@@ -94,11 +94,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
9494
9595 log:: debug!( "Using config file path: {:#?}" , config_file_path) ;
9696
97- if !config_file_path. exists ( ) {
98- log:: error!( "{:#?} doesn't exist" , config_file_path) ;
99- exit ( 1 ) ;
100- }
101-
10297 let hotkeys = match config:: load ( & config_file_path) {
10398 Err ( e) => {
10499 log:: error!( "Config Error: {}" , e) ;
@@ -319,7 +314,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
319314}
320315
321316fn 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) ?;
323320 stream. write_all ( command. as_bytes ( ) ) ?;
324321 Ok ( ( ) )
325322}
@@ -402,11 +399,11 @@ pub fn fetch_xdg_config_path() -> std::path::PathBuf {
402399}
403400
404401pub fn seteuid ( uid : u32 ) {
405- let uid = nix :: unistd :: Uid :: from_raw ( uid) ;
402+ let uid = Uid :: from_raw ( uid) ;
406403 match nix:: unistd:: seteuid ( uid) {
407404 Ok ( _) => log:: debug!( "Dropping privileges..." ) ,
408405 Err ( e) => {
409- log:: error!( "Failed to set UID : {:#?}" , e) ;
406+ log:: error!( "Failed to set EUID : {:#?}" , e) ;
410407 exit ( 1 ) ;
411408 }
412409 }
0 commit comments