dotfiles/scripts/emacslof
2022-09-04 10:52:38 -05:00

38 lines
914 B
Bash
Executable file

#!/bin/sh
# Check to see if an emacsclient is running
if [ $(pgrep -c emacsclient) -gt 0 ]; then
echo hi
if [ "$XDG_SESSION_TYPE" == "x11" ]; then
#X11
emacsrg=$(wmctrl -lx | rg emacs.Emacs | rg -v org-agenda | awk '{print $1}')
echo $emacsrg
if [ -z $emacsrg ]; then
exec emacsclient -c &
exit
else
exec wmctrl -ia $emacsrg
exit
fi
else
if [ "$KDE_FULL_SESSION" == "true" ]; then
exec /home/chris/bin/ww -fa Emacs -c emacsclient
exit
else
# WAYLAND
emacsrg=$(wlrctl window list | rg -v 'Emacs:\sorg-agenda' | rg 'Emacs:')
emacswin=$(echo $emacsrg | sed 's/.*\: //')
echo $emacswin
exec wlrctl toplevel focus title:"$emacswin"
exit
fi
fi
else
exec emacsclient -c &
fi