Avatar
Hund

Linux, plaintext & minimalism

Launch Twitch streams via Rofi using Twitchy

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 stream with $name"
		streamlink https://twitch.tv/$name best
	else exit 1
	fi
}

handle_selection "$( twitchy --non-interactive | sort | awk -F, 'BEGIN{OFS=" - ";} {print $1" - "$3" ["$2"] ("$4")"}' | rofi -font "xos4terminus 12" -m -0 -dmenu -i -p 'Launch a livestream' )"

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"

Feedback