summaryrefslogtreecommitdiff
path: root/scripts/open-emacs
blob: 2f63efdd9e8df2695237f7762732ff16f608e038 (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) + " " + .app_id?' | grep emacs | awk '{print $1}')"] focus
else
    emacsclient -c
fi