update description
This commit is contained in:
parent
03981e5660
commit
6efd805cd8
2 changed files with 29 additions and 11 deletions
31
README.org
31
README.org
|
|
@ -3,17 +3,18 @@
|
||||||
:header-args: :tangle nightlight :shebang "#!/bin/sh"
|
:header-args: :tangle nightlight :shebang "#!/bin/sh"
|
||||||
:END:
|
:END:
|
||||||
|
|
||||||
This is a shell script for automatically setting the screen colors and brightness based on daytime.
|
This is a shell script for automatically setting the screen colors and brightness, based on daytime.
|
||||||
|
|
||||||
The script is created via literate programming.
|
The script is created via literate programming.
|
||||||
You can find the code below.
|
You can find the code below.
|
||||||
|
|
||||||
** Usage
|
** Usage
|
||||||
|
|
||||||
1. Obtain your location code from [[https://weather.codes/search/][here]] and paste it into the script
|
1. Make sure the [[*Requirements][requirements]] are fulfilled
|
||||||
2. Get the IDs of your displays with =xrandr --listmonitors= and paste them into the script
|
2. Obtain your location code from [[https://weather.codes/search/][here]] and paste it into the script
|
||||||
3. (Optionally) set the fading window which specifies the amount of minutes in which the screen is dimmed
|
3. Get the IDs of your displays with =xrandr --listmonitors= and paste them into the script
|
||||||
4. Make sure the script is executable (=chmod +x nightlight=) and run it with =./nightlight=
|
4. (Optionally) set the fading window which specifies the amount of minutes in which the screen is dimmed
|
||||||
|
5. Make sure the script is executable (=chmod +x nightlight=) and run it with =./nightlight=
|
||||||
|
|
||||||
If you are unhappy with the display settings, you can revert them always by stopping the script and calling the following command manually.
|
If you are unhappy with the display settings, you can revert them always by stopping the script and calling the following command manually.
|
||||||
Please adjust your display ID and call for every display seperately.
|
Please adjust your display ID and call for every display seperately.
|
||||||
|
|
@ -27,13 +28,18 @@
|
||||||
Configuration is currently done via editing the script directly or editing this file and then tangling it with Emacs (=C-c C-v t=).
|
Configuration is currently done via editing the script directly or editing this file and then tangling it with Emacs (=C-c C-v t=).
|
||||||
|
|
||||||
#+BEGIN_SRC sh
|
#+BEGIN_SRC sh
|
||||||
|
# SETTINGS
|
||||||
|
# Edit from here -->
|
||||||
|
|
||||||
location="GMXX0128" # Location code (get it from https://weather.codes/search/)
|
location="GMXX0128" # Location code (get it from https://weather.codes/search/)
|
||||||
displays=("eDP-1-1") # Displays e.g. ("eDP-1-1" "eDP-1-2") (get displays with "xrandr --listmonitors")
|
displays=("eDP-1-1") # Displays e.g. ("eDP-1-1" "eDP-1-2") (get displays with "xrandr --listmonitors")
|
||||||
window=60 # Fading window in minutes
|
window=60 # Fading window in minutes
|
||||||
#+END_SRC
|
|
||||||
|
# <-- to here
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
** Requirements
|
** Requirements
|
||||||
|
|
||||||
- [[https://www.gnu.org/software/wget/][Wget]] :: Used for getting sunrise and sunset times
|
- [[https://www.gnu.org/software/wget/][Wget]] :: Used for getting sunrise and sunset times
|
||||||
- [[https://www.gnu.org/software/bc/][bc]] :: Used for floating point calculations
|
- [[https://www.gnu.org/software/bc/][bc]] :: Used for floating point calculations
|
||||||
- [[https://xorg.freedesktop.org/][xrandr]] :: Used for setting screen colors and brightess, usually shipped with X.Org
|
- [[https://xorg.freedesktop.org/][xrandr]] :: Used for setting screen colors and brightess, usually shipped with X.Org
|
||||||
|
|
@ -49,18 +55,22 @@
|
||||||
then
|
then
|
||||||
echo -ne "\e[1mbc\e[0m was not found, please install it"
|
echo -ne "\e[1mbc\e[0m was not found, please install it"
|
||||||
exit 1
|
exit 1
|
||||||
|
elif ! command -v xrandr &> /dev/null
|
||||||
|
then
|
||||||
|
echo -ne "\e[1mxrandr\e[0m was not found, are you using X.Org?"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
** Local variables
|
** Local variables
|
||||||
|
|
||||||
The file containig the sunrise and sunset is stored in =/tmp=.
|
The file containing the sunrise and sunset is stored in =/tmp=.
|
||||||
|
|
||||||
#+BEGIN_SRC sh
|
#+BEGIN_SRC sh
|
||||||
file=/tmp/$location
|
file=/tmp/$location
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
To make calculations easier, we scale the fading window down to seconds (=* 60=) and divide it in half (=* 0.5=).
|
To make calculations easier, we scale the fading window down to seconds (=*60=) and divide it in half (=*0.5=).
|
||||||
This results in a multiplication with =30=.
|
This results in a multiplication with =30=.
|
||||||
|
|
||||||
#+BEGIN_SRC sh
|
#+BEGIN_SRC sh
|
||||||
|
|
@ -73,7 +83,7 @@
|
||||||
- =sunrise= :: Time in seconds since the Unix epoch until sunrise
|
- =sunrise= :: Time in seconds since the Unix epoch until sunrise
|
||||||
- =sunset= :: Time in seconds since the Unix epoch until sunset
|
- =sunset= :: Time in seconds since the Unix epoch until sunset
|
||||||
- =now= :: Time in seconds since the Unix epoch until now
|
- =now= :: Time in seconds since the Unix epoch until now
|
||||||
- =value= :: Dim value in range [0:1] (0 at day, 1 at night, values in between if in interval around sunrise or sunset)
|
- =value= :: Dim value in range [0:1] (0 at day, 1 at night, values in between if in window around sunrise or sunset)
|
||||||
|
|
||||||
** Get times
|
** Get times
|
||||||
|
|
||||||
|
|
@ -132,7 +142,6 @@
|
||||||
}
|
}
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
|
||||||
** Set display
|
** Set display
|
||||||
|
|
||||||
For setting the display values, we need to calculate the current RGB colors and brightness.
|
For setting the display values, we need to calculate the current RGB colors and brightness.
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# SETTINGS
|
||||||
|
# Edit from here -->
|
||||||
|
|
||||||
location="GMXX0128" # Location code (get it from https://weather.codes/search/)
|
location="GMXX0128" # Location code (get it from https://weather.codes/search/)
|
||||||
displays=("eDP-1-1") # Displays e.g. ("eDP-1-1" "eDP-1-2") (get displays with "xrandr --listmonitors")
|
displays=("eDP-1-1") # Displays e.g. ("eDP-1-1" "eDP-1-2") (get displays with "xrandr --listmonitors")
|
||||||
window=60 # Fading window in minutes
|
window=60 # Fading window in minutes
|
||||||
|
|
||||||
|
# <-- to here
|
||||||
|
|
||||||
if ! command -v wget &> /dev/null
|
if ! command -v wget &> /dev/null
|
||||||
then
|
then
|
||||||
echo -ne "\e[1mwget\e[0m was not found, please install it"
|
echo -ne "\e[1mwget\e[0m was not found, please install it"
|
||||||
|
|
@ -11,6 +16,10 @@ elif ! command -v bc &> /dev/null
|
||||||
then
|
then
|
||||||
echo -ne "\e[1mbc\e[0m was not found, please install it"
|
echo -ne "\e[1mbc\e[0m was not found, please install it"
|
||||||
exit 1
|
exit 1
|
||||||
|
elif ! command -v xrandr &> /dev/null
|
||||||
|
then
|
||||||
|
echo -ne "\e[1mxrandr\e[0m was not found, are you using X.Org?"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
file=/tmp/$location
|
file=/tmp/$location
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue