September 23, 2018

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"

Comments

I'm looking into a good way of implementing comments on my blog that works without JavaScript, respects the users privacy and is reasonably user friendly. If you have any ideas or just want to give me some feedback on this blog post or if you just want to say hello, feel free to do so either via e-mail, XMPP or Mastodon.