NVIDIA GPU Profile Control

- Rename `system76-power.sh` to `cpu-gpu.sh`
- Add NVIDIA PowerMizer mode controls to `cpu-gpu.sh`
- Decrease rofi menu size to 50% of screen in both directions
  so notifications are not covered (e.g., when using profile
  query commands in `cpu-gpu.sh`)
- Switch to NVIDIA Performance Profile when launching game
- Switch to NVIDIA Adaptive Profile when exiting game
- Update control center script to work with renamed
  `cpu-gpu.sh`
This commit is contained in:
Sravan Balaji
2021-12-27 15:28:26 -05:00
parent f47ed175a3
commit c0bab6cde6
6 changed files with 135 additions and 51 deletions

View File

@@ -41,8 +41,8 @@
window {
location: center;
anchor: center;
height: 75%;
width: 75%;
height: 50%;
width: 50%;
orientation: horizontal;
children: [mainbox];
border: 2;

View File

@@ -16,7 +16,7 @@ rofi_menu() {
" Media - playerctl"
"墳Volume - pactl"
" Startup Processes - startup"
" Hardware - system76-power"
" Hardware - cpu-gpu"
" Power Menu - session"
" Back - back"
" Quit - quit"
@@ -56,8 +56,8 @@ main() {
--startup)
/home/sravan/.scripts/startup.sh --rofi
;;
--system76-power)
/home/sravan/.scripts/system76-power.sh --rofi
--cpu-gpu)
/home/sravan/.scripts/cpu-gpu.sh --rofi
;;
--session)
/home/sravan/.scripts/session.sh --rofi

View File

@@ -1,6 +1,6 @@
#!/bin/bash
help_menu() {
echo "Script to interact with system76-power. Use only one argument at a time."
echo "Script to control CPU & GPU modes / performance profiles. Use only one argument at a time."
# echo " - Play / Pause: playerctl.sh --play-pause"
# echo " - Next: playerctl.sh --next"
# echo " - Previous: playerctl.sh --prev"
@@ -11,8 +11,9 @@ help_menu() {
rofi_menu() {
declare -a options=(
" Switchable Graphics - rofi-graphics"
" Performance Profile - rofi-profile"
" CPU Performance Profile - rofi-cpu-profile"
" GPU Switching - rofi-graphics"
" NVIDIA GPU Performance Profile - rofi-gpu-profile"
" Back - back"
" Quit - quit"
)
@@ -27,6 +28,26 @@ rofi_menu() {
fi
}
rofi_cpu_profile_menu() {
declare -a options=(
"Query Current Profile - cpu-profile-query"
"Switch to Battery Mode - cpu-profile-battery"
"Switch to Balanced Mode - cpu-profile-balanced"
"Switch to Performance Mode - cpu-profile-performance"
" Back - back"
" Quit - quit"
)
choice=$(printf '%s\n' "${options[@]}" | rofi -dmenu -i)
option=$(printf '%s\n' "${choice}" | awk '{print $NF}')
if [[ "$option" == "quit" ]]; then
kilall rofi
elif [[ "$option" != "back" ]]; then
main "--$option" && main "--rofi-cpu-profile"
fi
}
rofi_graphics_menu() {
declare -a options=(
"Query Current Graphics - graphics-query"
@@ -48,12 +69,12 @@ rofi_graphics_menu() {
fi
}
rofi_profile_menu() {
rofi_gpu_profile_menu() {
declare -a options=(
"Query Current Profile - profile-query"
"Switch to Battery Mode - profile-battery"
"Switch to Balanced Mode - profile-balanced"
"Switch to Performance Mode - profile-performance"
"Query Current Profile - gpu-profile-query"
"Switch to Adaptive Mode - gpu-profile-adaptive"
"Switch to Performance Mode - gpu-profile-performance"
"Switch to Auto Mode - gpu-profile-auto"
" Back - back"
" Quit - quit"
)
@@ -64,7 +85,7 @@ rofi_profile_menu() {
if [[ "$option" == "quit" ]]; then
kilall rofi
elif [[ "$option" != "back" ]]; then
main "--$option" && main "--rofi-profile"
main "--$option" && main "--rofi-gpu-profile"
fi
}
@@ -104,24 +125,43 @@ main() {
pkexec system76-power graphics nvidia
notify-send -u critical -t 0 "System76-Power Graphics" "Please restart computer to switch graphics"
;;
--rofi-profile)
rofi_profile_menu
--rofi-cpu-profile)
rofi_cpu_profile_menu
;;
--profile-query)
--cpu-profile-query)
current_profile=$(pkexec system76-power profile)
notify-send "System76-Power Profile" "$current_profile"
notify-send "System76-Power CPU Profile" "$current_profile"
;;
--profile-battery)
--cpu-profile-battery)
pkexec system76-power profile battery
notify-send "System76-Power Profile" "Switched to Battery Profile"
notify-send "System76-Power CPU Profile" "Switched to Battery Profile"
;;
--profile-balanced)
--cpu-profile-balanced)
pkexec system76-power profile balanced
notify-send "System76-Power Profile" "Switched to Balanced Profile"
notify-send "System76-Power CPU Profile" "Switched to Balanced Profile"
;;
--profile-performance)
--cpu-profile-performance)
pkexec system76-power profile performance
notify-send "System76-Power Profile" "Switched to Performance Profile"
notify-send "System76-Power CPU Profile" "Switched to Performance Profile"
;;
--rofi-gpu-profile)
rofi_gpu_profile_menu
;;
--gpu-profile-query)
current_profile=$(nvidia-settings -q GpuPowerMizerMode)
notify-send "NVIDIA GPU Profile" "$current_profile"
;;
--gpu-profile-adaptive)
nvidia-settings -a "[gpu:0]/GpuPowerMizerMode=0"
notify-send "NVIDIA GPU Profile" "Switched to Adaptive Profile"
;;
--gpu-profile-performance)
nvidia-settings -a "[gpu:0]/GpuPowerMizerMode=1"
notify-send "NVIDIA GPU Profile" "Switched to Performance Profile"
;;
--gpu-profile-auto)
nvidia-settings -a "[gpu:0]/GpuPowerMizerMode=2"
notify-send "NVIDIA GPU Profile" "Switched to Auto Profile"
;;
--rofi)
rofi_menu

