[rc] add rc.org for centralized literate configs
[~bandali/configs] / wp / .local / bin / wp-auto
1 #! /bin/bash
2
3 SED=$(which sed)
4 ROFI=$(which rofi)
5
6 export DISPLAY=:0
7 HOUR=$(date +%H)
8
9 if [ -z "${SED}" ]
10 then
11 echo "Did not find 'sed', script cannot continue."
12 exit 1
13 fi
14 if [ -z "${ROFI}" ]
15 then
16 echo "Did not find rofi, there is no point to continue."
17 exit 1
18 fi
19
20 ###
21 # Create if not exists, then removes #include of .theme file (if present) and add the selected theme to the end.
22 # Repeated calls should leave the config clean-ish
23 ###
24 function set_theme()
25 {
26 CDIR="${HOME}/.config/rofi/"
27 if [ ! -d "${CDIR}" ]
28 then
29 mkdir -p ${CDIR}
30 fi
31 if [ -f "${CDIR}/config" ]
32 then
33 ${SED} -i "/rofi\.theme: .*\.rasi$/d" "${CDIR}/config"
34 fi
35 echo "rofi.theme: ${1}" >> "${CDIR}/config"
36
37 }
38
39 if [ "$HOUR" -gt "19" ] || [ "$HOUR" -lt "7" ]
40 then
41 feh --bg-scale $HOME/usr/pics/island_night_by_arsenixc-d6cz757.jpg
42 xrdb -merge $HOME/.Xresources.d/gruvbox-dark.xresources
43 set_theme "/usr/share/rofi/themes//gruvbox-dark.rasi"
44 else
45 feh --bg-scale $HOME/usr/pics/island_day_by_arsenixc-d6ctqon.jpg
46 xrdb -merge $HOME/.Xresources.d/gruvbox-light.xresources
47 set_theme "/usr/share/rofi/themes//gruvbox-light.rasi"
48 fi