From 46cdb519eaac846da84f447ee220f8628dcc2646 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Tue, 7 Mar 2023 12:08:47 +0100 Subject: [PATCH] flavours: Call bemenu selection from wrapper function If we call the listing and applying function directly we either select a random colorscheme on *no* selection or we have to make use of either xargs GNU functionality or something like moreutils ifne to only select color schemes on selection. Can additionally set a random theme (if selection is 'random') or a random light theme (if selection is 'light'). --- desktop/.config/river/init | 2 +- desktop/.local/bin/flavourchoose | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100755 desktop/.local/bin/flavourchoose diff --git a/desktop/.config/river/init b/desktop/.config/river/init index 5e6ce83..33cc3e7 100755 --- a/desktop/.config/river/init +++ b/desktop/.config/river/init @@ -71,7 +71,7 @@ riverctl map normal $mod+Shift T spawn "bemenu-translate" # Desktop theming # shellcheck disable=SC2016 -riverctl map normal $mod+Shift S spawn 'flavours list -l | bemenu | xargs flavours apply' +riverctl map normal $mod+Shift S spawn 'flavourchoose' # Password dropdown frontend riverctl map normal $mod+Shift P spawn "pass-pick" diff --git a/desktop/.local/bin/flavourchoose b/desktop/.local/bin/flavourchoose new file mode 100755 index 0000000..fc242cc --- /dev/null +++ b/desktop/.local/bin/flavourchoose @@ -0,0 +1,26 @@ +#!/usr/bin/env sh + +picker=dmenu +if exist bemenu; then + picker=bemenu +elif exist wofi; then + picker=wofi +elif exist rofi; then + picker=rofi +fi + +list=$(flavours list -l) +flavour=$(printf "%s\nrandom\nlight" "$list" | "$picker") +if [ -z "$flavour" ]; then + return +elif [ "$flavour" = "random" ]; then + flavours apply '*' +elif [ "$flavour" = "light" ]; then + flavours apply '*light' +else + flavours apply "$flavour" +fi + +if [ "$1" = '-v' ]; then + notify-send "Theme set" "set to: $flavour" +fi