shownotes-w3m-rice/redshift_toggle.sh
2017-05-22 00:12:52 -07:00

31 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
# _ _ _ _
# __ _ ___ | |_| |__ | | ___| |_ _ _
# / _` |/ _ \| __| '_ \| |/ _ \ __| | | |
#| (_| | (_) | |_| |_) | | __/ |_| |_| |
# \__, |\___/ \__|_.__/|_|\___|\__|\__,_|
# |___/
# https://www.youtube.com/user/gotbletu
# https://twitter.com/gotbletu
# https://plus.google.com/+gotbletu
# https://github.com/gotbletu
# gotbleu@gmail.com
# DESC: Toggle redshift on and off
# DEMO: https://www.youtube.com/watch?v=c8v84LRTeUw
# Requirements: redshift, notify-send (libnotify)
# check if process is running ( 0 = off, 1 = on )
STATUS="$(ps -ef | grep -w '[r]edshift' | wc -l)"
# if off then turn on
if [[ "${STATUS}" == 0 ]]; then
notify-send -i /usr/share/icons/hicolor/scalable/apps/redshift-status-on.svg "RedShift" "On"
redshift >/dev/null 2>&1 & disown
# else if on then turn off
elif [[ "${STATUS}" == 1 ]]; then
notify-send -i /usr/share/icons/hicolor/scalable/apps/redshift-status-off.svg "RedShift" "Off"
redshift -x && killall redshift
fi