summaryrefslogtreecommitdiff
path: root/scripts/open-emacs
diff options
context:
space:
mode:
authorJack Jamison <jackqjamison@gmail.com>2026-01-23 11:00:52 -0500
committerJack Jamison <jackqjamison@gmail.com>2026-01-23 11:00:52 -0500
commit6e8fbf36e07f9dd671880c4231131e0e38c2d384 (patch)
treeefb9f3cf29b7b31f915c7b29dd4785a8d893980e /scripts/open-emacs
parent1df6a929cb0f540b2b8caf8f127afc3ad6c2468c (diff)
bash and more proj stuff
Diffstat (limited to 'scripts/open-emacs')
-rwxr-xr-xscripts/open-emacs14
1 files changed, 14 insertions, 0 deletions
diff --git a/scripts/open-emacs b/scripts/open-emacs
new file mode 100755
index 0000000..15b0794
--- /dev/null
+++ b/scripts/open-emacs
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+emacsclient -e '(message "")' 2>&1 >/dev/null || emacs --daemon &
+
+emacs_attached() {
+ [ "$(emacsclient -e '(- (length (frame-list)) 1)')" = 0 ] && return 1 || return 0
+}
+
+if emacs_attached; then
+ # focus emacs
+ swaymsg [con_id="$(swaymsg -t get_tree | jq -r '.nodes[1].nodes[].nodes[] | .. | (.id|tostring) + " " + .name?' | grep -e "[0-9]* ." | grep Emacs | awk '{print $1}')"] focus
+else
+ emacsclient -c
+fi