Skip to content

Instantly share code, notes, and snippets.

@Bluey26
Created May 6, 2024 20:53
Show Gist options
  • Save Bluey26/0e9b5d09d97c62bdb806f16cee50ef3d to your computer and use it in GitHub Desktop.
Save Bluey26/0e9b5d09d97c62bdb806f16cee50ef3d to your computer and use it in GitHub Desktop.
GammaStep filedialog, which uses 'qarma' to set an specific screen temperature and close the window. Has to be used with a .desktop file pointing to this .sh
#!/bin/bash
menu=("4500" "3500" "RemoveEffect")
answer=`zenity --list --column=Menu ${menu[@]} --title "GammastepColor" --height 200`
if [ "$answer" = "4500" ]; then
#We Verify if there is a gammastep process running and if its running, we kill it before applying new temperature:
processo=$(pidof gammastep)
if [[ -n $processo ]]; then
kill $processo
fi
gammastep -O 4500
exit 1
elif [ "$answer" = "${menu[1]}" ]; then
processo=$(pidof gammastep)
if [[ -n $processo ]]; then
kill $processo
fi
gammastep -O 3500
exit 1
elif [ "$answer" = "${menu[2]}" ]; then
processo=$(pidof gammastep)
if [[ -n $processo ]]; then
kill $processo
fi
exit 1
else
exit 1
fi
@Bluey26
Copy link
Author

Bluey26 commented May 6, 2024

Screenshot-qarma

Example picture, using qarma.

The script should also be able to work properly with Zenity(without modifications, i think) and could be made with 'Yad' too (modifications may be needed in the dialog parts).

Gammastep (https://gitlab.com/chinstrap/gammastep ) is a redshift-like program for wayland, which has the set -O temperature option, to set an specific temperature, independent of the WM of Wayland.

@Bluey26
Copy link
Author

Bluey26 commented May 11, 2024

Terminal version (with custom value option):

#!/bin/bash

echo -e "Select the screen temperature : \n1=4500 \n2=3500 \n3=Default \n4=CustomValue(>2000 y <6500)"
read -n 1 -p 'Insert your option:' NUM
echo -e " " 
echo -e "$NUM Has been choosen"

#Verify if gammestep is running:
processo=$(pidof gammastep)


if [ "$NUM" = '1' ]
then
 if [[ -n $processo ]]; then
  kill $processo
 fi
 nohup gammastep -O 4500 >/dev/null 2>&1 &
	sleep 1
elif [ "$NUM" = '2' ]
then
 if [[ -n $processo ]]; then
  kill $processo
 fi
 nohup gammastep -O 3500 >/dev/null 2>&1 &
	sleep 1
elif [ "$NUM" = '3' ]
then
 if [[ -n $processo ]]; then
  kill $processo
 fi
 sleep 1
elif [ "$NUM" = '4' ]
then
 if [[ -n $processo ]]; then
  kill $processo
 fi
 echo 'Insert a temperature value between 2000 y 6500:'
 read VALOR
 
  if ((VALOR >= 2000 && VALOR <= 6500)); then
   nohup gammastep -O $VALOR >/dev/null 2>&1 &
    sleep 1
  else
   echo 'Invalid input, the value should be between 2000 y 6500'
  fi 

else
	echo Nothing has been done.
fi

This can be launched with a custom .desktop file which points to that .sh file:

[Desktop Entry]
Name=GammaStepT
GenericName=
Comment=
Exec=PATH_TO_DIRECTORY/gammastepterminal.sh
Type=Application
Icon=gammastep
Terminal=true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment