summaryrefslogtreecommitdiffstats
path: root/wp/.local/bin/wp-auto
blob: d5eeb126e62f818c450331251ceaa467ab2de962 (plain) (blame)
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
#! /bin/bash

SED=$(which sed)
ROFI=$(which rofi)

export DISPLAY=:0
HOUR=$(date +%H)

if [ -z "${SED}" ]
then
    echo "Did not find 'sed', script cannot continue."
    exit 1
fi
if [ -z "${ROFI}" ]
then
    echo "Did not find rofi, there is no point to continue."
    exit 1
fi

###
# Create if not exists, then removes #include of .theme file (if present) and add the selected theme to the end.
# Repeated calls should leave the config clean-ish
###
function set_theme()
{
    CDIR="${HOME}/.config/rofi/"
    if [ ! -d "${CDIR}" ]
    then
        mkdir -p ${CDIR}
    fi
    if [ -f "${CDIR}/config" ]
    then
        ${SED} -i "/rofi\.theme: .*\.rasi$/d" "${CDIR}/config"
    fi
    echo "rofi.theme: ${1}" >> "${CDIR}/config"

}

if [ "$HOUR" -gt "19" ] || [ "$HOUR" -lt "7" ]
    then
        feh --bg-scale $HOME/usr/pics/island_night_by_arsenixc-d6cz757.jpg
        xrdb -merge $HOME/.Xresources.d/gruvbox-dark.xresources
        set_theme "/usr/share/rofi/themes//gruvbox-dark.rasi"
    else
        feh --bg-scale $HOME/usr/pics/island_day_by_arsenixc-d6ctqon.jpg
        xrdb -merge $HOME/.Xresources.d/gruvbox-light.xresources
        set_theme "/usr/share/rofi/themes//gruvbox-light.rasi"
fi