Skip to content

Commit 6116ab2

Browse files
committed
feat!: simplify popup_mode with auto-detection via env var
Drop the PID-file hack. The tmux script now passes ORG_SUPER_AGENDA_POPUP=1 via new-session -e so nvim sees it at startup. wipe() checks the env var lazily at call time, so popup mode works without any user config. hide_command defaults to 'tmux detach-client' which cleanly closes the display-popup when attach-session exits. BREAKING CHANGE: users on the old PID-file hide_command must update their tmux script and remove the manual popup_mode config block.
1 parent 3e394cc commit 6116ab2

3 files changed

Lines changed: 45 additions & 13 deletions

File tree

README.md

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,11 @@ return {
163163
-- Global fallback sort for groups that omit `sort`
164164
group_sort = { by='date_nearest', order='asc' },
165165

166-
-- Popup mode: run in a persistent tmux session for instant access
166+
-- Popup mode: auto-detected when launched via the tmux script (ORG_SUPER_AGENDA_POPUP=1).
167+
-- Override only if you use a different popup mechanism.
167168
popup_mode = {
168-
enabled = false,
169-
hide_command = nil, -- e.g., "tmux detach-client"
169+
enabled = vim.env.ORG_SUPER_AGENDA_POPUP == '1',
170+
hide_command = 'tmux detach-client',
170171
},
171172

172173
debug = false,
@@ -443,17 +444,43 @@ When you press `s` and wait, a colored menu appears showing all available states
443444

444445
## 🪟 Popup Mode (tmux integration)
445446

446-
Run OrgSuperAgenda in a dedicated tmux session for instant access. When enabled, pressing `q` hides the session instead of closing the buffer.
447+
Run OrgSuperAgenda in a dedicated tmux session for instant access. Pressing `q` hides the popup (nvim keeps running in the background) instead of closing the buffer.
448+
449+
**No config needed** — popup mode is auto-detected when launched via the script below.
450+
451+
**tmux script** (`~/.local/bin/tmux-org-agenda.sh` or anywhere on your `$PATH`):
452+
453+
```bash
454+
#!/usr/bin/env bash
455+
SESSION="_org_agenda"
456+
457+
if ! tmux has-session -t "=$SESSION" 2>/dev/null; then
458+
tmux new-session -d -s "$SESSION" -e "ORG_SUPER_AGENDA_POPUP=1" \
459+
"nvim +'autocmd User VeryLazy ++once OrgSuperAgenda fullscreen'"
460+
tmux set-option -t "$SESSION" status off
461+
fi
462+
463+
tmux display-popup -w 100% -h 99% -E \
464+
"tmux attach-session -t '=$SESSION'"
465+
```
466+
467+
**tmux binding**:
468+
469+
```tmux
470+
bind -n 'M-a' run-shell -b "$HOME/.local/bin/tmux-org-agenda.sh"
471+
```
472+
473+
That's it. The `ORG_SUPER_AGENDA_POPUP=1` env var tells the plugin it's running in a popup, so `q` runs `tmux detach-client` to hide the popup cleanly.
474+
475+
Override if you use a different mechanism:
447476

448477
```lua
449478
popup_mode = {
450-
enabled = true,
451-
hide_command = "tmux detach-client",
479+
enabled = true, -- or use your own detection logic
480+
hide_command = "my-hide-cmd", -- anything that dismisses your popup
452481
}
453482
```
454483

455-
You can bind a tmux key to toggle the popup session for quick agenda access.
456-
457484
---
458485

459486
## ⚠️ Safety & behavior details

lua/org-super-agenda/adapters/neovim/actions.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,8 +791,11 @@ function A.set_keymaps(buf, win, line_map, reopen)
791791

792792
-- close
793793
local function wipe()
794-
local popup = cfg.popup_mode
795-
if popup and popup.enabled and popup.hide_command then
794+
local popup = get_cfg().popup_mode
795+
-- Check enabled lazily at call time: explicit config OR env var set in the nvim session.
796+
-- The env var approach is the zero-config path for the tmux script.
797+
local enabled = popup and (popup.enabled or vim.env.ORG_SUPER_AGENDA_POPUP == '1')
798+
if enabled and popup and popup.hide_command then
796799
-- Popup mode: detach from tmux session to hide the popup
797800
vim.fn.system(popup.hide_command)
798801
else

lua/org-super-agenda/config.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,12 @@ M.defaults = {
174174
-- Global fallback sort for groups that don't specify their own `sort`
175175
group_sort = { by = 'date_nearest', order = 'asc' },
176176

177-
-- Popup mode: when enabled, 'q' detaches from tmux instead of closing the buffer
177+
-- Popup mode: when enabled, 'q' hides the popup instead of closing the buffer.
178+
-- Auto-detected when launched via the org-super-agenda tmux script (ORG_SUPER_AGENDA_POPUP=1).
179+
-- Override `hide_command` if you use a different popup mechanism.
178180
popup_mode = {
179-
enabled = false,
180-
hide_command = nil, -- e.g., "tmux detach-client"
181+
enabled = vim.env.ORG_SUPER_AGENDA_POPUP == '1',
182+
hide_command = 'tmux detach-client', -- closes the display-popup when attach-session exits
181183
},
182184

183185
debug = false,

0 commit comments

Comments
 (0)