Skip to content
This repository was archived by the owner on Feb 16, 2025. It is now read-only.

Commit b6758db

Browse files
committed
fix: use /tmp instead of a run dir
1 parent 0e4a05c commit b6758db

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

Diff for: src/server.rs

+7-13
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pub async fn server(containers: Vec<(String, ContainerType)>) -> Result<(), Serv
4747
log::error!("Error setting up client {}: {:?}", container_name, kind);
4848
}
4949
}
50+
let _ = fs::remove_dir_all(Path::new("/tmp/container-desktop-entries/"));
5051
loop {
5152
// Busy wait until logging off, keeping the desktop entries alive
5253
std::future::pending::<()>().await;
@@ -59,15 +60,8 @@ async fn set_up_client(
5960
) -> Result<(), ClientSetupError> {
6061
// Start client if client is not running
6162
start_client(container_name, container_type)?;
62-
let to_path_str = match env::var("RUNTIME_DIRECTORY") {
63-
Ok(h) => h,
64-
Err(_) => {
65-
log::error!("RUNTIME_DIRECTORY NOT FOUND. Make sure you're using the service!");
66-
panic!()
67-
}
68-
};
6963

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

121115
for entry_path in fs::read_dir(to_path.join("applications")).unwrap() {
122-
let path = entry_path.unwrap().path();
123-
log::debug!("Looking at path: {:?}", path);
124-
match read_to_string(&path) {
116+
let path_buf = entry_path.unwrap().path();
117+
log::debug!("Looking at path: {:?}", path_buf);
118+
match read_to_string(&path_buf) {
125119
Ok(file_text) => {
126120
// run regex on it now
127121
let file_text = exec_regex
@@ -137,7 +131,7 @@ async fn set_up_client(
137131
)
138132
.to_string();
139133

140-
match DesktopEntry::decode(&path, &file_text) {
134+
match DesktopEntry::decode(&path_buf, &file_text) {
141135
Ok(entry) => {
142136
// We have a valid desktop entry
143137
if entry.no_display() {
@@ -197,7 +191,7 @@ async fn set_up_client(
197191
Err(e) => {
198192
log::error!(
199193
"Could not read path {:?} to string. Reason: {}",
200-
path,
194+
path_buf,
201195
e.to_string()
202196
);
203197
}

Diff for: systemd/container-desktop-entries.service

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ After=desktop-entry-daemon.service
77
Type=simple
88
Environment="RUST_LOG=debug"
99
ExecStart=container-desktop-entries
10-
RuntimeDirectory=container-desktop-entries
1110
Slice=session.slice
1211

1312
[Install]

0 commit comments

Comments
 (0)