hyprland-community / pyprland

Scratchpads & many goodies for Hyprland [maintainer=@fdev31]
MIT License
390 stars 17 forks source link

[FEAT] How to send commands to the created scratchpads? #57

Closed kohane27 closed 8 months ago

kohane27 commented 8 months ago

Hello! Hope you're doing well. Thank you for creating pyprland!

Description

I'm using scratchpads:

[scratchpads.music]
command = "kitty --class kitty_music"
animation = "fromRight"
class = "kitty_music"
size = "20% 60%"
margin = 10

After the scratchpads, I'd like to run the command ncmpcpp such that I'm dropped straight to my music player.

What I've Tried

The following command doesn't work:

command = "kitty --class kitty_music zsh -c 'ncmpcpp'"

Any help is much appreciated. Thank you!

kohane27 commented 8 months ago

kitty --class kitty_music zsh -i -c 'ncmpcpp' works. Silly me. Thank you again!

kohane27 commented 8 months ago

I tried to run the command tmuxp load --yes scratchpad for the scratchpad. tmuxp is a session manager for tmux. Basically, I want the scratchpad (which is just a kitty terminal) to be inside a tmux session called scratchpad.

The following doesn't work however:

[scratchpads.markdown]
command = "kitty --class kitty_Super_N zsh -i -c 'tmuxp load --yes scratchpad'"
class = "kitty_Super_N"

I have the following error:

✖ pypr
⚠ Failed spawning markdown as proc 534354
"kitty --class kitty_Super_N zsh -i -c 'tmuxp load --yes scratchpad'": The command terminated sucessfully, is it already running?
Failed to show markdown, aborting.

Any idea is again, much appreciated. Thank you!

fdev31 commented 8 months ago

Thank you! This is caused becuse the command exits immediately as indicated. You can test your command by typing it in a terminal:

kitty --class kitty_Super_N zsh -i -c 'tmuxp load --yes scratchpad'

this doesn't work, the window is immediately closed.

while if you use kitty --class kitty_Super_N tmuxp load --yes scratchpad I believe it's working as expected... (I don't have a tmuxp config to test)

For such, I believe the "Discussions" area is better suited... closing asusming that was just the command itself! Please re-open if you see any problem in pyprland.

kohane27 commented 8 months ago

I figured it out. If I want to launch kitty to be inside a tmux session called scratchpad, the command is kitty --execute tmux attach-session -t scratchpad. Thank you again and apologies for creating it as an issue instead of Discussions area.