summaryrefslogtreecommitdiff
path: root/x11/awww/files/patch-daemon_src_wallpaper.rs
blob: b24020b3e702032eacf0596677189cd710a044e6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
--- daemon/src/wallpaper.rs.orig	2026-04-25 17:08:32 UTC
+++ daemon/src/wallpaper.rs
@@ -312,25 +312,42 @@ impl Wallpaper {
                             cache.resize, cache.filter, cache.img_path
                         );
                         common::log::debug!("{}", cmd);
-                        match unsafe { rustix::runtime::kernel_fork() } {
-                            Ok(rustix::runtime::Fork::Child(_)) => {
-                                let args: [*const u8; 4] = [
-                                    c"sh".as_ptr().cast(),
-                                    c"-c".as_ptr().cast(),
-                                    cmd.as_ptr(),
-                                    core::ptr::null(),
-                                ];
-                                let err = unsafe {
-                                    rustix::runtime::execve(
-                                        c"/bin/sh",
-                                        args.as_ptr(),
-                                        environ as *const _,
-                                    )
-                                };
-                                panic!("execve failed: {err}");
+                        #[cfg(target_os = "linux")]
+                        {
+                            match unsafe { rustix::runtime::kernel_fork() } {
+                                Ok(rustix::runtime::Fork::Child(_)) => {
+                                    let args: [*const u8; 4] = [
+                                        c"sh".as_ptr().cast(),
+                                        c"-c".as_ptr().cast(),
+                                        cmd.as_ptr(),
+                                        core::ptr::null(),
+                                    ];
+                                    let err = unsafe {
+                                        rustix::runtime::execve(
+                                            c"/bin/sh",
+                                            args.as_ptr(),
+                                            environ as *const _,
+                                        )
+                                    };
+                                    panic!("execve failed: {err}");
+                                }
+                                Ok(rustix::runtime::Fork::ParentOf(_)) => (),
+                                Err(e) => error!("fork failed: {e}"),
                             }
-                            Ok(rustix::runtime::Fork::ParentOf(_)) => (),
-                            Err(e) => error!("fork failed: {e}"),
+                        }
+                        #[cfg(not(target_os = "linux"))]
+                        {
+                            use std::process::Command;
+
+                            let cmd_str = cmd.trim_end_matches('\0');
+                            match Command::new("/bin/sh")
+                                .arg("-c")
+                                .arg(cmd_str)
+                                .spawn()
+                            {
+                                Ok(_) => {}
+                                Err(e) => error!("fork/exec failed: {e}"),
+                            }
                         }
                     }
                     Ok(None) => break 'brk,