Add a Screenshot Button to Streamdeck with Golang
Command to Take a Screenshot
I’m on Ubuntu so I can take a screenshot, of the active window, after 2 seconds, with a command like this:
/usr/bin/gnome-screenshot -w -d 2
I wanted to quickly run this from my streamdeck so I could take screenshots while I work (I write quite a lot of technical blog posts, this comes up pretty often). It works a treat!
Pro-tip: Use a script to resize the window you are taking screenshots of (see also: earlier post about resizing windows), this way they will all be the same size, a useful aspect ratio and if you need to replace one, it will match too.
Add the Command to a Streamdeck Button
Here’s a simple example script that puts a button labelled “Pic” in the first slot on the streamdeck and sends my screenshot command when it is pressed.
rabbitmq_url = appEnv.getService('guestbook-messages').credentials.uri;
Using the go routine means that if I have other functionality in this application then I don’t need to wait for the command to complete before I can press another button – especially important because this command has a delay in it.
I know I’ll be referring back to this post when I want to add commands to buttons in my streamdeck project, so if it’s helpful for you as well, then that is even better :) If you want to see my project (under active development just now) then it’s on GitHub. Let me know if you use it!