-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrofi-twitch
executable file
·41 lines (34 loc) · 1.13 KB
/
rofi-twitch
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
#!/bin/bash
# Twitch launcher for rofi
# Supports chat popout via browser
[ -z "$XDG_CONFIG_HOME" ] &&
XDG_CONFIG_HOME="$HOME/.config"
mkdir -p "$XDG_CONFIG_HOME"
source "$XDG_CONFIG_HOME/rofi-twitch/settings"
twitch=https://www.twitch.tv
[ -z $user ] && echo "You should set your username in \
~/.config/rofi-twitch/settings."
# Choose quality, best by default
case "${2:-b}" in
b*) quality=best;;
l*) quality=480p;;
m*) quality=720p60;;
*)
echo '%s: unkown quality option: %s. Choose one of\n
[l]ow\n
[m]edium\n
[b]est)'"$0" "$2" >&2
exit 1
;;
esac
[ -z "$channel" ] && channel=$(twitchnotifier -c $user -n | perl \
-MHTML::Entities -pe 'encode_entities($_);' | rofi \
-theme-str '#window { width: 1000; }' -dmenu -markup-rows -i \
-p "" | grep -Po '^.+?(?=\:)')
[ -z "$channel" ] && exit
[[ -z $player ]] && player=mpv
# make verbose option
streamlink -p $player $twitch/$channel --default-stream $quality 2>&1 >/dev/null &
[[ -z $browser ]] && : || { channel="$(echo $channel | tr -d ' ')" && $browser \
--new-window "$twitch/popout/$channel/chat"; }
exit