Picture-in-picture Global Keyboard Shortcut

Description
I missed the functionality to globally toggle picture-in-picture directly from the keyboard.
So I created an applescript to toggle opening and closing.
Currently supported Applications: Safari, IINA
Shortcut: cmd ⌘ + ctrl Λ„ + P

:link: Download Preset
:link: Applescript

Update 06.10.2024 - updated to work with macOS Sonoma

Screenshots
Make sure "Developer > Allow JavaScript from Apple Events" is enabled in Safari

just an fyi – ⌘ + ` is actually the way to switch Safari window, so it wouldnt be good if someone was trying to switch window and accidentally triggers picture in picture

Oh, good you mention ⌘ + `. Yes, it's the default to switch between windows of the same application Move focus to next window. Changed it to ⌘ + § which it should've been in the first place. Karabiner Elements seem to have a bug here. (I use an UK Layout)

1 Like

Here's an updated version of a similar gist that works on macOS Ventura.

Does this script work on macOS Sonoma? I've tried using it but got no luck

Dunno, I'm still on Ventura and I'm not planning to upgrade to Sonoma.

Just updated the preset to work with macOS Sonoma