Record my desktop with ffmpeg
It seems that desktop recording is quite the pest. Not that I’ve tried much, but I also haven’t really found a "go-to" piece of software for X11 that just does it. So the last time I wanted to record my screen, I decided to have a go with just plain command-line tools.
It turns out that this is also ridiculously easy.
ffmpeg -f x11grab -s 500x300 -r 25 -i :0.0 foo.mp4
The -s option tells ffmpeg the pixel size of the region you want to grab; -r is the frame rate, -i is your X screen, and the video is written to foo.mp4.
If you don’t want to start the screen capture in the top-left, just use something like
-i :0.0+100,200 to specify where to start.
The ffmpeg website has more info.
Posted on Tuesday, February 19, 2019
Find and replace in geany
The other day I wanted to do a find-and-replace in geany using a regex in the find. I wanted to turn something like this
Field name: value
Field name: value plus some more
Since geany supports regex searching, I decided it was time to find out how to do regex replacements too. The way it works, is that you put parentheses around each match that you want to be able to use in the replacement string, and then reference these replacements using backslash-number. So the find string becomes
^Field name: (.*)
and the replacement string becomes
Field name: \1 plus some more
That was too easy.
Posted on Monday, February 18, 2019
Getting Void Linux to work right
My experiment with Void Linux started very well. There was the usual round of installing all the packages I needed to make the computer useful, and then there was the business of getting nonfunctional stuff to work. Being that Void doesn’t modify packages, this was also an educational experience.
The trackpad on this computer was tracking too slowly for my liking. I don’t know if it was due to Arch/Void differences, or just changes in xorg, but it really doesn’t matter.
I didn’t want to fix this with an X configuration file, primarily because it doesn’t live in my home directory and is thus vulnerable to disappearing with an OS install.
I discovered xinput, which allows you to query and set various input-related settings in a running X server.
To get a list of input devices:
To see the available properties of a device (use the device name reported above):
xinput list-props <device name>
To set a property:
xinput set-prop "ETPS/2 Elantech Touchpad" 287 1
where "ETPS/2 Elantech Touchpad" is the device name, 287 is the number of the property to set, and 1 is the value I want there.
I run this in .xinitrc before starting xfce4.
X display settings
I discovered the wonders of xrandr some time ago, but it’s worth documenting. With a laptop, you (or at least I) frequently end up connecting to a variety of different screens. These are often TVs that just don’t correctly report their capabilities in the EDID (which is the way a monitor tells a computer its name, the resolutions it supports, etc).
To fix this, you can sometimes supply an EDID file to the kernel at boot, or edit the xorg configuration, or just use xrandr on a running X server.
To create a new mode, and assign it to a particular output use this:
xrandr --newmode "1920x1080 60Hz" 148.500MHz 1920 2008 2052 2200 1080 1084 1089 1125 +HSync +VSync xrandr --addmode DP-1 "1920x1080 60Hz"
You can get the output names by running xrandr with no arguments. To get modelines, use the
cvt programs. The new mode will now be available in your favourite monitor-configuring tool, be that xrandr or your DE’s settings program.
I run this in .xinitrc before starting xfce4.
Getting xfce4’s restart and shutdown buttons to work
This one turned out to be easy. You simply run
startxfce4 with the
--with-ck-launch option. I had tried this previously with no result, probably because some required package wasn’t installed. I assume this was ConsoleKit, or maybe PolicyKit, and it would have been brought in as a dependency for something else.
For some reason, there are no suspend or hibernate buttons. I don’t know if they’re compiled out in Void, or not being shown because those functions aren’t available. I strongly suspect, due to what I’ve read, that these two rely on systemd to work.
Intel HDA sound is always a pest. My sound used to work in Arch, but that may have been due to some tweaking that got blown away when the root partition was reformatted. My problem was that sound would go to the headphones when they weren’t plugged in but when they were plugged in, sound would go to the speakers.
I finally stumbled upon the awesome tool
hdajackretask, which is a part of
alsa-tools. The snd-hda-intel module can be reconfigured on the fly by writing values to the correct section of
/sys. You just fiddle around in hdajackrestask until things seem to work right, then grab the shell script it creates from
I tweaked the script to stop it trying to write logging information to /tmp, and called it from
/etc/rc.local in order to apply the sound changes at boot — oh the joy of having rc.local again!
Automounting of USB drives
I’ve been using devmon and udevil for years. With systemd there’s some bodgy-looking method for running devmon when a user logs in. Without systemd you just put it in your .bashrc or equivalent shell startup script. I’m using fish, so what I’ve ended up with is:
pidof -x devmon > /dev/null 2>/dev/null if test $status -ne 0 echo "Starting devmon" devmon -g & end
This typically starts devmon when I log in, and logging out should kill it.
Posted on Tuesday, January 22, 2019