hugopl/devblog

06 Dec 2023

Disabling pipewire whitenoise on idle

Update from 2024-03-25
Wireplumber changed and nothing I wrote here works anymore, but one thing still... wireplumber is horrible to configure.

I’m writing this here so I “don’t forget”.

My speakers emit a annoying whitenoise when they are turned on but there’s no signal, the problem is that my ArchLinux setup is putting the sound board into idle mode to save power after 3 (or 5?) seconds, so every time I stop listeing something, after 3 (or 5?) seconds the whitenoise starts… really annoying.

I fixed this once, but I was lazy enough to edit system files instead of user files, so today I updated wireplumber again and the whitenoise was back there.

To let you and future me repeat the same mistake of present mine, if this happen to you, edit these files:

Comment this line from /usr/share/wireplumber/main.lua.d/90-enable-all.lua:

-- Automatically suspends idle nodes after 3 seconds
--load_script("suspend-node.lua")

Restart wireplumber:

systemctl --user restart wireplumber

Months ago I had also to edit /usr/share/wireplumber/main.lua.d/50-alsa-config.lua

Uncomment this line at end and set the value to 0 as the comment says.

--["session.suspend-timeout-seconds"] = 0,  -- 0 disables suspend

But nowadays the 90-enable-all.lua seems enough.

Comment
01 Apr 2021

GTK3/Gnome Custom Keyboard Compose Sequences

For personal historical reasons I’m used to US keyboards, so to write portuguese text with those keyboards I need to use the English (US, int. with dead keys) layout that provides compose sequences to write characters like áàãéíóóõúüç.

To generate a ' character I type ' +     . It’s this way since ever…. but lately (starting from GTK3 version 3.24.28) somebody decided that this was a bug, not a feature. If someone type this compose sequence the generated character should be ´, not ', and to generate ' you would need to type AltGr + '. The problem is that in protuguese the character ´ alone have no meaning/usage, on the other hand the character ' is used a lot when programming, i.e. this had a huge impact on me.

Long story short, to let GTK behave like I’used to, create a file named .XCompose in your home directory with this:

<dead_acute> <space>                : "'"   apostrophe # APOSTROPHE

If you are not used to the XCompose format, check /usr/share/X11/locale/en_US.UTF-8/Compose and you are going to have a idea (or man 5 Compose).

In the past the behavior change that made a headache was ' + c generating ć instead of ç as I was used to, the new compose sequence (that now I’m used to) is AltGr + ,. Hope it helps whoever is reading.

Comment
28 Apr 2019

Crystal On Raspberry Pi

For the ones that don’t know, Crystal was a 2018 hype (however the project exists since 2012) that I only found in 2019, basically it is a language very similar to Ruby in syntax, but that compiles to machine code and is statically type checked.

I was about to start a pet project using Raspberry Pi and Ruby when I noticed the existence of Crystal, so I used the occasion to learn Crystal, just one problem: There’s no crystal in archlinux for raspberry, or at least my efforts to find one weren’t enough.

Not a problem, let’s compile the Crystal compiler into raspberry! This would be amazing, but Crystal compiler is written in Crystal itself, so we have the egg-chicken problem here, the answer? cross compiling!

Cross compiling

By my experience with C and C++, cross compile is a hell, but since Crystal is built on top of LLVM, I gave a try hopping for the best… and was very easy! :-)

My tests were using ArchLinux into a rPi, but this is so simple that must work on every distro.

First do a hello world in Crystal, save it as hello.cr:

puts "Hello Crystal ARM world!"

Install crystal on your computer, sudo pacman -S crystal, then cross compile your hello-world program.

$ crystal build --cross-compile --target=armv6l-unknown-linux-gnueabihf hello.cr

To know why the string “armv6l-unknown-linux-gnueabihf”, go to the rPi, install the llvm-package and type llvm-config --host-target, this is how LLVM describe the platform it is compiling for.

This will compile the file, generate a object file and print lines of code that you need to run in the host machine (the rPi) to link your program, i.e. a GCC command line.

So…. copy the hello.o file to the rPi, then we are going to try to link it. But not so fast, Crystal programs have some dependencies, all but one are solved by installing packages, so in your rPi install the following packages:

$ pacman libevent gc

The missing dependency is libcrystal.a, a tiny one-file plain C static library that we are going to build from Crystal sources.

Building libcrystal.a

As I said, this library is just a single plain C file, so we just need to compile it and generate the static library in the rPi.

$ wget https://raw.githubusercontent.com/crystal-lang/crystal/master/src/ext/sigfault.c
$ cc -c -o sigfault.o sigfault.c
$ ar -rcs libcrystal.a sigfault.o

Then you can put libcrystal.a in /usr/lib/crystal/ext/ or in the same directory of the hello world. The crystal/ext directory is better, since the link commands the Crystal compiler tell us use this, so we need to change nothing.

