dmenu-scripts/dmenu-gpu

44 lines
1.0 KiB
Plaintext
Raw Normal View History

2022-03-21 18:05:05 +01:00
#!/bin/sh
2022-04-05 16:59:13 +02:00
# a simple "gui" for envycontrol
2022-03-21 18:05:05 +01:00
already_in()
{
quick-notify "Gpu Manager" "Already in $new_mode mode"
}
switch()
{
if sudo envycontrol.py --switch $new_mode; then
quick-notify "Gpu Manager" "Switched to $new_mode mode"
else
quick-notify "Gpu Manager" "Failed to switch to $new_mode mode"
fi
}
case "$(printf "integrated\\nhybrid\\nnvidia" | dmenu -p "Choose gpu mode")" in
2022-04-05 16:59:13 +02:00
"integrated") new_mode="integrated";;
"nvidia") new_mode="nvidia";;
"hybrid") new_mode="hybrid";;
2022-03-21 18:05:05 +01:00
esac
current_mode=$(envycontrol.py --status | awk '{ print $5 }')
if [ $current_mode = "integrated" ]; then
case $new_mode in
"integrated") already_in;;
"nvidia") quick-notify "Gpu Manager" "You need to first reboot into hybrid mode";;
"hybrid") switch;;
esac
elif [ $current_mode = "hybrid" ]; then
case $new_mode in
"hybrid") already_in;;
*) switch;;
esac
elif [ $current_mode = "nvidia" ]; then
case $new_mode in
"nvidia") already_in;;
*) switch;;
esac
fi