I’m going to try to do some kind of weekly update about different things that are going on, things I’m working on etc. Maybe just rambling thoughts.
Lately, there are two major projects I’ve been keeping busy with.
I’ve wanted something like this for a while. I did a bunch of searching but couldn’t find exactly what I was looking for. But then I found the Elgato Stream Deck and that looks amazing. It’s also not cheap at all.
Strangely though, after I found that, I found all kinds of similar devices. I don’t know where they were hiding during my earlier searches. Then I found this post:
And again, once I found that, I found a ton of similar projects. I decided to do it and bought a 3-pack of Arduino Nano clones. When I got them, I discovered that they will not work for this purpose. You need a device with a 32u4 chip in it, which will act as a keyboard/mouse interface. But while I waited to get the right Arduino, I was able to mess around with the code from the above article on the Nano and figure out how it all worked and started customizing it more to my needs. It wouldn’t connect as a keyboard, but I could trace things out to the serial port and see what happened when I pressed buttons. Here’s the nano, ready to go:
In the meantime, I got the right board, which is an Arduino Pro Micro clone and hooked that up on the breadboard, plugged it in and actually go it sending keys to my computer.
Then I got some pushbutton switches and plastic cases, soldered it all up, drilled some holes in the case, plugged it in and set up my shortcuts. And YES! It all works! Here’s prototype 2, which I’ve been using daily for the past week:
One of the ways I changed the software is that I created a separate callback function for each button, and a library of functions to call. It makes it easy to swap around buttons by just changing what they do. The article’s code hard-coded each button to a function key. My approach allows me to send other combos like Super-F
to open my file manager or Super-W
to open my browser, Super-T
for terminal, etc. Also, Alt-F4
to close a program or Ctrl-W
to close a window. All this is super easy on Linux, because it’s really simple to set up keyboard shortcuts to do virtually anything there. On Macos, you have to jump through additional hoops, using Automator or Karibiner. But I’m not using it on a Mac, so I’m good.
The worst part right now is remembering which button does what. I know have a sticky note next to it with a legend. Not ideal. So the next phase will include cherry mx keyboard switches with customized key caps.
Here’s a sneak peak at the final build in progress:
I hope to finish this up this weekend and I’ll post more details next week.
The other project I have going on is a desktop app which will will display live graphics generated from code, with various controls in the UI to update the code in real time.
When I was working mainly in JavaScript, I had built up a library of useful drawing functions that sat on top of the Canvas drawing API. I called this “bitlib”. I ported that to Go a couple of years ago, calling it “blgo” and have done a whole lot of work on it since. The Go version sits on top of Go wrappers to the C-based CairoGraphics library, which is part of GTK. Some weeks back I decided to try and go native with it, skip the wrappers, work directly with the C libraries, writing C code. I ported all of blgo to C and named it bitlib_c.
My reasons for getting away from JavaScript were mainly to get out of the browser. There are various limitations, security restrictions, performance considerations, etc. With Go and now C, I can write code, then compile that code, run the app, save an image and view that image with a press of a key. I can create an animation by saving hundreds or even thousands of files directly to my disk and then convert them to a gif using ImageMagick or even a video using ffmpeg. Again, all with one key press. I really love the set up that I’ve created over the last couple of years.
But one thing I missed from the browser is the immediacy and live feedback. In the browser, I was using my QuickSettings panel to alter the parameters for a drawing or animation in real time. This is not possible just running a program from the command line and saving to images. So I decided to build something myself.
One of the two major UI frameworks on Linux is GTK (the other being QT). Since Cairo is part of GTK, it made sense to build a desktop app with GTK. I could display a Cairo-based image surface in the app and then alter it with controls in real time. It was a bit of a learning curve, but I now have a proof of concept working.
Here you can see an image panel on the right and a control panel on the left. The sliders control the parameters of the drawing code and the drawing is updated in real time. This is a trivial example, but eventually I’ll be able to use this for any level of complexity of algorithmic drawing. My goals so far have been to get something working, learn GTK, and learn the various patterns to create a non-trivial application in C. I’m starting to get a decent MVC-type setup going on there which is nice. I want an easy way to create parameters and have that create the sliders or other controls, much like QuickSettings. Something more imperative, and less declarative than creating and initializing each control like it is now.
I’ll be continuing to work on this and share project. It’s still very much in the proof of concept phase, and I’m not sure it’s ever going to be something I share outright. But who knows.
I’m always looking for something cool to improve my computing life. What’s the one command line you probably use most often? ls
is one of mine (though I usually alias ll
to ls -la
). I recently found a mostly drop-in replacement called exa
(as of 2024, you should use the replacement, eza
).
It has great use of color coding, metadata and attributes, better defaults, built-in tree view and integrates with git. It’s built in Rust, is open sourced, MIT licensed, has executables for Linux and Mac OS (and Windows is on the horizon). Here’s a screenshot from exa’s github repo:
I just alias ls
to exa
and that mostly does all I need. Note that I said it’s a “mostly” drop-in replacement. There are some differences, but IMO, most of those differences are improvements.
I just alias ls
to exa
and that mostly does all I need. Note that I said it’s a “mostly” drop-in replacement. There are some differences, but IMO, most of those differences are improvements.
Is it life changing? No. But it’s a nice little quality of life improvement. Now if I ever see a non-exa ls
output, it just looks lame.
Comments? Best way to shout at me is on Mastodon