savedra1 / clipse

Configurable TUI clipboard manager for Unix
MIT License
272 stars 10 forks source link

Improvement: Hitting Enter should copy what u selected then close the window #17

Closed skela closed 5 months ago

skela commented 5 months ago

I think its a sensible and expected user experience, but if not, could we have a setting or config for it to make it so?

Love this program, already started using it in Hyprland. So happy to not do this via rofi anymore.

savedra1 commented 5 months ago

Thanks for raising this @skela

You'll be pleased to know that this functionality already exists for all Linux builds. What command did you bind for opening the TUI? If you bind clipse $PPID that should achieve the 'close on selection' effect you're looking for.

For anyone using MacOs, sadly this does not kill the terminal window. Have been looking into a fix but AFAIK it requires a lot of complex system adjustments by the user.

Let me know if this helps!

Cheers

skela commented 5 months ago

I'm using linux, endevour OS to be specific (not that that should matter here). I've got this in my hyprland config: bind = CONTROL ALT, C, exec, kitty --class floating -e fish -c 'clipse $PPID'

And this in my waybar config:

"custom/clipboard": {
        "format": "",
        "interval": "once",
        "return-type": "json",
        "on-click": "kitty --class floating -e fish  -c 'clipse $PPID'",
        "on-click-right": "kitty --class floating -e fish  -c 'clipse $PPID'",
        "on-click-middle": "clipse -clear",
        // "on-click": "/home/skela/.dotfiles/scripts/launcher-clipboard.sh left",
        // "on-click-right": "/home/skela/.dotfiles/scripts/launcher-clipboard.sh right",
        // "on-click-middle": "cliphist wipe",
        "exec": "printf '{\"tooltip\":\"%s\"}' $(cliphist list | wc -l)",
        // "exec-if": "[ -x \"$(command -v cliphist)\" ] && [ $(cliphist list | wc -l) -gt 0 ]",
        "signal": 9
    }
skela commented 5 months ago

Ok, i might have figured out why it wasnt working.

I was passing in fish as my environment, having also tried /usr/bin/fish, with it seemingly working, so thought that was all good.

But after replacing fish with bash, it closes the window when I hit enter.

So might be an issue specific to the fish shell iand clipse.

savedra1 commented 5 months ago

Love the idea of adding this to the waybar! Might copy you there.

As for the not closing.. you're bind seems perfect already so must be something else going wrong. Do you get a status message in the TUI after selection? I'd recommend checking the following:

hopefully this gets you somewhere

skela commented 5 months ago

both echo $PPID and echo $PID return nothing. image

savedra1 commented 5 months ago

Ok, i might have figured out why it wasn't working.

I was passing in fish as my environment, having also tried /usr/bin/fish, with it seemingly working, so thought that was all good.

But after replacing fish with bash, it closes the window when I hit enter.

So might be an issue specific to the fish shell and clipse.

Ah! that's super good to know, thank you for letting me know. Will keep an eye out for that in the future.

skela commented 5 months ago

Found this variable in fish that lets me kill it:

image

skela commented 5 months ago

So yeah, this bind works for me in fish: bind = CONTROL ALT, C, exec, kitty --class floating -e fish -c 'clipse $fish_pid'

Thanks a lot!

savedra1 commented 5 months ago

both echo $PPID and echo $PID return nothing. image

So there we have our issue - if fish does not return a $PPID, the command was just running clipse in the binding, opening the TUI in persist mode.

Looks like this might need a different var instead: https://github.com/fish-shell/fish-shell/issues/6203

savedra1 commented 5 months ago

So yeah, this bind works for me in fish: bind = CONTROL ALT, C, exec, kitty --class floating -e fish -c 'clipse $fish_pid'

Thanks a lot!

Excellent! glad you found a fix :)