Skip to content

Instantly share code, notes, and snippets.

@budasuyasa
Created August 13, 2021 11:50
Show Gist options
  • Save budasuyasa/616b30d2b71cb4f2ddb13547ddeb4b0b to your computer and use it in GitHub Desktop.
Save budasuyasa/616b30d2b71cb4f2ddb13547ddeb4b0b to your computer and use it in GitHub Desktop.
Lenovo S340 Conservation Mode Toggler Script
#!/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