summaryrefslogtreecommitdiff
path: root/scripts/util/open-emacs
diff options
context:
space:
mode:
authorJack Jamison <jackqjamison@gmail.com>2026-05-15 22:36:21 -0400
committerJack Jamison <jackqjamison@gmail.com>2026-05-15 22:36:21 -0400
commit1c58ccb7855719483490abe1982afa12b0488f24 (patch)
treed6d6f95477c743c1e2e8f4a64095d50cb491338c /scripts/util/open-emacs
parentfbe17d51cc2d52261721a46ee54d5dc8f32db3eb (diff)
refactor and battery notifier
Diffstat (limited to 'scripts/util/open-emacs')
-rwxr-xr-xscripts/util/open-emacs12
1 files changed, 12 insertions, 0 deletions
diff --git a/scripts/util/open-emacs b/scripts/util/open-emacs
new file mode 100755
index 0000000..2f63efd
--- /dev/null
+++ b/scripts/util/open-emacs
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+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) + " " + .app_id?' | grep emacs | awk '{print $1}')"] focus
+else
+ emacsclient -c
+fi