+some small fixes -redundancy
This commit is contained in:
parent
a7cbe56f39
commit
87b8f37e99
38
opti-sw.sh
38
opti-sw.sh
@ -34,29 +34,30 @@ rc_msg() {
|
|||||||
printf "\n\n"
|
printf "\n\n"
|
||||||
echo "If you haven't done so already, please put the following line at the top of your display manager or XOrg init script (for example ~/.xinitrc for startx or /usr/share/sddm/scripts/Xsetup for SDDM):"
|
echo "If you haven't done so already, please put the following line at the top of your display manager or XOrg init script (for example ~/.xinitrc for startx or /usr/share/sddm/scripts/Xsetup for SDDM):"
|
||||||
echo "sh $HOME/.local/lib/nvidia-switch-rc.sh"
|
echo "sh $HOME/.local/lib/nvidia-switch-rc.sh"
|
||||||
printf "%${TERM_WIDTH}s" | tr " " "_"
|
printf "%${TERM_WIDTH}s\n" | tr " " "_"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Make suspend work for NVIDIA
|
# Make suspend work for NVIDIA
|
||||||
install_nvidia_suspend_script() {
|
install_nvidia_suspend_script() {
|
||||||
[ ! -d /lib64/elogind/system-sleep/ ] &&
|
[ ! -d /lib64/elogind/system-sleep/ ] &&
|
||||||
echo "Unable to install NVIDIA suspend script: /lib64/elogind/system-sleep/ not found. This might be because you aren't using elogind."
|
echo "Unable to install NVIDIA suspend script: /lib64/elogind/system-sleep/ not found. This might be because you aren't using elogind." &&
|
||||||
|
return 1
|
||||||
|
|
||||||
sudo sh -c "echo '#!/usr/bin/env sh' > $SUSPEND_SCRIPT"
|
sudo sh -c "echo '#!/usr/bin/env sh
|
||||||
sudo sh -c "echo '# Managed by opti-sw.sh' >> $SUSPEND_SCRIPT"
|
# Managed by opti-sw.sh
|
||||||
sudo sh -c "echo 'lsmod | grep \"^nvidia\" || exit 0' >> $SUSPEND_SCRIPT"
|
lsmod | cut -d\" \" -f1 | grep \"^nvidia\$\" > /dev/null || exit 0
|
||||||
sudo sh -c "echo 'WHEN=\"\$1\"' >> $SUSPEND_SCRIPT"
|
WHEN=\"\$1\"
|
||||||
sudo sh -c "echo 'WHAT=\"\$2\"' >> $SUSPEND_SCRIPT"
|
WHAT=\"\$2\"
|
||||||
sudo sh -c "echo 'if [ pre = \"\$WHEN\" ]; then' >> $SUSPEND_SCRIPT"
|
if [ pre = \"\$WHEN\" ]; then
|
||||||
sudo sh -c "echo ' if [ suspend = \"\$WHAT\" ]; then' >> $SUSPEND_SCRIPT"
|
if [ suspend = \"\$WHAT\" ]; then
|
||||||
sudo sh -c "echo ' /usr/bin/nvidia-sleep.sh suspend' >> $SUSPEND_SCRIPT"
|
/usr/bin/nvidia-sleep.sh suspend
|
||||||
sudo sh -c "echo ' else' >> $SUSPEND_SCRIPT"
|
else
|
||||||
sudo sh -c "echo ' /usr/bin/nvidia-sleep.sh hibernate' >> $SUSPEND_SCRIPT"
|
/usr/bin/nvidia-sleep.sh hibernate
|
||||||
sudo sh -c "echo ' fi' >> $SUSPEND_SCRIPT"
|
fi
|
||||||
sudo sh -c "echo 'elif [ post = \"\$WHEN\" ]; then' >> $SUSPEND_SCRIPT"
|
elif [ post = \"\$WHEN\" ]; then
|
||||||
sudo sh -c "echo ' sleep 1' >> $SUSPEND_SCRIPT"
|
sleep 1
|
||||||
sudo sh -c "echo ' /usr/bin/nvidia-sleep.sh resume &' >> $SUSPEND_SCRIPT"
|
/usr/bin/nvidia-sleep.sh resume &
|
||||||
sudo sh -c "echo 'fi' >> $SUSPEND_SCRIPT"
|
fi' > $SUSPEND_SCRIPT"
|
||||||
|
|
||||||
sudo chmod +x $SUSPEND_SCRIPT
|
sudo chmod +x $SUSPEND_SCRIPT
|
||||||
}
|
}
|
||||||
@ -81,8 +82,11 @@ case $OPT in
|
|||||||
|
|
||||||
# Make suspend work
|
# Make suspend work
|
||||||
[ ! -e "$SUSPEND_SCRIPT" ] && install_nvidia_suspend_script && echo "Installed $SUSPEND_SCRIPT to make suspend work on NVIDIA"
|
[ ! -e "$SUSPEND_SCRIPT" ] && install_nvidia_suspend_script && echo "Installed $SUSPEND_SCRIPT to make suspend work on NVIDIA"
|
||||||
|
|
||||||
echo "Switched to NVIDIA GPU. You will probably need to restart."
|
echo "Switched to NVIDIA GPU. You will probably need to restart."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
[ ! -e ~/.local/lib/nvidia-switch-rc.sh ] && mkdir -p ~/.local/lib/ && touch ~/.local/lib/nvidia-switch-rc.sh && chmod +x ~/.local/lib/nvidia-switch-rc.sh
|
[ ! -e ~/.local/lib/nvidia-switch-rc.sh ] && mkdir -p ~/.local/lib/ && touch ~/.local/lib/nvidia-switch-rc.sh && chmod +x ~/.local/lib/nvidia-switch-rc.sh
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user