blob: 8694272a3eb0e5579d3459ddd8835c7e4f03f269 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#!/bin/fish
set parts (string split / $argv[1])
set protocol $parts[1]
set action $parts[3]
set secret $parts[4]
function die
notify-send -u critical -t 5000 'Jellynative Error' $argv[1]
exit 1
end
function player
notify-send -u low -t 1000 Jellynative 'Player ist launching...'
if not mpv --http-header-fields=(echo -s 'Cookie: session=' $argv[1]) $argv[3..] $argv[2]
die 'Player exited with error code'
end
end
if not test $protocol = "jellynative:"
die "Wrong protocol"
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
head -c 16 /dev/urandom | xxd -p >$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 $parts[5] (string join / $parts[6..])
case player-fullscreen
player $parts[5] (string join / $parts[6..]) --fullscreen
case '*'
die 'Unknown action'
end
|