summaryrefslogtreecommitdiff
path: root/scripts/open-emacs
blob: 92272df64132eb7af35819c35cc1a5f7e1455445 (plain)
1
2
3
4
5
6
7
8
9
10
11
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) + " " + .name?' | grep -e "[0-9]* ." | grep Emacs | awk '{print $1}')"] focus
else
    emacsclient -c
fi