From e3b86d708fb5c2ad20618148d692036730b07416 Mon Sep 17 00:00:00 2001 From: Sravan Balaji Date: Wed, 4 Sep 2024 20:14:10 -0400 Subject: [PATCH] Update scripts to check if using wayland or x11 - game launch/exit script's picom disable/enable and xfce power manager presentation mode only apply when running dwm - GPU profile switching with nvidia-settings only works when running x11 --- README.org | 46 +++++++++++++++++++++++++--------- gaming/.scripts/game_exit.sh | 7 ++++-- gaming/.scripts/game_launch.sh | 7 ++++-- system76/.scripts/cpu-gpu.sh | 32 +++++++++++++++++------ 4 files changed, 68 insertions(+), 24 deletions(-) diff --git a/README.org b/README.org index ade6419..3806501 100644 --- a/README.org +++ b/README.org @@ -7467,11 +7467,14 @@ These are scripts that should be run from Lutris when launching or exiting a gam *Preferences > System options > Pre-launch script* #+BEGIN_SRC shell :shebang #!/usr/bin/env bash :tangle gaming/.scripts/game_launch.sh -/home/sravan/.scripts/picom.sh --off & +if [ $XDG_SESSION_DESKTOP == "dwm" ]; then + /home/sravan/.scripts/picom.sh --off & + /usr/bin/xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode -s true & +fi + /home/sravan/.scripts/cpu-gpu.sh --cpu-profile-performance & /home/sravan/.scripts/cpu-gpu.sh --gpu-profile-performance & /home/sravan/.scripts/dunst.sh --pause & -/usr/bin/xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode -s true & #+END_SRC *** Post-Exit Script @@ -7479,11 +7482,14 @@ These are scripts that should be run from Lutris when launching or exiting a gam *Preferences > System options > Post-exit script* #+BEGIN_SRC shell :shebang #!/usr/bin/env bash :tangle gaming/.scripts/game_exit.sh -/home/sravan/.scripts/picom.sh --on & +if [ $XDG_SESSION_DESKTOP == "dwm" ]; then + /home/sravan/.scripts/picom.sh --on & + /usr/bin/xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode -s false & +fi + /home/sravan/.scripts/dunst.sh --unpause & /home/sravan/.scripts/cpu-gpu.sh --cpu-profile-balanced & /home/sravan/.scripts/cpu-gpu.sh --gpu-profile-adaptive & -/usr/bin/xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode -s false & #+END_SRC *** PlayStation 5 (DualSense) to Xbox 360 Controller Button Mapping @@ -9425,20 +9431,36 @@ main() { rofi_gpu_profile_menu ;; --gpu-profile-query) - current_profile=$(nvidia-settings -q GpuPowerMizerMode) - notify-send "NVIDIA GPU Profile" "$current_profile" + if [ $XDG_SESSION_TYPE == "x11" ]; then + current_profile=$(nvidia-settings -q GpuPowerMizerMode) + notify-send "NVIDIA GPU Profile" "$current_profile" + elif [ $XDG_SESSION_TYPE == "wayland" ]; then + notify-send "NVIDIA GPU Profile not supported on Wayland" + fi ;; --gpu-profile-adaptive) - nvidia-settings -a "[gpu:0]/GpuPowerMizerMode=0" - notify-send "NVIDIA GPU Profile" "Switched to Adaptive Profile" + if [ $XDG_SESSION_TYPE == "x11" ]; then + nvidia-settings -a "[gpu:0]/GpuPowerMizerMode=0" + notify-send "NVIDIA GPU Profile" "Switched to Adaptive Profile" + elif [ $XDG_SESSION_TYPE == "wayland" ]; then + notify-send "NVIDIA GPU Profile not supported on Wayland" + fi ;; --gpu-profile-performance) - nvidia-settings -a "[gpu:0]/GpuPowerMizerMode=1" - notify-send "NVIDIA GPU Profile" "Switched to Performance Profile" + if [ $XDG_SESSION_TYPE == "x11" ]; then + nvidia-settings -a "[gpu:0]/GpuPowerMizerMode=1" + notify-send "NVIDIA GPU Profile" "Switched to Performance Profile" + elif [ $XDG_SESSION_TYPE == "wayland" ]; then + notify-send "NVIDIA GPU Profile not supported on Wayland" + fi ;; --gpu-profile-auto) - nvidia-settings -a "[gpu:0]/GpuPowerMizerMode=2" - notify-send "NVIDIA GPU Profile" "Switched to Auto Profile" + if [ $XDG_SESSION_TYPE == "x11" ]; then + nvidia-settings -a "[gpu:0]/GpuPowerMizerMode=2" + notify-send "NVIDIA GPU Profile" "Switched to Auto Profile" + elif [ $XDG_SESSION_TYPE == "wayland" ]; then + notify-send "NVIDIA GPU Profile not supported on Wayland" + fi ;; --rofi) rofi_menu diff --git a/gaming/.scripts/game_exit.sh b/gaming/.scripts/game_exit.sh index 4086458..3a049aa 100755 --- a/gaming/.scripts/game_exit.sh +++ b/gaming/.scripts/game_exit.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash -/home/sravan/.scripts/picom.sh --on & +if [ $XDG_SESSION_DESKTOP == "dwm" ]; then + /home/sravan/.scripts/picom.sh --on & + /usr/bin/xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode -s false & +fi + /home/sravan/.scripts/dunst.sh --unpause & /home/sravan/.scripts/cpu-gpu.sh --cpu-profile-balanced & /home/sravan/.scripts/cpu-gpu.sh --gpu-profile-adaptive & -/usr/bin/xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode -s false & diff --git a/gaming/.scripts/game_launch.sh b/gaming/.scripts/game_launch.sh index 71bdf66..43ef7e7 100755 --- a/gaming/.scripts/game_launch.sh +++ b/gaming/.scripts/game_launch.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash -/home/sravan/.scripts/picom.sh --off & +if [ $XDG_SESSION_DESKTOP == "dwm" ]; then + /home/sravan/.scripts/picom.sh --off & + /usr/bin/xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode -s true & +fi + /home/sravan/.scripts/cpu-gpu.sh --cpu-profile-performance & /home/sravan/.scripts/cpu-gpu.sh --gpu-profile-performance & /home/sravan/.scripts/dunst.sh --pause & -/usr/bin/xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode -s true & diff --git a/system76/.scripts/cpu-gpu.sh b/system76/.scripts/cpu-gpu.sh index 4265dd0..3194b27 100755 --- a/system76/.scripts/cpu-gpu.sh +++ b/system76/.scripts/cpu-gpu.sh @@ -148,20 +148,36 @@ main() { rofi_gpu_profile_menu ;; --gpu-profile-query) - current_profile=$(nvidia-settings -q GpuPowerMizerMode) - notify-send "NVIDIA GPU Profile" "$current_profile" + if [ $XDG_SESSION_TYPE == "x11" ]; then + current_profile=$(nvidia-settings -q GpuPowerMizerMode) + notify-send "NVIDIA GPU Profile" "$current_profile" + elif [ $XDG_SESSION_TYPE == "wayland" ]; then + notify-send "NVIDIA GPU Profile not supported on Wayland" + fi ;; --gpu-profile-adaptive) - nvidia-settings -a "[gpu:0]/GpuPowerMizerMode=0" - notify-send "NVIDIA GPU Profile" "Switched to Adaptive Profile" + if [ $XDG_SESSION_TYPE == "x11" ]; then + nvidia-settings -a "[gpu:0]/GpuPowerMizerMode=0" + notify-send "NVIDIA GPU Profile" "Switched to Adaptive Profile" + elif [ $XDG_SESSION_TYPE == "wayland" ]; then + notify-send "NVIDIA GPU Profile not supported on Wayland" + fi ;; --gpu-profile-performance) - nvidia-settings -a "[gpu:0]/GpuPowerMizerMode=1" - notify-send "NVIDIA GPU Profile" "Switched to Performance Profile" + if [ $XDG_SESSION_TYPE == "x11" ]; then + nvidia-settings -a "[gpu:0]/GpuPowerMizerMode=1" + notify-send "NVIDIA GPU Profile" "Switched to Performance Profile" + elif [ $XDG_SESSION_TYPE == "wayland" ]; then + notify-send "NVIDIA GPU Profile not supported on Wayland" + fi ;; --gpu-profile-auto) - nvidia-settings -a "[gpu:0]/GpuPowerMizerMode=2" - notify-send "NVIDIA GPU Profile" "Switched to Auto Profile" + if [ $XDG_SESSION_TYPE == "x11" ]; then + nvidia-settings -a "[gpu:0]/GpuPowerMizerMode=2" + notify-send "NVIDIA GPU Profile" "Switched to Auto Profile" + elif [ $XDG_SESSION_TYPE == "wayland" ]; then + notify-send "NVIDIA GPU Profile not supported on Wayland" + fi ;; --rofi) rofi_menu