From 37251c97c6b6bb01c97682901141548c1985ba4b Mon Sep 17 00:00:00 2001 From: Sebastian Schulze Date: Mon, 14 Aug 2023 15:38:26 +0200 Subject: [PATCH] [bin] Simplify `worklogger` by just creating a new frame on demand --- bin/executable_worklogger | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/bin/executable_worklogger b/bin/executable_worklogger index 474266a..ceeff17 100644 --- a/bin/executable_worklogger +++ b/bin/executable_worklogger @@ -4,28 +4,17 @@ # # This supersedes [Worklogger](https://github.com/bascht/worklogger) # by appending to [OrgMode](https://github.com/bastibe/org-journal) -# via a scratchpad Window in the background +# by creating a new frame of the existing emacs server called "workmacs" -WORKLOG_CRITERIA='select(.app_id=="Worklog" and .name == "Worklog")' + +WORKLOG_CRITERIA='select(.name == "Worklog")' get_worklog_window () { swaymsg -t get_tree | jq -e -r "recurse(.nodes[],.floating_nodes[]) | ${WORKLOG_CRITERIA}.id" } -get_scratchpad_worklog() { - swaymsg -t get_tree | jq -r "recurse(.nodes[]?)|recurse(.floating_nodes[]?)|select(.name == \"__i3_scratch\").floating_nodes[] | ${WORKLOG_CRITERIA}${1}" -} -if [ -z "$(get_worklog_window)" ]; then - echo "No worklog, need to start instance" - emacs --name Worklog --eval="(bascht/worklog)" & - exit 0 -else - get_scratchpad_worklog ".id" - if [ -n "$(get_scratchpad_worklog)" ]; then - echo "Worklog is in scratchpad, bringing it back" - ID=$(get_scratchpad_worklog ".id") - swaymsg "[con_id=${ID}]" scratchpad show - else - echo "Worklog is already visible" - fi; +if [ -n "$(get_worklog_window)" ]; then + notify-send "Worklog window is already visible" fi + +emacsclient -s workmacs --create-frame --eval "(bascht/worklog)" &