update description
This commit is contained in:
parent
03981e5660
commit
6efd805cd8
2 changed files with 29 additions and 11 deletions
27
README.org
27
README.org
|
|
@ -3,17 +3,18 @@
|
|||
:header-args: :tangle nightlight :shebang "#!/bin/sh"
|
||||
: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.
|
||||
You can find the code below.
|
||||
|
||||
** Usage
|
||||
|
||||
1. Obtain your location code from [[https://weather.codes/search/][here]] and paste it into the script
|
||||
2. Get the IDs of your displays with =xrandr --listmonitors= and paste them into the script
|
||||
3. (Optionally) set the fading window which specifies the amount of minutes in which the screen is dimmed
|
||||
4. Make sure the script is executable (=chmod +x nightlight=) and run it with =./nightlight=
|
||||
1. Make sure the [[*Requirements][requirements]] are fulfilled
|
||||
2. Obtain your location code from [[https://weather.codes/search/][here]] and paste it into the script
|
||||
3. Get the IDs of your displays with =xrandr --listmonitors= and paste them into the script
|
||||
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.
|
||||
Please adjust your display ID and call for every display seperately.
|
||||
|
|
@ -27,9 +28,14 @@
|
|||
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
|
||||
# SETTINGS
|
||||
# Edit from here -->
|
||||
|
||||
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")
|
||||
window=60 # Fading window in minutes
|
||||
|
||||
# <-- to here
|
||||
#+END_SRC
|
||||
|
||||
** Requirements
|
||||
|
|
@ -49,18 +55,22 @@
|
|||
then
|
||||
echo -ne "\e[1mbc\e[0m was not found, please install it"
|
||||
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
|
||||
#+END_SRC
|
||||
|
||||
** 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
|
||||
file=/tmp/$location
|
||||
#+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=.
|
||||
|
||||
#+BEGIN_SRC sh
|
||||
|
|
@ -73,7 +83,7 @@
|
|||
- =sunrise= :: Time in seconds since the Unix epoch until sunrise
|
||||
- =sunset= :: Time in seconds since the Unix epoch until sunset
|
||||
- =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
|
||||
|
||||
|
|
@ -132,7 +142,6 @@
|
|||
}
|
||||
#+END_SRC
|
||||
|
||||
|
||||
** Set display
|
||||
|
||||
For setting the display values, we need to calculate the current RGB colors and brightness.
|
||||
|
|
|
|||
|
|
@ -1,8 +1,13 @@
|
|||
#!/bin/sh
|
||||
# SETTINGS
|
||||
# Edit from here -->
|
||||
|
||||
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")
|
||||
window=60 # Fading window in minutes
|
||||
|
||||
# <-- to here
|
||||
|
||||
if ! command -v wget &> /dev/null
|
||||
then
|
||||
echo -ne "\e[1mwget\e[0m was not found, please install it"
|
||||
|
|
@ -11,6 +16,10 @@ elif ! command -v bc &> /dev/null
|
|||
then
|
||||
echo -ne "\e[1mbc\e[0m was not found, please install it"
|
||||
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
|
||||
|
||||
file=/tmp/$location
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue