Its been a long time with me searching for this throughout the internet
but cant find any better solution
lemme get to the point
previously when i was in window i use to play movies/series using KM-PLAYER
in this player there used to be one hotkeys ESC which pauses the playing media automatically and minimizes it to the taskbar automatically just with one button
i tried many players but none have that functionality !!
anyone here can help me in that?
to make that feature work on VLC player or HARUNA MEDIA PLAYER
Provide some information on your environment first? Are you using Xorg or Wayland? Without these info, it’s impossible to give a precise solution.
For this behavior, you are going to have to define a custom keybinding for your desktop environment/window manager.
Assuming that you’re on Xorg, you can use xdotool to minimize your windows. To pause VLC, you need to install playerctl, which allows you to control VLC from inside a shell script.
Once you have all the necessary tools, simply put them all in a shell script.
#!/bin/sh
# This script minimizes the currently active window and pauses VLC
# Replace $(xdotool getactivewindow) with something else if you want more specific funtionality
# E.g: you can also use xdotool to search the window's WM_CLASS attribute
xdotool minimize $(xdotool getactivewindow)
playerctl --player=vlc pause
Make this shell script executable with chmod. After that, add a keybinding in your desktop environment/window manager to launch this script every time the defined key is pressed.
playerctl is in Arch’s extra repo. You can install it with pacman:
If you want more accurate behavior, you can modify the script like this:
#!/bin/sh
winclass=$(xdotool getactivewindow getwindowclassname)
if [ "$winclass" = "Vlc" ]
then
# only takes effect if the current active window is vlc
xdotool minimize $(xdotool getactivewindow)
playerctl --player=vlc pause
fi
This will trigger the minimize + pause behavior only if your current active window is vlc.
Install smplayer, then go to menu / options / preferences / general, then check the box “Pause when minimized”. Then when you minimize the window it pauses whatever is playing!
You can also menu / options “Show icon in system tray” so even if you “close” the window it stays minimized in tray
Step 2: Inside the terminal, type cd and press enter. This will change to your home directory.
Step 3: In the same terminal, run this command touch pause-and-minimize-vlc.sh. This will create an empty text file in your home directory.
Step 4: Open pause-and-minimize-vlc.sh with a text editor (kate, mousepad, or whichever text editor you prefer).
Step 5: Paste the following into pause-and-minimize-vlc.sh
#!/bin/sh
winclass=$(xdotool getactivewindow getwindowclassname)
if [ "$winclass" = "Vlc" ]
then
# only takes effect if the current active window is vlc
xdotool minimize $(xdotool getactivewindow)
playerctl --player=vlc pause
fi
Step 6: Save the file.
Step 7: Go back to your terminal and type
chmod +x ~/pause-and-minimize-vlc.sh
This will make the shell script executable.
Step 8: Add a keyboard shortcut to run this shell script every time the shortcut is pressed. How you do this depends on the desktop environment you’re using. If you are using XFCE or KDE, there are probably graphical tools to do this. I don’t recommend binding the ESC key for this function, since the ESC key has its own uses. Choose something like Win + M or something.
If you are certain that VLC does not support this feature (by looking at their documentation), then you have no choice but to implement it yourself by writing a shell script.