From 122f54d3aed1728a6894a4a0a9e8f917cdfe853c Mon Sep 17 00:00:00 2001 From: Bartek Stalewski Date: Wed, 22 Feb 2023 16:19:33 +0100 Subject: [PATCH] Switch to rofi. --- _desktop/_scripts/{dmenu-audio => selector-audio} | 14 +++++++------- .../{dmenu-bluetooth => selector-bluetooth} | 12 ++++++------ _desktop/_scripts/{dmenu-chars => selector-chars} | 2 +- _desktop/install-desktop.sh | 2 +- _desktop/qtile/config.py | 8 ++++---- _desktop/rofi/config.rasi | 1 + 6 files changed, 20 insertions(+), 19 deletions(-) rename _desktop/_scripts/{dmenu-audio => selector-audio} (80%) rename _desktop/_scripts/{dmenu-bluetooth => selector-bluetooth} (96%) rename _desktop/_scripts/{dmenu-chars => selector-chars} (59%) create mode 100644 _desktop/rofi/config.rasi diff --git a/_desktop/_scripts/dmenu-audio b/_desktop/_scripts/selector-audio similarity index 80% rename from _desktop/_scripts/dmenu-audio rename to _desktop/_scripts/selector-audio index b28fe51..25f1152 100755 --- a/_desktop/_scripts/dmenu-audio +++ b/_desktop/_scripts/selector-audio @@ -1,9 +1,9 @@ #!/bin/sh -div="----------" +div="---" set_output() { - sel_sink=$(printf "$sinks\\n$div\\nback\\nexit" | dmenu -c -l 10 -i) + sel_sink=$(printf "$sinks\\n$div\\nback\\n$div\\nexit" | rofi -dmenu -i -p "select output device") case "$sel_sink" in back) show_current ;; exit) exit ;; @@ -14,7 +14,7 @@ set_output() { } set_input() { - sel_source=$(printf "$sources\\n$div\\nBluetooth profile\\n$div\\nback\\nexit" | dmenu -c -l 10 -i) + sel_source=$(printf "$sources\\n$div\\nbluetooth profile\\n$div\\nback\\n$div\\nexit" | rofi -dmenu -i -p "select input device") case "$sel_source" in back) show_current ;; exit) exit ;; @@ -29,7 +29,7 @@ set_bt_profile() { bt_sink=$(pactl list cards | awk -F'"' '/device.name.*bluez/ {print $2}') [ -z "${bt_sink}" ] && { notify-send -t 2000 -u critical "ﳌ no headphones connected"; exit; } - profile_chosen=$(printf "profile mSBC\\nprofile LDAC\\n$div\\nback\\nexit" | dmenu -c -l 5 -i) + profile_chosen=$(printf "profile mSBC\\nprofile LDAC\\n$div\\nback\\nexit" | rofi -dmenu -i -p "select bluettoth profile") case "$profile_chosen" in back) show_current ;; exit) exit ;; @@ -44,15 +44,15 @@ set_bt_profile() { show_current() { def_snk=$(pactl list | grep -A 1 "Name: $(pactl get-default-sink)\$" | awk -F': ' '/Description: / {print $2}') def_src=$(pactl list | grep -A 1 "Name: $(pactl get-default-source)\$" | awk -F': ' '/Description: / {print $2}') - chosen=$(printf "Output: $def_snk\\nInput: $def_src" | dmenu -c -l 2) + chosen=$(printf "output: $def_snk\\ninput: $def_src" | rofi -dmenu -i -p "current audio devices") if [ "$1" = "no_switch" ]; then case "$chosen" in *) notify-send -t 2000 -u critical "婢 no device to switch" ;; esac else case "$chosen" in - Output*) set_output ;; - Input*) set_input ;; + output*) set_output ;; + input*) set_input ;; esac fi } diff --git a/_desktop/_scripts/dmenu-bluetooth b/_desktop/_scripts/selector-bluetooth similarity index 96% rename from _desktop/_scripts/dmenu-bluetooth rename to _desktop/_scripts/selector-bluetooth index 4f68226..8aa1e96 100755 --- a/_desktop/_scripts/dmenu-bluetooth +++ b/_desktop/_scripts/selector-bluetooth @@ -9,7 +9,7 @@ # # Constants -divider="----------" +div="---" goback="back" # Checks if bluetooth controller is powered on @@ -215,13 +215,13 @@ device_menu() { fi paired=$(device_paired $mac) trusted=$(device_trusted $mac) - options="$connected\n$paired\n$trusted\n$divider\n$goback\nexit" + options="$connected\n$paired\n$trusted\n$div\n$goback\n$div\nexit" chosen="$(echo -e "$options" | $rofi_command "$device_name")" # Match chosen option to command case $chosen in - "" | $divider) + "" | $div) echo "no option chosen." ;; $connected) @@ -253,7 +253,7 @@ show_menu() { pairable=$(pairable_on) discoverable=$(discoverable_on) - options="$devices\n$divider\n$power\n$scan\n$pairable\n$discoverable\nexit" + options="$devices\n$div\n$power\n$scan\n$pairable\n$discoverable\nexit" else power="power: off" options="$power\nexit" @@ -263,7 +263,7 @@ show_menu() { # Match chosen option to command case $chosen in - "" | $divider) + "" | $div) echo "No option chosen." ;; $power) @@ -287,7 +287,7 @@ show_menu() { } # command to pipe into, can add any options here -rofi_command="dmenu -c -l 20 -i -p" +rofi_command="rofi -dmenu -i -p" case "$1" in --status) diff --git a/_desktop/_scripts/dmenu-chars b/_desktop/_scripts/selector-chars similarity index 59% rename from _desktop/_scripts/dmenu-chars rename to _desktop/_scripts/selector-chars index c4cccc0..7a1bdce 100755 --- a/_desktop/_scripts/dmenu-chars +++ b/_desktop/_scripts/selector-chars @@ -1,6 +1,6 @@ #!/bin/sh -chosen=$(cut -d ';' -f1 $XDG_CONFIG_HOME/qtile/chars/* | dmenu -l 30 -i | sed "s/ .*//") +chosen=$(cut -d ';' -f1 $XDG_CONFIG_HOME/qtile/chars/* | rofi -dmenu -i -p "select character to copy" | sed "s/ .*//") [ -z "$chosen" ] && exit if [ -n "$1" ]; then diff --git a/_desktop/install-desktop.sh b/_desktop/install-desktop.sh index 03be038..0e35a8f 100644 --- a/_desktop/install-desktop.sh +++ b/_desktop/install-desktop.sh @@ -4,7 +4,7 @@ mkdir -p ~/.config ~/.local/bin # link config -for i in foot gtk-3.0 kanshi neofetch qtile zathura; do +for i in foot gtk-3.0 kanshi neofetch qtile rofi zathura; do rm -rf ~/.config/${i} ln -sf $(pwd)/${i} ~/.config done diff --git a/_desktop/qtile/config.py b/_desktop/qtile/config.py index 917f483..e3c9151 100644 --- a/_desktop/qtile/config.py +++ b/_desktop/qtile/config.py @@ -31,7 +31,7 @@ groups = [ Group("0", label="\uf2bb", matches=[Match(wm_class=["workfx"])]), ScratchPad("scratchpad", [ DropDown( - "spterm", "sh -c 'BROWSER=firefox st'", + "spterm", "foot", on_focus_lost_hide=False, width=0.40, height=0.50, @@ -76,9 +76,9 @@ keys = [ Key([mod, "shift"], "e", lazy.group["scratchpad"].dropdown_toggle('spwork')), Key([mod, "shift"], "i", lazy.spawn("grim")), Key([mod, "shift"], "Return", lazy.spawn("sh -c 'terminal_profile=work foot -o url.launch=workfx\ \${url}'")), - Key([mod, "control"], "a", lazy.spawn("dmenu-audio")), - Key([mod, "control"], "b", lazy.spawn("dmenu-bluetooth")), - Key([mod, "control"], "e", lazy.spawn("dmenu-chars")), + Key([mod, "control"], "a", lazy.spawn("selector-audio")), + Key([mod, "control"], "b", lazy.spawn("selector-bluetooth")), + Key([mod, "control"], "e", lazy.spawn("selector-chars")), # WM control Key([mod], "f", lazy.window.toggle_floating()), Key([mod], "q", lazy.window.kill()), diff --git a/_desktop/rofi/config.rasi b/_desktop/rofi/config.rasi new file mode 100644 index 0000000..308e109 --- /dev/null +++ b/_desktop/rofi/config.rasi @@ -0,0 +1 @@ +@theme "/usr/local/share/rofi/themes/glue_pro_blue.rasi"