I used to be able to get Picture In Picture with Chrome by maximizing the video, Alt+F3+M+F to exit fullscreen but stay in Chrome’s “fullscreen mode” with the addressbar and window frame hidden. I would then hit Alt+F3+M+A to make the window stay on top. Finally I would use Alt+RightClick to resize the window to be smaller, and Alt+LeftClick to move the window into the bottom right of the screen. This worked for the most part, but was cumbersome to setup.
Unfortunately, I cannot do the same procedure for Firefox, as when we use Alt+F3+M+F to exit fullscreen, Firefox does not say in the “fullscreen mode” and the addressbar reappears.
If you haven’t already made a userChrome.css file, then navigate to ~/.mozilla/firefox/abcde124.default/ or whatever your profile’s folder name is. Then create the .../abcde124.default/chrome/userChrome.css directory and file. Open up userChrome.css then add the following:
Next up lets create a KWin Script that will resize the firefox window to 565 x 318 when snapped to the bottom right corner of the screen.
Navigate to ~/.local/share/ then create any missing folders in the path ~/.local/share/kwin/scripts/FirefoxPictureInPicture/contents/code/. Then make 2 new files FirefoxPictureInPicture/metadata.desktop and FirefoxPictureInPicture/contents/code/main.js.
In metadata.desktop put the following:
Next in contents/code/main.js put:
Open System Settings > Window Management > KWin Scripts.
To reload the script, uncheck to disable our new script, click Apply, then enable our script, and click Apply.
Lets focus on the variables at the top.
In Kubuntu, which uses the Breeze Gtk3 theme, you’ll notice that the windows don’t have any border/outline around the windows. So leaving it at 0 should be fine. The window will resize to 565 x 318.
However, in Manjaro, the Gtk3 theme in Breath and has a 1px border around the window. This border means we need to resize the window to 567 x 320. So we need to set windowBorderWidth=1.
The scrollbarAreaWidth=20 adjusts how far away from the right side of the screen you wish the popup to appear. If you wish the popup to appear further from the bottom, it should be rather simple to modify the script to do so by using this variable as an example.