From 042505573f22706463adc8003f4523fd4f7b64b5 Mon Sep 17 00:00:00 2001 From: Baitinq <30861839+Baitinq@users.noreply.github.com> Date: Thu, 18 Nov 2021 18:01:43 +0000 Subject: Rename smart_greyscale to smart-greyscale --- smart-greyscale | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ smart_greyscale | 59 --------------------------------------------------------- 2 files changed, 59 insertions(+), 59 deletions(-) create mode 100644 smart-greyscale delete mode 100644 smart_greyscale diff --git a/smart-greyscale b/smart-greyscale new file mode 100644 index 0000000..2aff820 --- /dev/null +++ b/smart-greyscale @@ -0,0 +1,59 @@ +#!/bin/bash + +# Requires redshift and picom + +period=300 +location="" + +trap cleanup EXIT + +cleanup() +{ + killall picom 2> /dev/null +} + +check_if_picom_already_running() +{ + if pgrep -x "picom" > /dev/null + then + echo "PICOM IS ALREADY RUNNING, PLEASE KILL IT AND EXECUTE THE SCRIPT AGAIN." + exit 1 + fi +} + +check_and_enable_if_night_or_day() +{ + if redshift -l $location -p | grep -i -q "day"; then + killall picom + else + if ! pgrep -x "picom" > /dev/null; then + picom -b --config /dev/null --backend glx --glx-fshader-win "uniform sampler2D tex; uniform float opacity; void main() { vec4 c = texture2D(tex, gl_TexCoord[0].xy); float y = dot(c.rgb, vec3(0.2126, 0.7152, 0.0722)); gl_FragColor = opacity*vec4(y, y, y, c.a); }" & + fi + fi +} + +while getopts ':l:p:' flag; do + case "${flag}" in + l) location="${OPTARG}" ;; + p) period="${OPTARG}" ;; + esac +done + +main() +{ + if [ "$location" == "" ]; then + echo "Need location argument [-l (LAT:LON)]" + exit 1 + fi + + check_if_picom_already_running + + while true + do + check_and_enable_if_night_or_day + + sleep $period + done +} + +main diff --git a/smart_greyscale b/smart_greyscale deleted file mode 100644 index 2aff820..0000000 --- a/smart_greyscale +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash - -# Requires redshift and picom - -period=300 -location="" - -trap cleanup EXIT - -cleanup() -{ - killall picom 2> /dev/null -} - -check_if_picom_already_running() -{ - if pgrep -x "picom" > /dev/null - then - echo "PICOM IS ALREADY RUNNING, PLEASE KILL IT AND EXECUTE THE SCRIPT AGAIN." - exit 1 - fi -} - -check_and_enable_if_night_or_day() -{ - if redshift -l $location -p | grep -i -q "day"; then - killall picom - else - if ! pgrep -x "picom" > /dev/null; then - picom -b --config /dev/null --backend glx --glx-fshader-win "uniform sampler2D tex; uniform float opacity; void main() { vec4 c = texture2D(tex, gl_TexCoord[0].xy); float y = dot(c.rgb, vec3(0.2126, 0.7152, 0.0722)); gl_FragColor = opacity*vec4(y, y, y, c.a); }" & - fi - fi -} - -while getopts ':l:p:' flag; do - case "${flag}" in - l) location="${OPTARG}" ;; - p) period="${OPTARG}" ;; - esac -done - -main() -{ - if [ "$location" == "" ]; then - echo "Need location argument [-l (LAT:LON)]" - exit 1 - fi - - check_if_picom_already_running - - while true - do - check_and_enable_if_night_or_day - - sleep $period - done -} - -main -- cgit 1.4.1