diff options
| author | Jack Jamison <jackqjamison@gmail.com> | 2026-05-15 22:36:21 -0400 |
|---|---|---|
| committer | Jack Jamison <jackqjamison@gmail.com> | 2026-05-15 22:36:21 -0400 |
| commit | 1c58ccb7855719483490abe1982afa12b0488f24 (patch) | |
| tree | d6d6f95477c743c1e2e8f4a64095d50cb491338c /scripts/util/open-emacs-project | |
| parent | fbe17d51cc2d52261721a46ee54d5dc8f32db3eb (diff) | |
refactor and battery notifier
Diffstat (limited to 'scripts/util/open-emacs-project')
| -rwxr-xr-x | scripts/util/open-emacs-project | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/scripts/util/open-emacs-project b/scripts/util/open-emacs-project new file mode 100755 index 0000000..48360b1 --- /dev/null +++ b/scripts/util/open-emacs-project @@ -0,0 +1,28 @@ +#!/bin/bash + +find_dirs() { + echo $(emacsclient -e "(proj--get-paths)" | sed -ze 's/(\(.*\))/\1/') | xargs -n1 +} + +emacs_attached() { + [ "$(emacsclient -e '(- (length (frame-list)) 1)')" = 0 ] && return 1 || return 0 +} + +switch_to() { + if emacs_attached; then + emacsclient -e "(proj-set \"$1\")" + else + emacsclient -ce "(proj-set \"$1\")" + fi +} + +# get selected +selected=$(find_dirs | swenu -coil 15) +[ -z "$selected" ] && exit 1; +selected="${selected/\~/$HOME}" + +# set emacs project +switch_to "$selected" + +# 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 |
