Created
August 13, 2021 11:50
-
-
Save budasuyasa/616b30d2b71cb4f2ddb13547ddeb4b0b to your computer and use it in GitHub Desktop.
Lenovo S340 Conservation Mode Toggler Script
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
#!/usr/bin/env bash | |
if [[ -z $1 || $1 == "0" || $1 == "1" ]]; then | |
mode=$([ -z $1 ] && echo "1" || echo $1) | |
modeMessage=$([ "$mode" == 1 ] && echo "on 🟢" || echo "off ⛔") | |
echo $mode >> /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode | |
if [[ $? == 0 ]]; then | |
echo "Conservation mode $modeMessage" | |
sudo -u asha DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus notify-send -a "Lenovo S340" "Conservation mode $modeMessage " | |
fi | |
else | |
echo "Please provide argument 1 to turn on, or 0 to turn off" | |
exit 1; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment