diff options
Diffstat (limited to 'karlcommon')
-rw-r--r-- | karlcommon/src/lib.rs | 5 | ||||
-rw-r--r-- | karlcommon/src/protocol.rs | 8 |
2 files changed, 11 insertions, 2 deletions
diff --git a/karlcommon/src/lib.rs b/karlcommon/src/lib.rs index 66df90d..f5e0798 100644 --- a/karlcommon/src/lib.rs +++ b/karlcommon/src/lib.rs @@ -7,8 +7,9 @@ use std::{ pub use protocol::*; pub fn socket_path() -> PathBuf { - Path::new("/run/user") - .join(format!("{}", getuid())) + std::env::var("XDG_RUNTIME_DIR") + .map(|p| Path::new(p.as_str()).to_path_buf()) + .unwrap_or_else(|_| Path::new("/run/user").join(format!("{}", getuid()))) .join("calendar") } fn getuid() -> u32 { diff --git a/karlcommon/src/protocol.rs b/karlcommon/src/protocol.rs index 25dfc66..4dc8724 100644 --- a/karlcommon/src/protocol.rs +++ b/karlcommon/src/protocol.rs @@ -59,6 +59,14 @@ pub enum Schedule { Static(Range<i64>), } +impl Schedule { + /// Returns `true` if the schedule is [`Dynamic`]. + /// + /// [`Dynamic`]: Schedule::Dynamic + pub fn is_dynamic(&self) -> bool { + matches!(self, Self::Dynamic { .. }) + } +} #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] |