From be6c50d95f79590ec990fc69dae635c19c96604b Mon Sep 17 00:00:00 2001 From: Joe Fiorini Date: Tue, 22 Oct 2019 16:16:30 -0400 Subject: Add Terminal property support --- sway-launcher-desktop.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sway-launcher-desktop.sh b/sway-launcher-desktop.sh index efcb8e2..52fdf7a 100755 --- a/sway-launcher-desktop.sh +++ b/sway-launcher-desktop.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash # terminal application launcher for sway, using fzf # Based on: https://gitlab.com/FlyingWombat/my-scripts/blob/master/sway-launcher +# https://gist.github.com/Biont/40ef59652acf3673520c7a03c9f22d2a shopt -s nullglob if [[ "$1" == 'describe' ]]; then @@ -19,6 +20,8 @@ if [[ "$1" == 'describe' ]]; then exit fi +TERMINAL_COMMAND="termite -e" + HIST_FILE="${XDG_CACHE_HOME:-$HOME/.cache}/${0##*/}-history.txt" DIRS=( @@ -129,7 +132,7 @@ desktop) # 3. We see a Path= line during search: set variable # 4. Finally, build command line command=$(awk -v pattern="${PATTERN}" -F= ' - BEGIN{a=0;exec=0; path=0} + BEGIN{a=0;exec=0;path=0} /^\[Desktop/{ if(a){ a=0 @@ -138,6 +141,12 @@ desktop) $0 ~ pattern{ a=1 } + /^Terminal=/{ + sub("^Terminal=", ""); + if ($0 == "true") { + terminal=1 + } + } /^Exec=/{ if(a && !exec){ sub("^Exec=", ""); @@ -153,7 +162,10 @@ desktop) END{ if(path){ - print "cd " path " &&" + printf "cd " path " &&" + } + if (terminal){ + printf "$TERMINAL_COMMAND " } print exec }' "${PARAMS[0]}") @@ -162,4 +174,5 @@ command) command="${PARAMS[0]}" ;; esac +echo "Executing command: \"$command\"" >> ~/.local/var/log/sway-launcher.log swaymsg -t command exec "$command" -- cgit v1.2.3 From 5d7f7182eb46f3d8d5f911ca41d8bbec35990393 Mon Sep 17 00:00:00 2001 From: Joe Fiorini Date: Tue, 22 Oct 2019 16:21:05 -0400 Subject: Better when it actually works... --- sway-launcher-desktop.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sway-launcher-desktop.sh b/sway-launcher-desktop.sh index 52fdf7a..68feb9f 100755 --- a/sway-launcher-desktop.sh +++ b/sway-launcher-desktop.sh @@ -131,7 +131,7 @@ desktop) # 3. We see an Exec= line during search: remove field codes and set variable # 3. We see a Path= line during search: set variable # 4. Finally, build command line - command=$(awk -v pattern="${PATTERN}" -F= ' + command=$(awk -v pattern="${PATTERN}" -v terminal_command="${TERMINAL_COMMAND}" -F= ' BEGIN{a=0;exec=0;path=0} /^\[Desktop/{ if(a){ @@ -165,7 +165,7 @@ desktop) printf "cd " path " &&" } if (terminal){ - printf "$TERMINAL_COMMAND " + printf terminal_command " " } print exec }' "${PARAMS[0]}") -- cgit v1.2.3 From 63bec1eaf0946952f5004e7140a7b9307f2ea2f3 Mon Sep 17 00:00:00 2001 From: Joe Fiorini Date: Wed, 23 Oct 2019 09:48:02 -0400 Subject: Remove debug logging --- 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 68feb9f..c459d10 100755 --- a/sway-launcher-desktop.sh +++ b/sway-launcher-desktop.sh @@ -174,5 +174,5 @@ command) command="${PARAMS[0]}" ;; esac -echo "Executing command: \"$command\"" >> ~/.local/var/log/sway-launcher.log + swaymsg -t command exec "$command" -- cgit v1.2.3 From e5f9c51dfd1c43c9f49b929071e63c96b6a0950a Mon Sep 17 00:00:00 2001 From: Joe Fiorini Date: Wed, 23 Oct 2019 09:53:13 -0400 Subject: Allow overriding terminal variable --- sway-launcher-desktop.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sway-launcher-desktop.sh b/sway-launcher-desktop.sh index c459d10..a631a47 100755 --- a/sway-launcher-desktop.sh +++ b/sway-launcher-desktop.sh @@ -20,7 +20,10 @@ if [[ "$1" == 'describe' ]]; then exit fi -TERMINAL_COMMAND="termite -e" +# Defaulting terminal to termite, but feel free to either change +# this or override with an environment variable in your sway config +# It would be good to move this to a config file eventually +set ${TERMINAL_COMMAND:="termite -e"} HIST_FILE="${XDG_CACHE_HOME:-$HOME/.cache}/${0##*/}-history.txt" -- cgit v1.2.3