From a933010810b91b8cdefcd264fe4a23ffb9689069 Mon Sep 17 00:00:00 2001 From: itspngu <34752364+itspngu@users.noreply.github.com> Date: Mon, 21 Dec 2020 19:31:41 +0100 Subject: make tests individually executable --- tests/autostart.bats | 4 +++- tests/describe.bats | 2 ++ tests/entries.bats | 4 +++- tests/generate-command.bats | 4 +++- tests/providers.bats | 2 ++ 5 files changed, 13 insertions(+), 3 deletions(-) mode change 100644 => 100755 tests/autostart.bats mode change 100644 => 100755 tests/describe.bats mode change 100644 => 100755 tests/entries.bats mode change 100644 => 100755 tests/generate-command.bats mode change 100644 => 100755 tests/providers.bats diff --git a/tests/autostart.bats b/tests/autostart.bats old mode 100644 new mode 100755 index 0197a30..f2019f3 --- a/tests/autostart.bats +++ b/tests/autostart.bats @@ -1,3 +1,5 @@ +#!/usr/bin/env bats + setup() { export TERMINAL_COMMAND='urxvt -e' export XDG_CONFIG_HOME=./data/autostart-folders/0 @@ -11,4 +13,4 @@ setup() { [[ ${#lines[@]} == 2 ]] [[ ${lines[0]} =~ data/autostart-folders/0/autostart/firefox.desktop ]] [[ ${lines[1]} =~ data/autostart-folders/1/autostart/htop.desktop ]] -} \ No newline at end of file +} diff --git a/tests/describe.bats b/tests/describe.bats old mode 100644 new mode 100755 index 1ac58ff..7692c63 --- a/tests/describe.bats +++ b/tests/describe.bats @@ -1,3 +1,5 @@ +#!/usr/bin/env bats + @test "Name and description of firefox desktop file are properly extracted" { run env XDG_CONFIG_HOME=./data/config ../sway-launcher-desktop.sh describe desktop ./data/desktop-files/0/applications/firefox.desktop [ "$status" -eq 0 ] diff --git a/tests/entries.bats b/tests/entries.bats old mode 100644 new mode 100755 index e6781ed..dd77fd8 --- a/tests/entries.bats +++ b/tests/entries.bats @@ -1,3 +1,5 @@ +#!/usr/bin/env bats + @test "Firefox desktop entry and all its actions are extracted" { run ../sway-launcher-desktop.sh entries data/desktop-files/0/applications/firefox.desktop echo -e "OUTPUT:\n$output" @@ -19,4 +21,4 @@ echo "EXPECTED: foo-bar.desktop ACTUAL: $output" [ "$status" -eq 0 ] [[ ${#lines[@]} == 6 ]] -} \ No newline at end of file +} diff --git a/tests/generate-command.bats b/tests/generate-command.bats old mode 100644 new mode 100755 index 1dccc13..2a30cd0 --- a/tests/generate-command.bats +++ b/tests/generate-command.bats @@ -1,3 +1,5 @@ +#!/usr/bin/env bats + setup() { export TERMINAL_COMMAND='urxvt -e' } @@ -21,4 +23,4 @@ setup() { run ../sway-launcher-desktop.sh generate-command data/desktop-files/0/applications/minecraft-launcher.desktop [ "$status" -eq 0 ] [[ "$output" == 'cd /opt/minecraft-launcher/ && env GDK_BACKEND=x11 /opt/minecraft-launcher/minecraft-launcher' ]] -} \ No newline at end of file +} diff --git a/tests/providers.bats b/tests/providers.bats old mode 100644 new mode 100755 index 1c11f0d..21a061f --- a/tests/providers.bats +++ b/tests/providers.bats @@ -1,3 +1,5 @@ +#!/usr/bin/env bats + @test "Builtin desktop provider works" { run env XDG_CONFIG_HOME=./data/config XDG_DATA_HOME=./data/desktop-files/1 XDG_DATA_DIRS=./data/desktop-files/0 ../sway-launcher-desktop.sh provide desktop echo "OUTPUT:$output" -- cgit v1.2.3 From e8626e74da1f54d4e0d04d0d014b5ac98b56868f Mon Sep 17 00:00:00 2001 From: itspngu <34752364+itspngu@users.noreply.github.com> Date: Tue, 22 Dec 2020 11:37:45 +0100 Subject: make glyphs overridable --- sway-launcher-desktop.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sway-launcher-desktop.sh b/sway-launcher-desktop.sh index a8ee3dc..8841568 100755 --- a/sway-launcher-desktop.sh +++ b/sway-launcher-desktop.sh @@ -13,8 +13,12 @@ IFS=$'\n\t' DEL=$'\34' TERMINAL_COMMAND="${TERMINAL_COMMAND:="$TERM -e"}" -GLYPH_COMMAND=" " -GLYPH_DESKTOP=" " +if [[ -n $GLYPH_COMMAND ]]; then + GLYPH_COMMAND=" " +fi +if [[ -n $GLYPH_DESKTOP ]]; then + GLYPH_DESKTOP=" " +fi CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/sway-launcher-desktop" PROVIDERS_FILE="${PROVIDERS_FILE:=providers.conf}" if [[ "${PROVIDERS_FILE#/}" == "${PROVIDERS_FILE}" ]]; then @@ -259,6 +263,7 @@ COMMAND_STR=$( fzf +s -x -d '\034' --nth ..3 --with-nth 3 \ --preview "$0 describe {2} {1}" \ --preview-window=up:3:wrap --ansi \ + --no-info --margin="3%" --cycle \ <"$FZFPIPE" ) || exit 1 -- cgit v1.2.3 From 0bfa512856821e69b5efcb5c9c191d748ff1a55e Mon Sep 17 00:00:00 2001 From: itspngu <34752364+itspngu@users.noreply.github.com> Date: Tue, 22 Dec 2020 11:43:15 +0100 Subject: make glyphs overridable --- sway-launcher-desktop.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/sway-launcher-desktop.sh b/sway-launcher-desktop.sh index 8841568..d9e6b0b 100755 --- a/sway-launcher-desktop.sh +++ b/sway-launcher-desktop.sh @@ -13,12 +13,8 @@ IFS=$'\n\t' DEL=$'\34' TERMINAL_COMMAND="${TERMINAL_COMMAND:="$TERM -e"}" -if [[ -n $GLYPH_COMMAND ]]; then - GLYPH_COMMAND=" " -fi -if [[ -n $GLYPH_DESKTOP ]]; then - GLYPH_DESKTOP=" " -fi +GLYPH_COMMAND="${GLYPH_COMMAND- }" +GLYPH_DESKTOP="${GLYPH_DESKTOP- }" CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/sway-launcher-desktop" PROVIDERS_FILE="${PROVIDERS_FILE:=providers.conf}" if [[ "${PROVIDERS_FILE#/}" == "${PROVIDERS_FILE}" ]]; then -- cgit v1.2.3 From dfe17905246e6d2ecf4c1dfc4f860d13958a09f5 Mon Sep 17 00:00:00 2001 From: itspngu <34752364+itspngu@users.noreply.github.com> Date: Tue, 22 Dec 2020 13:17:17 +0100 Subject: clean up UI, allow overriding fzf default prompt, update readme --- README.md | 9 ++++++--- sway-launcher-desktop.sh | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 936f6ea..e69d22f 100644 --- a/README.md +++ b/README.md @@ -25,12 +25,15 @@ Arch Linux users can also grab it from the AUR (thanks @turtlewit) Configure it in Sway like this: ``` -for_window [class="URxvt" instance="launcher"] floating enable, border pixel 10, sticky enable -set $menu exec urxvt -geometry 55x18 -name launcher -e env TERMINAL_COMMAND="urxvt -e" /path/to/repo/sway-launcher-desktop.sh +for_window [app_id="^launcher$"] floating enable, sticky enable, resize set 30 ppt 60 ppt, border pixel 10 +set $menu exec $term --class=launcher -e /path/to/repo/sway-launcher-desktop.sh bindsym $mod+d exec $menu ``` - +You can override the default icons/glyphs by setting the appropriate GLYPH_ variable in your $menu command, e.g.: +``` +set $menu exec $term --class=launcher -e env GLYPH_COMMAND="" GLYPH_DESKTOP="" GLYPH_PROMPT="? " sway-launcher +``` ### Setup a Terminal command Some of your desktop entries will probably be TUI programs that expect to be launched in a new terminal window. Those entries have the `Terminal=true` flag set and you need to tell the launcher which terminal emulator to use. Pass the `TERMINAL_COMMAND` environment variable with your terminal startup command to the script to use your preferred terminal emulator. The script will default to `$TERM -e` diff --git a/sway-launcher-desktop.sh b/sway-launcher-desktop.sh index d9e6b0b..859f25d 100755 --- a/sway-launcher-desktop.sh +++ b/sway-launcher-desktop.sh @@ -256,10 +256,13 @@ for PROVIDER_NAME in "${!PROVIDERS[@]}"; do done COMMAND_STR=$( - fzf +s -x -d '\034' --nth ..3 --with-nth 3 \ + fzf --ansi +s -x -d '\034' --nth ..3 --with-nth 3 \ --preview "$0 describe {2} {1}" \ - --preview-window=up:3:wrap --ansi \ - --no-info --margin="3%" --cycle \ + --preview-window=up:2:noborder \ + --no-mouse --no-multi --cycle \ + --prompt="${GLYPH_PROMPT-# }" \ + --header='' --no-info --margin='1,2' \ + --color='16,gutter:-1' \ <"$FZFPIPE" ) || exit 1 -- cgit v1.2.3 From 8f4cb34b9046cded085a84badea3ef84c491c759 Mon Sep 17 00:00:00 2001 From: itspngu <34752364+itspngu@users.noreply.github.com> Date: Tue, 22 Dec 2020 21:20:12 +0100 Subject: reverted mouse disable thingie --- sway-launcher-desktop.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway-launcher-desktop.sh b/sway-launcher-desktop.sh index 859f25d..e58c053 100755 --- a/sway-launcher-desktop.sh +++ b/sway-launcher-desktop.sh @@ -259,7 +259,7 @@ COMMAND_STR=$( fzf --ansi +s -x -d '\034' --nth ..3 --with-nth 3 \ --preview "$0 describe {2} {1}" \ --preview-window=up:2:noborder \ - --no-mouse --no-multi --cycle \ + --no-multi --cycle \ --prompt="${GLYPH_PROMPT-# }" \ --header='' --no-info --margin='1,2' \ --color='16,gutter:-1' \ -- cgit v1.2.3