@@ -94,11 +94,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
94
94
95
95
log:: debug!( "Using config file path: {:#?}" , config_file_path) ;
96
96
97
- if !config_file_path. exists ( ) {
98
- log:: error!( "{:#?} doesn't exist" , config_file_path) ;
99
- exit ( 1 ) ;
100
- }
101
-
102
97
let hotkeys = match config:: load ( & config_file_path) {
103
98
Err ( e) => {
104
99
log:: error!( "Config Error: {}" , e) ;
@@ -319,7 +314,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
319
314
}
320
315
321
316
fn sock_send ( command : & str ) -> std:: io:: Result < ( ) > {
322
- let mut stream = UnixStream :: connect ( "/tmp/swhkd.sock" ) ?;
317
+ let sock_file_path =
318
+ String :: from ( format ! ( "/run/user/{}/swhkd.sock" , env:: var( "PKEXEC_UID" ) . unwrap( ) ) ) ;
319
+ let mut stream = UnixStream :: connect ( sock_file_path) ?;
323
320
stream. write_all ( command. as_bytes ( ) ) ?;
324
321
Ok ( ( ) )
325
322
}
@@ -402,11 +399,11 @@ pub fn fetch_xdg_config_path() -> std::path::PathBuf {
402
399
}
403
400
404
401
pub fn seteuid ( uid : u32 ) {
405
- let uid = nix :: unistd :: Uid :: from_raw ( uid) ;
402
+ let uid = Uid :: from_raw ( uid) ;
406
403
match nix:: unistd:: seteuid ( uid) {
407
404
Ok ( _) => log:: debug!( "Dropping privileges..." ) ,
408
405
Err ( e) => {
409
- log:: error!( "Failed to set UID : {:#?}" , e) ;
406
+ log:: error!( "Failed to set EUID : {:#?}" , e) ;
410
407
exit ( 1 ) ;
411
408
}
412
409
}
0 commit comments