Avatar
Linux, plaintext & minimalism
September 23, 2018

Launch Twitch streams via Rofi using Twitchy

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

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"
Tags: Rofi | Twitchy | Twitch

Feedback

I don't have a commenting system simply because I haven't found a solution that I like. If you want to leave any feedback and/or have any questions, feel free to contact me either via e-mail, fediverse, XMPP or IRC (I'm Hund at freenode.net).