Hund

How to launch Twitch streams via Rofi using Twitchy

September 23, 2018

I wrote this little script for Rofi that lets me launch Twitch streams using Twitchy. It requires Rofi, Twitchy and Streamlink to work.

My script for Rofi that lets me launch Twitch streams using Twitchy

#!/bin/bash

handle_selection() {
	if [[ $1 ]]; then
		name=$(echo $1 | awk {'print $1'})
		notify-send "Twitchy" "Launching the livestream with $name"
		streamlink https://twitch.tv/$name --title "$name - Twitch"
	else
        exit 1
	fi
}

handle_selection "$( twitchy --non-interactive | sort | awk -F, '{print $1 " - " $(NF-1) " [" $(NF-2) "] (" $(NF-0) ")"}' | rofi -font "xos4terminus 12" -m 0 -bw 3 -dmenu -i -p 'Twitchy' -hlbg '#5FA5D7' -bc '#5FA5D7' )"

I use this script to list my Rofi scripts in Rofi:

#!/bin/bash
cd $HOME/Scripts/rofi; menu=$(find -L . -printf '%P\n' | sort | tail -n +2 | rofi -font "xos4terminus 12" -m -0 -bw 3 -dmenu -i -p "Rofi Scripts: "); ./"${menu}"

And I have bound it to Alt+Shift+p in i3:

bindsym $mod+shift+p exec "sh $HOME/Scripts/rofi-scripts.sh"

Post updated

  • September 28, 2019 - I updated the script to fix an issue with some stream titles causing the stream uptime to not work properly.

Meta

No Comments

Use the e-mail form, if you wish to leave feedback for this post. Markdown is supported. [Terms of service]