View File

@@ -1,2 +1,3 @@
#!/bin/bash
/home/sravan/.scripts/deadd.sh --unpause
/home/sravan/.scripts/cpu-gpu.sh --gpu-profile-adaptive

View File

@@ -1,3 +1,4 @@
#!/bin/bash
/home/sravan/.scripts/picom.sh --off
/home/sravan/.scripts/cpu-gpu.sh --gpu-profile-performance
/home/sravan/.scripts/deadd.sh --pause

View File

@@ -80,7 +80,7 @@
- [[#media-control][Media Control]]
- [[#volume-control][Volume Control]]
- [[#trackpad-control][Trackpad Control]]
- [[#system76-power-control][System76 Power Control]]
- [[#cpu--gpu-control][CPU & GPU Control]]
- [[#session-control][Session Control]]
- [[#startup][Startup]]
- [[#gaming-1][Gaming]]
@@ -1525,8 +1525,8 @@ configuration {
window {
location: center;
anchor: center;
height: 75%;
width: 75%;
height: 50%;
width: 50%;
orientation: horizontal;
children: [mainbox];
border: 2;
@@ -7475,11 +7475,11 @@ else
fi
#+END_SRC
** System76 Power Control
** CPU & GPU Control
#+BEGIN_SRC shell :shebang #!/bin/bash :tangle .scripts/system76-power.sh
#+BEGIN_SRC shell :shebang #!/bin/bash :tangle .scripts/cpu-gpu.sh
help_menu() {
echo "Script to interact with system76-power. Use only one argument at a time."
echo "Script to control CPU & GPU modes / performance profiles. Use only one argument at a time."
# echo " - Play / Pause: playerctl.sh --play-pause"
# echo " - Next: playerctl.sh --next"
# echo " - Previous: playerctl.sh --prev"
@@ -7490,8 +7490,9 @@ help_menu() {
rofi_menu() {
declare -a options=(
" Switchable Graphics - rofi-graphics"
" Performance Profile - rofi-profile"
" CPU Performance Profile - rofi-cpu-profile"
" GPU Switching - rofi-graphics"
" NVIDIA GPU Performance Profile - rofi-gpu-profile"
" Back - back"
" Quit - quit"
)
@@ -7506,6 +7507,26 @@ rofi_menu() {
fi
}
rofi_cpu_profile_menu() {
declare -a options=(
"Query Current Profile - cpu-profile-query"
"Switch to Battery Mode - cpu-profile-battery"
"Switch to Balanced Mode - cpu-profile-balanced"
"Switch to Performance Mode - cpu-profile-performance"
" Back - back"
" Quit - quit"
)
choice=$(printf '%s\n' "${options[@]}" | rofi -dmenu -i)
option=$(printf '%s\n' "${choice}" | awk '{print $NF}')
if [[ "$option" == "quit" ]]; then
kilall rofi
elif [[ "$option" != "back" ]]; then
main "--$option" && main "--rofi-cpu-profile"
fi
}
rofi_graphics_menu() {
declare -a options=(
"Query Current Graphics - graphics-query"
@@ -7527,12 +7548,12 @@ rofi_graphics_menu() {
fi
}
rofi_profile_menu() {
rofi_gpu_profile_menu() {
declare -a options=(
"Query Current Profile - profile-query"
"Switch to Battery Mode - profile-battery"
"Switch to Balanced Mode - profile-balanced"
"Switch to Performance Mode - profile-performance"
"Query Current Profile - gpu-profile-query"
"Switch to Adaptive Mode - gpu-profile-adaptive"
"Switch to Performance Mode - gpu-profile-performance"
"Switch to Auto Mode - gpu-profile-auto"
" Back - back"
" Quit - quit"
)
@@ -7543,7 +7564,7 @@ rofi_profile_menu() {
if [[ "$option" == "quit" ]]; then
kilall rofi
elif [[ "$option" != "back" ]]; then
main "--$option" && main "--rofi-profile"
main "--$option" && main "--rofi-gpu-profile"
fi
}
@@ -7583,24 +7604,43 @@ main() {
pkexec system76-power graphics nvidia
notify-send -u critical -t 0 "System76-Power Graphics" "Please restart computer to switch graphics"
;;
--rofi-profile)
rofi_profile_menu
--rofi-cpu-profile)
rofi_cpu_profile_menu
;;
--profile-query)
--cpu-profile-query)
current_profile=$(pkexec system76-power profile)
notify-send "System76-Power Profile" "$current_profile"
notify-send "System76-Power CPU Profile" "$current_profile"
;;
--profile-battery)
--cpu-profile-battery)
pkexec system76-power profile battery
notify-send "System76-Power Profile" "Switched to Battery Profile"
notify-send "System76-Power CPU Profile" "Switched to Battery Profile"
;;
--profile-balanced)
--cpu-profile-balanced)
pkexec system76-power profile balanced
notify-send "System76-Power Profile" "Switched to Balanced Profile"
notify-send "System76-Power CPU Profile" "Switched to Balanced Profile"
;;
--profile-performance)
--cpu-profile-performance)
pkexec system76-power profile performance
notify-send "System76-Power Profile" "Switched to Performance Profile"
notify-send "System76-Power CPU Profile" "Switched to Performance Profile"
;;
--rofi-gpu-profile)
rofi_gpu_profile_menu
;;
--gpu-profile-query)
current_profile=$(nvidia-settings -q GpuPowerMizerMode)
notify-send "NVIDIA GPU Profile" "$current_profile"
;;
--gpu-profile-adaptive)
nvidia-settings -a "[gpu:0]/GpuPowerMizerMode=0"
notify-send "NVIDIA GPU Profile" "Switched to Adaptive Profile"
;;
--gpu-profile-performance)
nvidia-settings -a "[gpu:0]/GpuPowerMizerMode=1"
notify-send "NVIDIA GPU Profile" "Switched to Performance Profile"
;;
--gpu-profile-auto)
nvidia-settings -a "[gpu:0]/GpuPowerMizerMode=2"
notify-send "NVIDIA GPU Profile" "Switched to Auto Profile"
;;
--rofi)
rofi_menu
@@ -7850,6 +7890,7 @@ These are scripts that should be run from Lutris when launching or exiting a gam
#+BEGIN_SRC shell :shebang #!/bin/bash :tangle .scripts/game_launch.sh
/home/sravan/.scripts/picom.sh --off
/home/sravan/.scripts/cpu-gpu.sh --gpu-profile-performance
/home/sravan/.scripts/deadd.sh --pause
#+END_SRC
@@ -7859,6 +7900,7 @@ These are scripts that should be run from Lutris when launching or exiting a gam
#+BEGIN_SRC shell :shebang #!/bin/bash :tangle .scripts/game_exit.sh
/home/sravan/.scripts/deadd.sh --unpause
/home/sravan/.scripts/cpu-gpu.sh --gpu-profile-adaptive
#+END_SRC
** Control Center
@@ -7881,7 +7923,7 @@ rofi_menu() {
" Media - playerctl"
"墳Volume - pactl"
" Startup Processes - startup"
" Hardware - system76-power"
" Hardware - cpu-gpu"
" Power Menu - session"
" Back - back"
" Quit - quit"
@@ -7921,8 +7963,8 @@ main() {
--startup)
/home/sravan/.scripts/startup.sh --rofi
;;
--system76-power)
/home/sravan/.scripts/system76-power.sh --rofi
--cpu-gpu)
/home/sravan/.scripts/cpu-gpu.sh --rofi
;;
--session)
/home/sravan/.scripts/session.sh --rofi