Skip to content

Instantly share code, notes, and snippets.

@quantenProjects
Created June 17, 2018 17:04
Show Gist options
  • Save quantenProjects/1a8e7331be2bebc6e751a93ccbc1b6b3 to your computer and use it in GitHub Desktop.
Save quantenProjects/1a8e7331be2bebc6e751a93ccbc1b6b3 to your computer and use it in GitHub Desktop.
dirty Script to disable the powermanagment of KDE when inside my thinkpad dock, run with crontab every minute and it will inhibit powerdevil if the dock is present and unihibit if it is gone
export DISPLAY=":0"
export KONSOLE_DBUS_SESSION=/Sessions/1
export KONSOLE_DBUS_SERVICE=:1.30
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
STRDOCK=`lsusb | grep -o 17ef:100a`
ID="17ef:100a"
if [ -n "$STRDOCK" ]; then
#echo "in Dock"
if [ -e /run/user/1000/dockCookie ]; then
#echo "already inhibited, do nothing"
:
else
#echo "inhibit now"
qdbus local.org_kde_powerdevil /org/freedesktop/PowerManagement/Inhibit org.freedesktop.PowerManagement.Inhibit.Inhibit "Dock" "is in Dock" > /run/user/1000/dockCookie
echo "inhibited with cookie `cat /run/user/1000/dockCookie`"
fi
else
#echo "not in Dock"
if [ -e /run/user/1000/dockCookie ]; then
echo "deinhibit now with cookie `cat /run/user/1000/dockCookie`"
qdbus local.org_kde_powerdevil /org/freedesktop/PowerManagement/Inhibit org.freedesktop.PowerManagement.Inhibit.UnInhibit `cat /run/user/1000/dockCookie`
rm /run/user/1000/dockCookie
else
#echo "not inhibited, do nothing"
:
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment