Inspired by this post for Windows on Raymond Chen’s blog, detailing how to make a best-effort attempt to open a query in the user’s default browser and search provider, I decided to write a Linux equivalent.
Since Raymond used C# for Windows (what could be more Windows?), I decided to use Bourne shell script for the Linux version (what could be more UNIXy?). Of course, me being me, I couldn’t help but add more error handling than Raymond does for his little programs.
One of the simplest ways to make a multi-monitor system look more impressive is to set a desktop background which spans across all of the monitors. Just scale the image up to the smallest size that fills all of the visible desktop space, then cut out monitor-shaped pieces to display.
Every system (even lightweight, older Linux desktops) supports this… every system except one. When KDE went from 3.5.x to 4.x, they dropped support for spanning a background across all desktops and, to this day, they still haven’t brought it back.
…and since everything more lightweight has bugs with the desktop layout I’m currently dealing with while I wait for the new monitor bracket I ordered, that’s a problem. (Even worse, there’s no API I could find to programmatically set a background either!)
The solution I settled on was to write a little Python script which uses maybe half a dozen lines of PyQt 4.x/5.x calls (before line-wrapping and boilerplate) to do what KDE should have, then spits out image files to be set as per-monitor backgrounds.
I also implemented a --randomize option which can be used with cron to produce input for KDE’s slideshow mode. (Basically, you set each monitor background to be a single-entry slideshow that the script updates)
Just give it an image (or --randomize and a list of files and/or folders) and an output directory. (See --help for more details)
UPDATE: It now also gives more control over how the background is matched to the desktop’s aspect ratio via --gravity and I included, as an example, the .desktop file I use to integrate it with Geeqie via Zenity. (KDialog’s equivalent to zenity --list is inferior.)
As I mentioned on previousoccasions, I don’t take too kindly to people trying to make me pay once for a game and again for its soundtrack and, as a matter of principle, I rip my soundtracks straight from the data files I paid for rather than pirating the officially separated versions.
Use it to open DesktopDungeons_Data/resources.assets
Extract all of the .ogg files
Load them all in your music player and manually delete the ones which are sound effects. (You should be left with pairs of Intro and Loop files.)
Download the following script and install the packages listed in the Requirements section
Place the script in the same folder as your .ogg files, run it, and wait.
Could not embed GitHub Gist 2e3748af264c70cf32c2: API rate limit exceeded for 220.127.116.11. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)
Not much to report over the last few days. I was mainly busy ripping old CDs so I could store them in the closet.
cdparanoia -B and ddrescue (instructions) are essential for damaged audio tracks and CD-Rs. However, for old DOS/Win3.1-era CD-ROM games which use Redbook audio, they don’t really produce something that DOSBox or CDEmu+Wine can mount and play.
As such, I whipped up a quick little script for generating BIN/CUE pairs based on advice for ripping Playstation games under Linux. Here it is in case anyone wants it (you’ll also want my swab.py script that works but is long overdue for a rewrite):
In the time since I last tried migrating my blog to Jekyll, it has gained an official WordPress importer. Unfortunately, that importer requires direct database access and NearlyFreeSpeech.NET doesn’t have the requisite Ruby dependencies.
…so I decided to hack around that. It’s much easier to run the importer locally, but NFSN doesn’t expose their database servers to the world at large… SSH port forwarding to the rescue.
Install the development headers for libmysqlclient
gem install jekyll-import sequel mysql2 unidecode` Note: Make sure it does complain about `htmlentities` being missing or you’ll get a broken import with things like the / in </a> escaped.
Open up two terminal windows
In one terminal, adjust this SSH command and run it to forward the MySQL client port ssh -L 3306:YOUR_DSN_HERE:3306 USERNAME_SITENAME@ssh.phx.nearlyfreespeech.net
In the other terminal, adjust and run this jekyll-import command to dump the blog
Note: Make sure `host` is set to 127.0.0.1. If you use localhost, it will try to use a UNIX domain socket rather than a TCP socket and fail.
Exit the ssh connection to close the tunnel and start fine-tuning the exported content.
Unfortunately, I found jekyll-import insufficient (eg. it made no attempt to preserve permalinks) so I started investigating alternatives. I discovered that Pelican (a Python alternative to Jekyll) has some very appealing plugins (eg. ), so I’ll probably use that instead.
I generally like using TaskWarrior to manage my tasks but I’ve found that, for daily recurring stuff, it just doesn’t feel quite right.
As such, I’ve put together a little tasklib-based glue script, runnable as a user cronjob if you set DISPLAY, which presents tasks due before the end of today (defined as 1:00:01 AM, local time, to work around a quirk caused by TiddlyWiki’s ignorance of daylight saving’s time) in a zenity checklist dialog.
It looks like this:
Clicking OK will commit the changes and then redisplay the dialog with refreshed content while clicking Cancel will quit the tool. The redisplay behaviour, window size, warning period, and zenity command can be customized by editing constants at the top of the file.
It’s available on GitHub Gist, as embedded below and here’s the download link. A requirements.txt is included which will install all of the dependencies except zenity.
Today, I decided to help someone out and, as is often the case with coding, I got carried away.
I set out to help fix up a shell script but, instead, I decided to “do it right” and produced a simple Python script which…
Uses a combination of GLib.timeout_add_seconds and UPower events to react to power supply changes immediately while still putting a limit on how often battery percentage changes should be able to cause wakeups.
Uses GStreamer and notify2 to provide audio and visual low-battery warnings without the weight and delay of calling subprocesses.
Is compact and easy to customize because it’s written in Python
By design, it doesn’t really have much of a UI (just a persistent notification popup and alert sound that come and go in response to changes in power state), but here’s what the popup looks like when using xfce4-notifyd:
It does require the 1.0 UPower API for its “Display Device” abstraction, so an 0.99.x-series version of UPower or newer is required, but for people on a new enough Debian/Ubuntu/Mint release (Vivid, in Ubuntu’s case), the dependencies can be installed as follows:
It hasn’t been tested under Python 3.x but it looks like it should work perfectly if you just replace python-notify2 python-gi with python3-notify2 python3-gi in the dependencies and edit the shebang line at the top of the file.
I only wish I’d realized what I was doing sooner so I could start tracking its evolution properly in git. As-is, all I could do was translate the snapshots from Dropbox’s revision history.
As usual for small, single-file things, here’s the direct download link followed by a GitHub Gist embed.