#!/usr/bin/env bash # theme - change the current desktop theme (XFCE) to light, dark, or based on # the time of day. other programs should update automatically. # # usage: theme set -euo pipefail LIGHT_THEME=Greybird DARK_THEME=Greybird-dark usage() { echo "usage: theme " exit 1 } set_theme() { xfconf-query -c xfwm4 -p /general/theme -s "$1" xfconf-query -c xsettings -p /Net/ThemeName -s "$1" gsettings set org.gnome.desktop.interface color-scheme "$2" } set_light_theme() { set_theme $LIGHT_THEME default } set_dark_theme() { set_theme $DARK_THEME prefer-dark } set_auto_theme() { current_time=$(date +"%s") time_for_dark=$(date -d "18:00" +"%s") if [ "$current_time" -gt "$time_for_dark" ]; then set_dark_theme else set_light_theme fi } case ${1-} in light) set_light_theme;; dark) set_dark_theme;; auto) set_auto_theme;; *) usage;; esac