diff options
Diffstat (limited to 'web')
-rwxr-xr-x | web/native-protocol/jellynative | 41 | ||||
-rw-r--r-- | web/script/transition.ts | 1 |
2 files changed, 32 insertions, 10 deletions
diff --git a/web/native-protocol/jellynative b/web/native-protocol/jellynative index 1653e3f..e1b310c 100755 --- a/web/native-protocol/jellynative +++ b/web/native-protocol/jellynative @@ -2,33 +2,54 @@ set parts (string split / $argv[1]) set protocol $parts[1] set action $parts[3] -set arg (string join / $parts[4..]) +set secret $parts[4] -function die - notify-send -u critical 'Jellynative Error' $argv[1] - exit 1 -end if not test $protocol = "jellynative:" die "Wrong protocol" end + +function die + notify-send -u critical -t 5000 'Jellynative Error' $argv[1] + exit 1 +end + function player if which mpv &>/dev/null set playercommand mpv else if which vlc &>/dev/null set playercommand vlc else - die "No Media Player detected" + die 'No Media Player detected' end notify-send -u low -t 1000 Jellynative 'Player ist launching...' if not $playercommand $argv[2..] $argv[1] - die "Player exited with error code" + die 'Player exited with error code' end end + +set config_dir $XDG_CONFIG_HOME +if test -z $config + set config_dir ~/.config +end +set config $config_dir/jellynative_secret +if not test -e $config + random 0 4000000000 >$config +end +set secret (cat $config) + +if test $action != show-secret + if test $secret != $parts[4] + die 'Incorrect secret' + end +end + switch $action + case show-secret + notify-send -u low Jellynative "Secret: $secret" case player - player $arg + player (string join / $parts[5..]) case player-fullscreen - player $arg --fullscreen + player (string join / $parts[5..]) --fullscreen case '*' - die "Unknown action" + die 'Unknown action' end diff --git a/web/script/transition.ts b/web/script/transition.ts index a15a6b0..03338ca 100644 --- a/web/script/transition.ts +++ b/web/script/transition.ts @@ -23,6 +23,7 @@ globalThis.addEventListener("navigationrequiresreload", () => { function patch_page() { document.querySelectorAll("a").forEach(el => { + if (!el.href.startsWith("http")) return el.addEventListener("click", async ev => { ev.preventDefault() await transition_to(el.href) |