#!/bin/fish set parts (string split / $argv[1]) set protocol $parts[1] set action $parts[3] set secret $parts[4] 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' end notify-send -u low -t 1000 Jellynative 'Player ist launching...' if not $playercommand $argv[2..] $argv[1] 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 (string join / $parts[5..]) case player-fullscreen player (string join / $parts[5..]) --fullscreen case '*' die 'Unknown action' end