Reimplement script to temp change the timeout when locked
Script now changes the screen timeout when the screen is locked and restores the values after unlocking from the config-file.
This commit is contained in:
		
							parent
							
								
									a8cc54391c
								
							
						
					
					
						commit
						6d54498b39
					
				@ -1,18 +1,25 @@
 | 
				
			|||||||
#!/bin/sh
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					SCREENSAVER_TIMEOUT_DEFAULT=10
 | 
				
			||||||
 | 
					NORMAL_TIMEOUT_DEFAULT=1800
 | 
				
			||||||
 | 
					
 | 
				
			||||||
is_screen_locked()
 | 
					case "$1" in
 | 
				
			||||||
{
 | 
					  "locked")
 | 
				
			||||||
  if dbus-send --session --dest=org.freedesktop.ScreenSaver --type=method_call --print-reply /org/freedesktop/ScreenSaver org.freedesktop.ScreenSaver.GetActive | grep 'boolean true' > /dev/null; then
 | 
					    # Read timeout from KDE
 | 
				
			||||||
    return 0
 | 
					    SCREENSAVER_TIMEOUT=$(kreadconfig5 --file powermanagementprofilesrc --group AC --group DPMSControl --key idleTime_screenSaver)
 | 
				
			||||||
  else
 | 
					    TIMEOUT="${NORMAL_TIMEOUT:-$SCREENSAVER_TIMEOUT_DEFAULT}"
 | 
				
			||||||
    return 1
 | 
					    ;;
 | 
				
			||||||
  fi
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Sleep to timeout
 | 
					  "unlocked")
 | 
				
			||||||
sleep 15
 | 
					    # Read timeout from KDE
 | 
				
			||||||
 | 
					    NORMAL_TIMEOUT=$(kreadconfig5 --file powermanagementprofilesrc --group AC --group DPMSControl --key idleTime)
 | 
				
			||||||
 | 
					    TIMEOUT="${NORMAL_TIMEOUT:-$NORMAL_TIMEOUT_DEFAULT}"
 | 
				
			||||||
 | 
					    ;;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if is_screen_locked; then
 | 
					  *)
 | 
				
			||||||
    # Disable screens
 | 
					    echo "$0 <locked|unlocked>"
 | 
				
			||||||
    xset dpms force off
 | 
					    exit 1
 | 
				
			||||||
fi
 | 
					    ;;
 | 
				
			||||||
 | 
					esac
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Set timeout-value
 | 
				
			||||||
 | 
					xset s ${TIMEOUT} ${TIMEOUT}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user