Hund

How to launch Twitch streams via Rofi using Twitchy

Published: Sunday, 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


Meta

Comments

If you want to leave feedback you can do so by sending me a message via e-mail.