Last active
March 7, 2018 21:27
-
-
Save yuan3y/a4effdc88bf5f13654cace493bc3a3aa to your computer and use it in GitHub Desktop.
This script prevents lock screen from dimming. Tested on Ubuntu 16.04.2 LTS with default Unity interface.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Copyright (c) 2017 @yuan3y | |
# Released under MIT License | |
# Tested on Ubuntu 16.04.2 LTS with default Unity interface | |
# | |
# USAGE: | |
# chmod +x install_prevent_lock_screen_dim.sh | |
# ./install_prevent_lock_screen_dim.sh | |
scriptFile=~/.prevent_lock_screen_dim.sh | |
desktopFile=~/.config/autostart/.prevent_lock_screen_dim.sh.desktop | |
if hash xdotool 2>/dev/null; then | |
echo "Checking xdotool exists: PASS" | |
else | |
echo "Checking xdotool exists: FAILED" | |
while true; do | |
read -p "Do you wish to install xdotool the commandline X11 automation tool?" yn | |
case $yn in | |
[Yy]* ) sudo apt-get install xdotool; break;; | |
[Nn]* ) exit;; | |
* ) echo "Please answer yes or no.";; | |
esac | |
done | |
fi | |
cat > ${scriptFile} <<_EOF | |
#!/bin/bash | |
# This script prevents lock screen from dimming while it is running. | |
# | |
# Copyright (c) 2017 @yuan3y | |
# Released under MIT License | |
# Tested on Ubuntu 16.04.2 LTS with default Unity interface | |
# | |
# To uninstall the script, | |
# # 1) Kill all running instance, | |
# kill \$(ps aux | grep '[p]revent_lock_screen_dim.sh' | awk '{print \$2}') | |
# # 2) remove it from Startup Applications, or run the following command | |
# rm ${desktopFile} | |
# rm ${scriptFile} | |
dbus-monitor --session "type='signal',interface='com.ubuntu.Upstart0_6'" | | |
while read x; do | |
case "\$x" in | |
*"started"*) sleep 1; xdotool key "Escape";; | |
esac | |
done | |
_EOF | |
chmod +x ${scriptFile} | |
cat > ${desktopFile} <<_EOF | |
[Desktop Entry] | |
Type=Application | |
Exec=${HOME}/.prevent_lock_screen_dim.sh | |
Hidden=false | |
NoDisplay=false | |
X-GNOME-Autostart-enabled=true | |
Name=Prevent Lock Screen Dimming | |
Comment=Preventing Lock Screen from Dimming | |
_EOF | |
${scriptFile} &>/dev/null & | |
echo "Installation is done. Your lock screen will be prevented from dimming." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment