summary refs log tree commit diff
path: root/bin/swx
diff options
context:
space:
mode:
Diffstat (limited to 'bin/swx')
-rwxr-xr-xbin/swx19
1 files changed, 12 insertions, 7 deletions
diff --git a/bin/swx b/bin/swx
index 5b25d35..3e894f7 100755
--- a/bin/swx
+++ b/bin/swx
@@ -27,7 +27,8 @@ floating=
 autotile=
 into_scratchpad=
 mark=
-while getopts b:w:o:g:I:r:stfF:aSM:h name; do
+term_title=
+while getopts b:w:o:g:I:r:stfF:aSM:T:h name; do
 	case "$name" in
 	b)	# border
 		border="${OPTARG}" ;;
@@ -57,7 +58,10 @@ while getopts b:w:o:g:I:r:stfF:aSM:h name; do
 		into_scratchpad=1 ;;
 	M)	# mark
 		mark="${OPTARG}" ;;
-	h|?)	printf "usage: %s [-bwogIrsfoSM] COMMAND\n" "$(basename "$0")"
+	T)	# set terminal title
+		term_title="${OPTARG}" ;;
+
+	h|?)	printf "usage: %s [-bwogIrsfoSMT] COMMAND\n" "$(basename "$0")"
 		printf "\n"
 		printf "  -t \t\trun COMMAND in \$TERM\n"
 		printf "  -b BORDER \tset border property\n"
@@ -71,6 +75,7 @@ while getopts b:w:o:g:I:r:stfF:aSM:h name; do
 		printf "  -a \t\tauto-tiling; always open COMMAND on the shorter edge of\n\t\tthe current container\n"
 		printf "  -S \t\tmove the container into the scratchpad\n"
 		printf "  -M MARK\t\set MARK on the container\n"
+		printf "  -T TERM_TITLE\t\set a title on the terminal (only makes sense with -t)\n"
 		printf "\n"
 		printf "See sway(5) for possible options for BORDER, WORKSPACE, OUTPUT and GEOMETRY.\n"
 		exit 2 ;;
@@ -86,17 +91,17 @@ if [ -z "${arg0}" ]; then
 fi
 shift
 
+command="${arg0} ${*}"
+
 # needs to be termified?
 # spawn a $TERM instance and exec that
 if [ -n "${termify}" ]; then
 	case ${TERM} in
-	alacritty)	term_args="--title=${arg0} --class=${arg0} --command" ;;
-	foot) 		term_args="--title=${arg0} --app-id=${arg0} --" ;;
+	alacritty)	term_args="--title=${term_title:-${arg0}} --class=${term_title:-${arg0}} --command" ;;
+	foot) 		term_args="--title=${term_title:-${arg0}} --app-id=${term_title:-${arg0}} --" ;;
 	*) 		term_args="" ;;
 	esac
-	command="${TERM} ${term_args} ${arg0} ${*}"
-else
-	command="${arg0} ${*}"
+	command="${TERM} ${term_args} ${command}"
 fi
 
 # needs to be rotated