#!/bin/sh 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 "integrated") new_mode="integrated";; "nvidia") new_mode="nvidia";; "hybrid") new_mode="hybrid";; 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