diff options
author | metamuffin <metamuffin@disroot.org> | 2024-01-30 16:34:38 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-01-30 16:34:38 +0100 |
commit | ef88eba498d0362137bcc9203a4cf1a20b6dec9e (patch) | |
tree | bd1e6ce50d5f591b722ed12459a116a0b0aff883 /web/native-protocol/jellynative | |
parent | 81326d9178a04814c0c8ed669bdf2f19fc865fbe (diff) | |
download | jellything-ef88eba498d0362137bcc9203a4cf1a20b6dec9e.tar jellything-ef88eba498d0362137bcc9203a4cf1a20b6dec9e.tar.bz2 jellything-ef88eba498d0362137bcc9203a4cf1a20b6dec9e.tar.zst |
np: authentificate native
Diffstat (limited to 'web/native-protocol/jellynative')
-rwxr-xr-x | web/native-protocol/jellynative | 41 |
1 files changed, 31 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 |