summary refs log tree commit diff
path: root/bin/sway-run
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2020-01-26 17:16:07 +0100
committerRobert Günzler <r@gnzler.io>2020-01-26 18:00:59 +0100
commitf5d56602df70950de6b7d40966b00c9939c81763 (patch)
treeb50ffeb5496fe3525cc1bab2629389ced95435b7 /bin/sway-run
Intial commit of v2
See https://drewdevault.com/2019/12/30/dotfiles.html
Diffstat (limited to 'bin/sway-run')
-rwxr-xr-xbin/sway-run47
1 files changed, 47 insertions, 0 deletions
diff --git a/bin/sway-run b/bin/sway-run
new file mode 100755
index 0000000..be60ae4
--- /dev/null
+++ b/bin/sway-run
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+set -ex
+
+if [ "$XDG_RUNTIME_DIR" == "" ]; then
+    export XDG_RUNTIME_DIR=/tmp
+fi
+
+LOCKED=0
+SWAY_BIN=/usr/bin/sway
+SWAY_ARGS=
+
+while getopts ":dcDL" o; do
+    case $o in
+        d) SWAY_ARGS="$SWAY_ARGS --debug" ;;
+        D)
+            export XDG_RUNTIME_DIR=/tmp/sway-run-debug
+            [ ! -d "$XDG_RUNTIME_DIR" ] && mkdir -p "$XDG_RUNTIME_DIR"
+            ;;
+        c) SWAY_ARGS="$SWAY_ARGS --config $XDG_CONFIG_HOME/sway/simple.conf" ;;
+        L) LOCKED=1 ;;
+        *) echo "unknown flag: $o" 1>&2
+    esac
+done
+shift $((OPTIND-1))
+
+if [ $LOCKED -eq 1 ]; then
+    sh -c 'sleep 1; $HOME/.dotfiles/bin/lock' & disown
+    exec "$0" $@
+fi
+
+case $1 in
+    locked)     shift; exec $0 -L ;;
+    git)        shift; 
+        SWAY_SRC="$HOME/devel/upstream/github.com/swaywm/sway"
+        SWAY_BIN="$SWAY_SRC/build/sway/sway";
+        export PATH="$SWAY_SRC/build/sway:$PATH"
+        export LD_LIBRARY_PATH="$SWAY_SRC/build/subprojects/wlroots:$LD_LIBRARY_PATH"
+        ;;
+    system)     shift; exec $0 ;;
+    clean)      shift; exec $0 -c ;;
+esac
+
+TS="$(date -u --rfc-3339=seconds | tr ' ' 'T')"
+LOG=/var/log/sway/"$TS".log
+
+exec $SWAY_BIN -Ddamage=rerender $SWAY_ARGS $@ 1>&2 2>"$LOG"