@@ -8,8 +8,7 @@ use std::{
8
8
collections:: HashMap ,
9
9
error:: Error ,
10
10
process:: { Child , Command } ,
11
- sync:: atomic:: AtomicBool ,
12
- sync:: { Arc , Mutex } ,
11
+ sync:: { atomic:: AtomicBool , Arc , Mutex } ,
13
12
thread:: sleep,
14
13
time:: { Duration , Instant } ,
15
14
} ;
@@ -45,6 +44,7 @@ impl DBusInterface for DBusRunner {
45
44
msg. read3 :: < String , HashMap < _ , _ > , Vec < String > > ( ) . unwrap ( ) . 1 ;
46
45
if let Some ( playback_status) = items. get ( "PlaybackStatus" ) {
47
46
if let Some ( status) = playback_status. 0 . as_str ( ) {
47
+ log:: debug!( "Status found {}" , status) ;
48
48
if status == "Playing" {
49
49
good_to_send. store ( true , std:: sync:: atomic:: Ordering :: SeqCst ) ;
50
50
} else {
@@ -121,8 +121,6 @@ impl IdleApp {
121
121
Ok ( child) => {
122
122
log:: debug!( "Swayidle is inhibiting now!" ) ;
123
123
inhibit. 0 = Some ( child) ;
124
- process_running
125
- . store ( true , std:: sync:: atomic:: Ordering :: SeqCst ) ;
126
124
}
127
125
Err ( e) => {
128
126
eprintln ! ( "unable to block swayidle :: {:?}" , e)
@@ -152,6 +150,7 @@ impl IdleApp {
152
150
153
151
fn run_cmd ( & self ) -> Result < Child , Box < dyn Error > > {
154
152
log:: debug!( "command is spawning" ) ;
153
+ let process_running = Arc :: clone ( & self . process_running ) ;
155
154
match Command :: new ( "systemd-inhibit" )
156
155
. arg ( "--what" )
157
156
. arg ( "idle" )
@@ -170,6 +169,7 @@ impl IdleApp {
170
169
if let Ok ( mut last_block_time) = self . last_block_time . lock ( ) {
171
170
* last_block_time = Some ( Instant :: now ( ) ) ;
172
171
}
172
+ process_running. store ( true , std:: sync:: atomic:: Ordering :: SeqCst ) ;
173
173
Ok ( child)
174
174
}
175
175
Err ( e) => {
@@ -185,13 +185,13 @@ impl IdleApp {
185
185
186
186
const INTERFACE_NAME : & str = "org.freedesktop.DBus.Properties" ;
187
187
const DBUS_NAMESPACE : & str = "/org/mpris/MediaPlayer2" ;
188
- const INHIBIT_DURATION : u64 = 55 ;
188
+ const INHIBIT_DURATION : u64 = 25 ;
189
189
const OVERLAP_DURATION : u64 = 5 ;
190
190
191
191
fn main ( ) -> Result < ( ) , Box < dyn Error > > {
192
192
env_logger:: Builder :: from_env ( Env :: default ( ) . default_filter_or ( "info" ) ) . init ( ) ;
193
193
log:: debug!( "Swaddle starting up" ) ;
194
- let app = IdleApp :: new ( 60 ) ?;
194
+ let app = IdleApp :: new ( 30 ) ?;
195
195
app. run ( )
196
196
}
197
197
0 commit comments