-
Notifications
You must be signed in to change notification settings - Fork 11
/
redshifter
71 lines (65 loc) · 2.45 KB
/
redshifter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
#----------------------------------------------------------------------------------
# Project Name - miscellaneous/redshifter
# Started On - Tue 3 Oct 19:14:37 BST 2017
# Last Change - Mon 26 Mar 20:33:19 BST 2018
# Author E-Mail - [email protected]
# Author GitHub - https://github.com/terminalforlife
#----------------------------------------------------------------------------------
# Effective and simple tool to manually adjust the gamma via Redshift.
#
# IMPORTANT:
#
# This small script assumes you have redshift (and mkdir of course) installed and
# available. Also assumed is that you'll be using this script via keyboard
# shortcuts, not terminals.
#
# Calling bash to avoid dependencies and to make use of bash syntax.
#
# SYNTAX: redshifter [OPT]
#
# OPT: --version|-v - Output only the version datestamp.
# --increment|-i N - Increment gamma by N integer.
# --decrement|-d N - Decrement gamma by N integer.
# --reset|-r - Reset to the default.
#
# NOTE: As of 2018-03-26, redshifter no longer uses /tmp for the temporary
# file from which redshifter reads and sets the current value. This
# will be stored in the user's home directory, to keep the value from
# resetting upon reboot.
#
# If you do need to reset the value, simply delete the stored file:
#
# ~/.config/redshifter.tmp
#
# If this won't work, when it previously may have, check the value
# saved isn't a value of '-100' or something; must be an integer.
#----------------------------------------------------------------------------------
_VERSION_="2018-03-26"
BUFFER="$HOME/.config/redshifter.tmp"
[ -d "$HOME/.config" ] || /bin/mkdir "$HOME/.config"
if ! [ -f "$BUFFER" -a -r "$BUFFER" ]; then
GAMMAS_NOW=6500
printf "6500\n" > "$BUFFER"
else
GAMMAS_NOW=`< "$BUFFER"`
fi
case "$1" in
--version|-v)
printf "%s\n" "$_VERSION_"
exit 0 ;;
--reset|-r)
printf "6500\n" > "$BUFFER"
/usr/bin/redshift -o -O 6500K ;;
--increment|-i)
TEMP=$(( GAMMAS_NOW + $2 ))
[ $TEMP -gt 25000 ] && exit 0
printf "%d\n" "$TEMP" > "$BUFFER"
/usr/bin/redshift -o -O ${TEMP}K ;;
--decrement|-d)
TEMP=$(( GAMMAS_NOW - $2 ))
[ $TEMP -lt 1000 ] && exit 0
printf "%d\n" "$TEMP" > "$BUFFER"
/usr/bin/redshift -o -O ${TEMP}K ;;
esac
# vim: ft=sh noexpandtab colorcolumn=84 tabstop=8 noswapfile nobackup