~kris/dots

srice

ref: e98f3b030dc24445bd55c68d95d2d81933fd68b3 srice/.config/fish/conf.d/detach-gui.fish -rw-r--r-- 2.0 KiB
e98f3b03 — Kris Yotam chore: sync local state after restore (push updates, no pull) a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Auto-detach GUI apps launched from the shell.
# Typing `brave`, `zathura`, etc. never ties the process to the terminal.
#
# Escape hatches:
#   command brave          # real binary, attached
#   DETACH_OFF=1 brave     # same, for wrapped names
#   detach <cmd>           # explicit (also works for anything not listed)

if not status is-interactive
    exit
end

# Apps that open a window and have no reason to own a terminal.
# Keep this list GUI-only. Never put TUIs (nvim, btop, nnn, dmenu, rofi, fzf).
set -g DETACH_GUI_APPS \
    brave brave-browser chromium firefox librewolf vivaldi ungoogled-chromium helium \
    nyxt qutebrowser surf torbrowser-launcher \
    zathura nsxiv imv sxiv feh mpv vlc \
    gimp inkscape libreoffice soffice \
    thunar pcmanfm nautilus dolphin nemo \
    pavucontrol pavucontrol-qt blueman-manager arandr lxappearance qt5ct qt6ct \
    nm-connection-editor gparted \
    obs qbittorrent transmission-gtk filezilla \
    keepassxc bitwarden \
    cursor zed \
    steam discord signal-desktop telegram-desktop \
    anki gthumb eog \
    wireshark wireshark-qt \
    virtualbox VirtualBox \
    hakuneko-desktop \
    mousepad xed leafpad \
    galculator \
    mirror-browser

function __detach_gui_wrap --description 'Define a detached wrapper for a GUI binary'
    set -l name $argv[1]
    # Only wrap if a real binary exists (avoid wrapping missing tools)
    if not command -q $name
        return
    end
    # Do not clobber an existing hand-written function (e.g. special wrappers)
    if functions -q $name
        return
    end

    # Dynamic function: name becomes a detached launcher; `command name` is the escape hatch
    eval "
    function $name --wraps=$name --description '$name (detached from terminal)'
        if set -q DETACH_OFF
            command $name \$argv
        else
            detach command $name \$argv
        end
    end
    "
end

for __detach_app in $DETACH_GUI_APPS
    __detach_gui_wrap $__detach_app
end
set -e __detach_app