Skip to content

Commit

Permalink
fix: use /tmp instead of a run dir
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanabx committed Apr 18, 2024
1 parent 0e4a05c commit b6758db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
20 changes: 7 additions & 13 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub async fn server(containers: Vec<(String, ContainerType)>) -> Result<(), Serv
log::error!("Error setting up client {}: {:?}", container_name, kind);
}
}
let _ = fs::remove_dir_all(Path::new("/tmp/container-desktop-entries/"));
loop {
// Busy wait until logging off, keeping the desktop entries alive
std::future::pending::<()>().await;
Expand All @@ -59,15 +60,8 @@ async fn set_up_client(
) -> Result<(), ClientSetupError> {
// Start client if client is not running
start_client(container_name, container_type)?;
let to_path_str = match env::var("RUNTIME_DIRECTORY") {
Ok(h) => h,
Err(_) => {
log::error!("RUNTIME_DIRECTORY NOT FOUND. Make sure you're using the service!");
panic!()
}
};

let to_path = Path::new(&to_path_str);
let to_path = Path::new("/tmp/container-desktop-entries/");
if !to_path.exists() {
log::warn!(
"Runtime directory {} does not exist! Attempting to create directory manually...",
Expand Down Expand Up @@ -119,9 +113,9 @@ async fn set_up_client(
let name_regex = Regex::new(container_type.format_name_regex_pattern().as_str()).unwrap();

for entry_path in fs::read_dir(to_path.join("applications")).unwrap() {
let path = entry_path.unwrap().path();
log::debug!("Looking at path: {:?}", path);
match read_to_string(&path) {
let path_buf = entry_path.unwrap().path();
log::debug!("Looking at path: {:?}", path_buf);
match read_to_string(&path_buf) {
Ok(file_text) => {
// run regex on it now
let file_text = exec_regex
Expand All @@ -137,7 +131,7 @@ async fn set_up_client(
)
.to_string();

match DesktopEntry::decode(&path, &file_text) {
match DesktopEntry::decode(&path_buf, &file_text) {
Ok(entry) => {
// We have a valid desktop entry
if entry.no_display() {
Expand Down Expand Up @@ -197,7 +191,7 @@ async fn set_up_client(
Err(e) => {
log::error!(
"Could not read path {:?} to string. Reason: {}",
path,
path_buf,
e.to_string()
);
}
Expand Down
1 change: 0 additions & 1 deletion systemd/container-desktop-entries.service
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ After=desktop-entry-daemon.service
Type=simple
Environment="RUST_LOG=debug"
ExecStart=container-desktop-entries
RuntimeDirectory=container-desktop-entries
Slice=session.slice

[Install]
Expand Down

0 comments on commit b6758db

Please sign in to comment.