Categories
Raspberry Pi

A twitch chatroom display that appears on an e-ink screen at the press of a button.

I’ve been trying recently to get a twitch video broadcast system that I can just push a button and we’re go. As usual I’m working with a raspberry pi and its basic (but more than adequate) camera.

One of the annoying things I’m running into is firing up my twitch chat server on my phone and picking it up between songs etc. I don’t like having to press/swipe a load more things and I don’t honestly like an lcd screen flashing away at me or a mobile phone/wifi device right next to me while I’m playing (yes I’m sensitive to them – both the blue light and the wifi – I know you probably think I’m crazy but no amount of the government/manufacturers telling me this stuff is safe is ever going to stop me feeling like sh*t when I’m exposed to them too much!).

My pi gives me the potential to eliminate all this and have a wifi/mobile/lcd free device where I literally just have to press one button and the chat server appears on the screen! Cool huh!

Problem is… Twitch lets you into its chatroom with oauth tokens. This means when you disconnect from the chatroom you have to get another token! Really annoying if you do not have a permanent internet connection. Therefore I’ve got a VPS that is permanently logged into my twitch chatroom:-)

So what do we do? Well… Step number one is to actually get twitch to accept me into its chatroom. I’m using weechat as my irc.

Steps are:

  • Log into twitch in your browser
  • Go here: https://twitchapps.com/tmi/ and press to generate a token, then copy it.
  • then ssh into your vps and run ‘screen’ – this way it’ll stay even if you disconnect
  • then run ‘weechat’ in your screen session
  • then in weechat: server add twitch irc.twitch.tv/6667 -password=<pasted oauth token> -nicks=<username> -username=<username>
  • then connect to twitch with: /connect twitch
  • then join your channel with: /join #<username>
  • save your settings: /save

Now if you ssh back into your VPS you can type ‘screen -r -d’ and your twitch chat server will appear again!

Oh and I find Ctrl A – F really useful if I’ve used it on the wrong screen size and now it looks silly – it’ll have a good look at wherever you’re ssh’ing from and figure out what size screen you’re using now and modify itself…

Great, but what happens when your vps host has to reboot to do some security updates? (happened to me recently…) or you manage to completely gum up your vps with zombie processes to the point where you have to reboot from the hosting panel (ah… I errr… once heard a friend of mine did that…) Well then, here’s your set of instructions to sort out your chat screen if it disconnects:

  • go back here and get a new token: https://twitchapps.com/tmi/ Didn’t you know there is an infinite supply!
  • start screen again then weechat
  • back in weechat: /set irc.server.twitch.password <paste it here!>
  • /connect twitch
  • join #<username> and you’re back in!

But what about the e-ink screen I told you about? It’s a waveshare 800*450 one. Terrible refresh rate (we’re talking seemingly endless thumb-twiddling seconds…) But really cheap, good enough for displaying chat messages and has this excellent software for it: https://github.com/joukos/PaperTTY

Essentially what I’ve done is set up my old pi3 (aw I love the lil’ thing – I actually used it as my main work machine for the best part of a year – no kidding… Recorded a load of music on it too…) ummm where was I? Ah yes I set up the pi with the PaperTTY terminal command loading at startup.

In fact I messed with the config of the tty1 systemd process so that instead of coming up with a login screen, it shows tmux right from boot.

And then… And here’s the cool bit – I’ve got a script on my main machine (a pi4 in case you were wondering) that is triggered by xbindkeys so I press one keypress to:

  • log into the pi3 via ssh
  • trigger a local script on the pi3 that does a ‘writevt /dev/tty1 bash connect_to_my_vps.sh’

And connect_to_my_vps.sh does exactly that. It has an RSA key to log in so no password and it autoloads shell from the .bashrc on login.

Voila! One keypress and I’ve got a twich chat server on a reasonably sized e-ink screen.

Leave a Reply

Your email address will not be published. Required fields are marked *