Finally linking!

Now with everything ready, just link your object file with the commands supplied by the crystal cross compilation.

$ cc 'hello.o' -o 'hello'  -rdynamic  -lpcre -lgc -lpthread /usr/lib/crystal/ext/libcrystal.a \
-levent -lrt -ldl -L/usr/lib -L/usr/local/lib

If you think this is too much job… or you are too young in the cross compilation world or I’m too old to remember how painful was to cross compile anything to ARM.

Comment
21 Apr 2016

RubyCreator release and Windows binaries!

If you have a Windows 32bits and want to try RubyCreator I present you the first RubyCreator binary distribution!

Only Windows 32bits is available since I only have a Windows7 32bits VM available. Consider the Windows distribution beta, I don’t test/use it everyday like I do with the Linux version.

Project Manager

This hand in the screenshot is from my Linux desktop and I’m too lazy to go there take another shot, since I compiled and tested using a VM.

I turned off font anti aliasing, with it on I was not able to proper see the bold text used in RubyCreator sintaxhighlighter, I also didn’t test the Rubocop integration, but it should work, to try it: Add ruby to the system path and make the rubocop gem available for it.

To install it go to Github releases page, download the zip file, unzip and copy the Ruby.dll file to the QtCreator plugins directory. Restart QtCreator and done.

The binary distribution is GPG signed (.sig file) if some nerd want to check if was really me that created it, BTW I need create a new GPG key, mine is too old.

Want a 64bits version?

So help me, I wrote instructions about how to compile the plugin on Windows, it’s not that hard but takes some time.

Conclusions

After too many years without code a single hello world on Windows I have the feeling that Courrier New font is very ugly, but ok, it works.

Comment
20 Apr 2016

Compiling RubyCreator on Windows

I finally spent some time to try to compile RubyCreator on Windows, I don’t use Windows and dislike it as a development environment so this is why it took so long, here I’ll describe the steps to get it compiled and working, in a near future I plan to do binary distributions for RubyCreator, so will be easy for Ruby Windows developers to get it.

While there is no binary distribution, you need to compile it yourself, so here is the slow and painful instructions, ok, not so painful, but requires a log of time and downloads.

Overview

To get it done you will need.

  1. Patience, 1Kg is enough.
  2. Download Microsoft Visual Studio Express 2013 (QtCreator binary distribution was compiled with it, so the plugins should use the same compiler).
  3. Download Qt for Visual Studio 2013 (The huge package with 840Mb)
  4. Get the QtCreator sources from somewhere or clone it from git (git@github.com:qtproject/qt-creator.git). Try to do a shallow clone to avoid download the whole QtCreator git history.
  5. Compile QtCreator
  6. Clone RubyCreator
  7. Compile RubyCreator

Compiling QtCreator

As the QtCreator binary distribution does not come with all the data we need to be able to compile any plugin, you will need to compile QtCreator first.

  1. Open the MSVC2013 Developer Command Prompt.
  2. Add the Qt bin directory to the system path, so you can call qmake.
    C:\> SET PATH=%PATH%;C:\Qt\Qt5.6.0\5.6\msvc2013\bin
  3. Go to the directory you cloned QtCreator.
  4. Checkout to the tag matching the version of QtCreator you want to compile, in this case same version of QtCreator you already have installed on your system.
  5. Prepare to do a out of source build:
    C:\...\QtCreator> cd ..
    C:\...\> mkdir QtCreatorBuild
    C:\...\> cd QtCreatorBuild
    C:\...\QtCreatorBuild> qmake ..\QtCreator\qtcreator.pro
    C:\...\QtCreatorBuild> nmake
  6. Now go find something to do, because this will take some time.

Compiling RubyCreator

You are closer… just a few minutes.

  1. Open the MSVC2013 Developer Command Prompt and make sure qmake is on system path like you did to compile QtCreator.
  2. Go to directory you clonned RubyCreator.
  3. Change to the branch that match the QtCreator version (qtc-3.6 for QtCreator 3.6.x).
  4. Compile it :-)
    C:\...\RubyCreator> cd ..
    C:\...\> mkdir RubyCreatorBuild
    C:\...\> cd RubyCreatorBuild
    C:\...\RubyCreatorBuild> qmake QTC_SOURCE=..\QtCreator QTC_BUILD=..\QtCreatorBuild ..\RubyCreator\ruby.pro
    C:\...\RubyCreatorBuild> nmake

The plugin is called Ruby.dll, you can find it somwwhere in the QtCreatorBuild among with other plugins, copy it to your QtCreator plugins directory, restart it and done.

Conclusions

Need to compile the entire QtCreator to just compile a small plugin is a pain in the ass, life would be easier if QtCreator packages had the necessary bits to compile plugins.

Comment