aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoritz Meißelbach <arbelzapf@gmail.com>2019-10-23 17:13:11 +0200
committerGitHub <noreply@github.com>2019-10-23 17:13:11 +0200
commit18ff43af5474e60dd58205fe614c0253727011e4 (patch)
treedf3992a9be1d49d5d5d2014fd24c260aa657dea1
parent1cd15bb6ab8761f4e95885b30c1040e6ed2e45f8 (diff)
parente5f9c51dfd1c43c9f49b929071e63c96b6a0950a (diff)
downloadsway-launcher-desktop-18ff43af5474e60dd58205fe614c0253727011e4.tar.gz
sway-launcher-desktop-18ff43af5474e60dd58205fe614c0253727011e4.zip
Merge pull request #1 from joefiorini/patch-1
Add Terminal property support. Thank you very much @joefiorini!
-rwxr-xr-xsway-launcher-desktop.sh22
1 files changed, 19 insertions, 3 deletions
diff --git a/sway-launcher-desktop.sh b/sway-launcher-desktop.sh
index efcb8e2..a631a47 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,11 @@ if [[ "$1" == 'describe' ]]; then
exit
fi
+# 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"
DIRS=(
@@ -128,8 +134,8 @@ 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= '
- BEGIN{a=0;exec=0; path=0}
+ command=$(awk -v pattern="${PATTERN}" -v terminal_command="${TERMINAL_COMMAND}" -F= '
+ BEGIN{a=0;exec=0;path=0}
/^\[Desktop/{
if(a){
a=0
@@ -138,6 +144,12 @@ desktop)
$0 ~ pattern{
a=1
}
+ /^Terminal=/{
+ sub("^Terminal=", "");
+ if ($0 == "true") {
+ terminal=1
+ }
+ }
/^Exec=/{
if(a && !exec){
sub("^Exec=", "");
@@ -153,7 +165,10 @@ desktop)
END{
if(path){
- print "cd " path " &&"
+ printf "cd " path " &&"
+ }
+ if (terminal){
+ printf terminal_command " "
}
print exec
}' "${PARAMS[0]}")
@@ -162,4 +177,5 @@ command)
command="${PARAMS[0]}"
;;
esac
+
swaymsg -t command exec "$command"