pystardust / ytfzf

A posix script to find and watch youtube videos from the terminal. (Without API)
GNU General Public License v3.0
3.78k stars 343 forks source link

[Suggestion] Swallow terminal when playing a video #275

Closed Kabouik closed 2 years ago

Kabouik commented 3 years ago

I just found out about ytfzf and I really like it, thanks to you and all contributors for this awesome script.

What would you think about an option to automatically hide the terminal during play back and restoring it when the video ends? This is something I submitted for termv and I think it works pretty well with minimal dependencies. I have looked at the code for ytfzf and it's a bit complex for my limited coding skills, but since it's POSIX it should be relatively easy to implement in a similar way.

qoheniac commented 3 years ago

xdo would be another Xorg-only dependency in addition to Überzug for the thumbnails.

tamis-laan commented 3 years ago

@Kabouik

Might I suggest not swallowing the terminal but forking the mpv player. This way you can do multiple searches and have multiple videos open. https://github.com/pystardust/ytfzf/issues/174

You can also try to modify that example and introduce swallowing.

pystardust commented 3 years ago

forking the mpv player.

This has been implemented here #291 You could press alt-enter to open the video as a forked process and continue the menu selection. ( Update to the development branch using ytfzf --update-unstable )

tamis-laan commented 3 years ago

@pystardust alt-enter is the most commonly used shortcut for opening a new terminal in tilling window managers, might I suggest using ctrl-enter?

pystardust commented 3 years ago

unfortunately ctrl-enter isn't in the list of hotkeys supported by fzf. The list of hot keys available from fzf (man fzf)

   AVAILABLE KEYS: (SYNONYMS)
       ctrl-[a-z]
       ctrl-space
       ctrl-\
       ctrl-]
       ctrl-^      (ctrl-6)
       ctrl-/      (ctrl-_)
       ctrl-alt-[a-z]
       alt-[*]     (Any case-sensitive single character is allowed)
       f[1-12]
       enter       (return ctrl-m)
       space
       bspace      (bs)
       alt-up
       alt-down
       alt-left
       alt-right
       alt-enter
       alt-space
       alt-bspace  (alt-bs)
       tab
       btab        (shift-tab)
       esc
       del
       up
       down
       left
       right
       home
       end
       insert
       pgup        (page-up)
       pgdn        (page-down)
       shift-up
       shift-down
       shift-left
       shift-right
       alt-shift-up
       alt-shift-down
       alt-shift-left
       alt-shift-right
       left-click
       right-click
       double-click
       or any single character

Yes alt-enter seems like a poor default choice. You could edit the shortcuts in the config https://github.com/pystardust/ytfzf/blob/f9b519f04bfcaed6e5b3392e713cd775aa56b146/docs/conf.sh#L226 Do suggest a better default. I will modify it.

pystardust commented 3 years ago

There is also an option --detach that does the same (without any shortcut). You could add detach_player=1 in your config to make it permanent

tamis-laan commented 3 years ago

shift-enter ?

More shortcuts should be added, this is way to sparse.

pystardust commented 3 years ago

nope doesn't work

unsupported key: shift-enter

The key must be present in the above list according to fzf's manual

Kabouik commented 3 years ago

Great news! Would be nice to have a swallow option too though, detach is not the same thing, but that would indeed add a dependency either for xdo or devour.

I agree that alt-enter is not ideal (one of my devices has no Super key so I have to use Alt as my i3 modifier, and I think many people do that too). I'm still happy with the --detach option anyway, but it would be great if fzf could support ctrl-enter or shift-enter in the future. Shift-right would make me happy too (just Right won't do since we need it to move the cursor in the search field) but I don't think it's very intuitive if you don't know it in advance.

On 2021-06-18 19:13 Harshith @.***> wrote:

nope doesn't work

unsupported key: shift-enter

The key must be present in the above list according to fzf's manual

--
You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/pystardust/ytfzf/issues/275#issuecomment-864173626

Euro20179 commented 3 years ago

I thought ctrl-enter was valid

plasmoduck commented 3 years ago

I got swallowing working. Make a script in '~/bin/swallow.sh' containing

#!/bin/sh
xdotool windowunmap "$WINDOWID"
$@
xdotool windowmap "$WINDOWID"

Then edit ~/.config/ytfzf/conf.sh and put:

#the player to use when choosing a video format with $YTFZF_PREF
#(YTFZF_PLAYER_FORMAT)
video_player_format="/home/$USER/bin/swallow mpv --ytdl-format="

This will swallow then unswallow the terminal.