From cd5b7f6e87de15d6f5c0ae8f4149ba4b97d6dce4 Mon Sep 17 00:00:00 2001 From: Liam Egan Date: Wed, 23 Sep 2026 12:05:29 -0400 Subject: [PATCH] Add auto theme command --- bin/theme | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/bin/theme b/bin/theme index 2922642..3f2ba10 100755 --- a/bin/theme +++ b/bin/theme @@ -1,9 +1,9 @@ #!/usr/bin/env bash -# theme - change the current desktop theme (XFCE) to light or dark. other -# programs should update automatically. +# theme - change the current desktop theme (XFCE) to light, dark, or based on +# the time of day. other programs should update automatically. # -# usage: theme +# usage: theme set -euo pipefail @@ -11,7 +11,7 @@ LIGHT_THEME=Greybird DARK_THEME=Greybird-dark usage() { - echo "usage: theme " + echo "usage: theme " exit 1 } @@ -29,8 +29,19 @@ 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 -- knotmirror 0.0.1