Tag Archives: Linux

Customizing the Librem5 ringtone (works for Mobian too)

The Librem5 has a single ringtone included, and while it is nice, it is not aggressive enough for me, I wanted to customize it. So here is how I went about. The same will work for the Pinephone on Mobian which uses the same software stack, I think.

The terminology in this howto is quite confusing. So be aware that a 1) sound theme, a 2) feedback theme, and 3) feedback profiles are three different things.

1) The first one defines in which directories a sound file is looked up (the freedesktop theme will serve as fallback, if a sound is not defined). 2) The feedback theme connects event names and sound files (or visual/haptic feedback) and also defines various feedback profiles. 3) Those profiles are full, quiet and silent, providing profiles within a theme. OK, so let us get started and explain how to customize sounds. The testing it all section at the end of this blog post lets you easily test your results.

TL,DR; the quickie on the L5 / Mobian

#on the L5: as user purism
cp -pr /usr/share/sounds/librem5 ~/.local/share/sounds/mysound
mv YOURCOOLRINGTONE.ogg ~/.local/share/sounds/mysound/stereo/phone-incoming-call.oga
gsettings set org.gnome.desktop.sound theme-name mysound
# probably a reboot is needed...?!
#on Mobian: as user mobian
mkdir -p ~/.local/share/sounds/mobian/stereo
cp -pr /usr/share/sounds/freedesktop/index.theme ~/.local/share/sounds/mobian
mv YOURCOOLRINGTONE.ogg ~/.local/share/sounds/mobian/stereo/phone-incoming-call.oga
gsettings set org.gnome.desktop.sound theme-name mobian
# probably a reboot is needed...?!

Setting a sound theme

To check the current sound theme, issue:

gsettings get org.gnome.desktop.sound theme-name

On a Librem 5, the sound theme name will be “librem5“, which means that the default sound theme (src) installed at /usr/share/sounds/librem5 is being used. Go there, and check out the sounds in there, if you like. On the Mobian, the theme-name is simply set to “freedesktop“, ie no special theme-name has been set.

To create a new sound theme, I copied over the /usr/share/sounds/librem5 to /usr/share/sounds/spaetz (and renaming the theme in the index.theme file). If you want to do this as a local user, you can also place the directory in the ~/.local/share/sounds directory. Then set the sound theme to your new name, and you are done:

gsettings set org.gnome.desktop.sound theme-name YOURTHEMEDIRECTORNAMEYHERE

Once again, to check the currently set sound theme use: gsettings get org.gnome.desktop.sound theme-name

If all you wanted to achieve is to customize the sound, ie switch out sound files, you are done here. If you need to change the notifications or want to connect events and sounds in a different manner, read on.

Connecting Events and Sounds

feedbackd is used to connect events and feedback. The configured sound theme is used by the feedback theme definitions stored in /usr/share/feedbackd/themes/default.json which connects events to various types of feedback. Possible themes for various devices are in this src repo. And all possible event names are listed here. The docs however state that currently only a single hard coded feedback theme ‘default‘ can be used. So /usr/share/feedbackd/themes/default.json is the file to modify if you want to use a different sound name for an event, or let the vibrator vibrate longer (or shorter).

As an alternative to switching sound themes, in order to customize ringtones for instance, one could also connect e.g. the phone-incoming-call event to a different ogg sound file name (sound files usually use an .oga file suffix) and simply place that in the fallback directory at ~/.local/share/sounds/freedesktop. Modifying the effect name to your sound file name should be sufficient then (untested):

   {
      "event-name" : "phone-incoming-call",
      "type"       : "Sound",
      "effect"     : "phone-incoming-call"
    },

Although there is only a single feedback theme, it offers various feedback profiles, which is what we know as the normal, silent, vibrate-only profiles on other mobile phones. These can also be set and retrieved programmatically:

Feedback Profiles

In Settings->Notifications one can conveniently change the overall profile between loud and silent ones. Using the command line, you can use:

gsettings get org.sigxcpu.feedbackd profile
in order to retrieve the current profile and
gsettings set org.sigxcpu.feedbackd profile full|quiet|silent (one of the three possible values)
in order to set the current feedback profile. The description says:

full: Use configured events from the full, quiet and silent parts of the feedback them.

quiet: Use quiet and silent part from of the feedback theme. This usually means no audio feedback.

silent: Only use the silent part from the feedback theme. This usually means to not use audio or vibra.

Per app profiles

In Settings->Notifications one can conveniently change the profile also per application (so silence your chat messages but have loud sound when the alarm clock wants to go off).

Advanced stuff: One can set the feedback profile of an individual application via GSettings. E.g. for an app with app id sm.puri.Phosh to set the profile to quiet do:

gsettings set org.sigxcpu.feedbackd.application:/org/sigxcpu/feedbackd/application/sm-puri-phosh/ profile quiet

Testing it all

To simulate events and see/listen to the sounds use the fbcli utility (just fbcli will simulate an incoming phone call). The following (taken from the docs), will simulate an incoming message once:

fbcli -t -1 -E message-new-instant
# or play the alarm clock sound for 10 seconds:
fbcli -t 10 -E alarm-clock-elapsed

Note: while fbcli picked up a new sound theme immediately, a quick test on calling myself led to no ringtone sound at all. After a reboot, the new sound played fine. Please report if this was a glitch or seems to be the case indeed.

TODO: So what is the “Do not disturb” setting doing then 🙂
TODO: find out what happens when both /usr/share/sounds/librem5 and ~/.local/share/sounds/librem5 exist

Pinephone

It is great to use a phone that runs *real* Linux. (Although I do own the OpenMoko, and the Nokia N770 too :-)). Here are a few technical notes to myself how to tweak it:

#GNOME software daemon uses obscene amounts of memory and I update manually anyway 
rm /etc/xdg/autostart/gnome-software-service.desktop

Connecting Keepassxc Portable on Windows with Firefox

I am using the excellent KeepassXC on all my computers, it works on Windows (work-supplied laptop), Linux (home) and there are mobile clients too. On my Windows work laptop I am using the PortableApps version. The keepassxc devs offer a portable zip for download (KUDOS!) but I do like the seamless upgrades and the start menu the PortableApps platform offers. So far, so good.

However, I – seemingly like many others – have trouble to connect the portable version with the Firefox browser extension to enable autofill. After lots of trial and error and debugging attempts (debugging led to no more detail than “key exchange failed”, unfortunately), I have gotten it working. See below what I did, in the hope that it might be useful for others and for future reference to myself (I posted this in the portable app forum too -and- as the problem seems widespread as an issue in the keepassxc issue tracker. It was quickly closed there as the devs don’t want to support PortableApps versions, fair enough, but would perhaps saved them a few support requests if the information were to be find in their development wiki):

Initial Problem PortableApps Keepassxc (2.5.3)
Some things worked as intended:

  • I had a registry key under “Computer\HKEY_CURRENT_USER\Software\Mozilla\NativeMessagingHosts\org.keepassxc.keepassxc_browser”,
  • it pointed to the correct org.keepassxc.keepassxc_browser_firefox.json file
  • which pointed to a correct path “C:\Users\spaetz\bin\PortableApps\KeePassXCPortable\App\KeePassXC\keepassxc-proxy.exe”

When I started Firefox, I got a running keepassxc-proxy.exe process as a Firefox child process. However, trying to connect, all I got is a “key exchange failed” error. Turning on add-on debugging led to the same result and not more helpful information.
When I turned off the use of a proxy in the keepassxc settings (Browser integration -> Advanced), starting Firefox actually also started a keepassxc instance automatically, however all I still got was a “key exchange failed” error. NO combination of options, deleting of keepassxc and/or the browser extension, deletion of registry entries, or using a fresh Firefox profile helped.

Possible Solution

I noted that there are actually 2 binaries:
BINARY1:
C:\Users\spaetz\bin\PortableApps\KeePassXCPortable\KeePassXCPortable.exe (248kb) and
BINARY2:
C:\Users\spaetz\bin\PortableApps\KeePassXCPortable\App\KeePassXC\KeePassXC.exe (7094kb)

The latter is also the directory which contains the keepassxc-proxy.exe. The binary in the former directory is what is started when one starts keepassxc through the PortableApps menu.

IF I directly start the latter binary, the Firefox extension is able to connect to the running keepassxc. If I start the former, I will get a key exchange failed error. Somehow, in this case the proxy will probably try to talk to the wrong binary. (not sure what weird wrapper the first binary is).

I autostart BINARY2 now on system start (Hit WIN-R, type shell:startup and paste a “link” to the correct keepassxc.exe) and that seems to do the trick for me. I realize that this is not the fault of keepassxc, but given the multitude of reported errors and the unhelpful error message I think this might be of use for other users of the Portable Version. It might be useful on the wiki if confirmed by other users of the portable version on windows….

Home Assistent Pitfalls

I have been playing with Home Assistent. Yes, our home should be smart too :-). But I am not giving up my privacy, so only a local solution was considered! Here are a few pitfalls that I experienced when configuring Home Assistant, I hope they are useful to you too.

FritzBox device tracker:

I have a FritzBox from AVM, so I installed the “platform: fritz” module to track devices in our WLAN. However, that led to mysterious “Failed to establish connection to FRITZ!Box with IP: 169.254.1.1” errors. Debugging the underlying package “fritzconnection”, it turns out that you need to turn on “Zugriff für Anwendungen zulassen” AND “Statusinformationen über UPnP übertragen” in your Homenetwork->Network Settings, to make it work. This will turn on TR-64 and the transmission of the necessary status information. Error handling of this package could be a tad better….

FritzBox DECT switch (Fritz DECT 210):

the “platform: fritzdect” module is supposed to handle The Fritz DECT 210 remote switch. However, I still haven’t gotten it to work. I receive error messages in the form:

 File "/usr/local/lib/python3.6/dist-packages/homeassistant/components/switch/f
ritzdect.py", line 157, in update
 self.state = actor.get_state()
 File "/home/hassio/.homeassistant/deps/lib/python3.6/site-packages/fritzhome/a
ctor.py", line 56, in get_state
 int(self.box.homeautoswitch("getswitchstate", self.actor_id))
ValueError: invalid literal for int() with base 10: 'inval'

Notifications via XMPP/Jabber:

I have managed to receive notification messages via XMPP when certain things happen. Now I need to come up with smart rules, to make things smart….

ARTICLE WILL BE UPDATED AS I PLAY MORE WITH HOME ASSISTANT.

CIFS mount on Linux

If you start running into mysterious CIFS mount errors on a recent Debian (“mount error(95): Operation not supported“) or autofs stops working (“mount(generic): failed to mount //192.168.178.2/YY (type cifs) on /home/YYY”),

try to add “vers=2.0” (or vers=1.0) to your mount options. Recent kernels default to samba version 3, which apparently is not supported by many boxes (including my Synology)

Using an HTTP proxy when a VPN is used

Background: When I connect to my University’s VPN service I need to use a HTTP proxy in order to access the WWW. I use GNOME and Network-Manager. The Openconnect plugin manages to establish the VPN connection nicely, but previously I had to enable the proxy in Firefox manually afterwards. This is my solution on how to set GNOMEs http proxy settings automatically when a VPN connection with the name “UniiHH” is established and works by using a script in /etc/Network-Manager/dispatch.d.

This is my 10_enablevpnproxy (needs permission 755):

#!/bin/sh -e
# Script to set up the University of Hamburg web proxy when the Openconnect VPN connected
# credits to https://wiki.ubuntuusers.de/NetworkManager/Dispatcher/

VPN_CONNECTION_NAME="UniHH"
USER="spaetz"

# VPN connection started or stopped?
case "$2" in
    vpn-up)
    active_vpn=$(nmcli -t --fields NAME con show --active|grep "${VPN_CONNECTION_NAME}" -q)
    if $active_vpn; then
        # VPN to UNI HH was started
    else
        #Irrelevant VPN started, do nothing
        exit 0
    fi
    # gsettings will fail if dbus is not launched with:
    # "dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
    sudo -u "$USER" dbus-launch gsettings set org.gnome.system.proxy mode 'manual' 
    sudo -u "$USER" dbus-launch gsettings set org.gnome.system.proxy.http host 'proxy.uni-hamburg.de'
    sudo -u "$USER" dbus-launch gsettings set org.gnome.system.proxy.http port 3128
    ##gsettings set org.gnome.system.proxy.ftp host 'proxy.localdomain.com'
    ##gsettings set org.gnome.system.proxy.ftp port 3128
    sudo -u "$USER" dbus-launch gsettings set org.gnome.system.proxy.https host 'proxy.uni-hamburg.de'
    sudo -u "$USER" dbus-launch gsettings set org.gnome.system.proxy.https port 3128
    sudo -u "$USER" dbus-launch gsettings set org.gnome.system.proxy ignore-hosts "['localhost', '127.0.0.0/8', '10.0.0.0/8', '192.168.0.0/16', '172.16.0.0/12' , 'fc00::/8' , '*.fritz.box' ]"
        ;;
    vpn-down)
    # Disable all proxies on VPN shutdown, this might be to simple
    # for your case, it works for me.
    echo "VPN connection was stopped"
    sudo -u "$USER" dbus-launch gsettings set org.gnome.system.proxy mode 'none'
        ;;
esac
exit 0;

The script is run as root by network-manger so, I needed to hardcode the user whose proxy settings I want to modify in the script. And admittedly the part about calling sudo -u $USER dbus-launch multiple times is quite clumsy and should be solved more elegantly. The problem is that gsettings needs to a) run as the user whose values we want to change and b) needs access to a running dbus-session or it will spit out:

Cannot autolaunch D-Bus without X11 $DISPLAY

Helpful links were: https://wiki.archlinux.org/index.php/proxy_settings https://wiki.ubuntuusers.de/NetworkManager/Dispatcher/ http://askubuntu.com/questions/645968/error-cannot-autolaunch-d-bus-without-x11-display

P.S. Of course, sudo needs to be installed for this script.

Getting WiFi rtl8723be to work in Debian

After crashing my previous laptop, I bought a HP 15-ba055ng that contains a rtl8723be Wifi card. However, under Linux the connection would become instable after a short while and refuse to reconnect. I needed to do a series of things to fix this:

  1. Apparently only 1 antenna is connected to the card while the card is configured to use a different antenna slot, leading to an abysmal signal. A new parameter was introduced in kernen 4.0.7 (or so) that lets on select the antenna in the kernel module.
    Create a file /etc/modprobe.d/rtl8723be.conf and enter

    options rtl8723be ant_sel 1

    (the default is 0). This let to a much better signal reception (as visible by doing iwlist scanning). But it still did not help, connection got refused after a while.

  2. Some other options need to be changed to make it work. Most people say that disabling sleep parameter fwlps (FW control power save, default 1) helped. So, that would be adding fwlps=0 to the above line. I did that.In addition some claim, that setting ips=0 or msi=1 has helped them to get a better reception. Try it, I use ips=0, but msi=1 seemed not necessary, so that my current options look like this: options rtl8723be ant_sel=1 ips=0 fwlps=0
  3. Some claim that windows fasstboot mode needs to be disabled in order to make WiFi work reliably. (in case you dualboot) However, I have not tried that yet, nor found it necessary.

All this is on a Debian Jessie system. On a final note: I find it pretty sad that a laptop sold in 2016 has no 5Ghz capabilities. I did not even fact-check that before my purchase as it did not occur to me that this could be an issue.

Relevant links I used for trouble-spotting (plus a ton of other links I forgot about):

  • https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1461174/comments/35
  • https://unix.stackexchange.com/questions/229221/rtlwifi-rtl8723befw-bin-wireless-stop-working-then-laptop-needs-to-reboot-to
  • http://askubuntu.com/questions/635625/how-do-i-get-a-realtek-8723be-wireless-card-to-work
  • https://ubuntuforums.org/showthread.php?t=2304607&page=4
  • https://bugzilla.kernel.org/show_bug.cgi?id=83641#c1

Howto extract PDF pages on Windows and Linux

mutool is great. You can install it portable as regular user on Windows, for instance. If you need to extract a few pages from a long pdf you can use mutool clean. However by default, this will create a pdf that is as big as the original input file. To compact the resulting file, make use of the -g options. So this works great to extract pages 19-20:

mutool clean -ggg  input.pdf output.pdf 19,20

Ungültige Signatur in Windows

Ich benutze einige Portable Programme (wie z.B. emacs) auf meinem Windows-Arbeitsrechner. Leider gibt es dort diese hässliche Fehlermeldungen bei jedem Start: “Diese Datei verfügt über keine gültige Signatur…”. Mist, dachte ich. Allerdings ist Windows gar nicht so streng, es will lediglich alle aus dem Internet heruntergeladenen Programme signiert haben. Wenn man das Programm lokal “kreiert” dann läuft es auch ohne Signatur (eigentlich hirnrissig). Die Anleitung um den Fehler beim Starten wegzubekommen ist hier. (Danke)

UPDATE (Mar 2016:): Die Anleitung in Kürze: Mit “cat putty.exe > putty2.exe” ist die ausführbare Datei auf einmal “lokal” erzeugt und gilt nicht als unsichere heruntergeladene Datei. Dann klappts auch mit den Nachbarn.

VPN an der Uni Hamburg mit Linux

Die Universität Hamburg bietet wie so viele andere Organisationen ein VPN auf Cisco AnyConnect Basis an. Bis vor einiger Zeit funktionierte der eingebaute “vpnc” VPN Dienst (Gruppenname “vpnusers”), allerdings wurde der wohl endgültig eingemottet :-(. Als einzige Möglichkeit wird der Download und die Nutzung des proprietären Cisco AnyConnect Client angeboten. Also, downloade Cisco Binärblob und lasse ihn als Administrator (root) auf deinem Rechner laufen. HAHA, ganz bestinmmt … nicht.

Zum Glück geht es auch mit Linux-Distributionsbordmitteln. Zur eigenen Referenz hier die Schritte mit GNOME unter Debian (Jessie):

  1. Das Geheimnis heisst “Openconnect” und ist so als Paket auch in z.B. Debian installierbar. (muss nicht installiert werden, wenn man die GUI Variante verwenden will). Für alle hardcore Terminalbenutzer: Die Verbindung (als root) mittels: “openconnect https://vpn.rrz.uni-hamburg.de” funktionierte. Das wäre also das Minimum.
  2. Für alle die den Komfort einer grafischen Oberfläche zu schätzen wissen, installieren:
    network-manager-openconnect-gnome bzw. network-manager-openconnect (KDE Nutzer, was ist das Richtige für Euch???)
    Danach mindestens Aus/Einloggen oder sogar neu booten, ansonsten klappte das Verbinden bei mir nicht!!!
  3. Zum EInrichten: Netzwerkeinstellungen starten, Neues VPN einrichten, “Cisco Anyconnect kompatible Verbindung (OpenConnect)” auswählen.
    Als Gateway: vpn.rrz.uni-hamburg.de
    Als CA-Zertifikat: Ich habe in Debian das vorinstallierte Telekom Zertifikat ausgewählt (/etc/ssl/certs/Deutsche_Telekom_Root_CA_2.pem). Das ist das gleiche Zertifikat das man auf der Downloadseite des RRZ unter dem Namen “Deutsche Telekom Root CA 2 Zertifikat” angeboten bekommt. Ich weiss aber nicht ob es notwendig gewesen ist hier überhaupt ein Zertifikat anzugeben (bitte Bescheid geben).
    Die restlichen Einstellungen kann man auf “deaktiviert” (Token-Modus) und “(keine)” (Zertifikate, …) lassen.
  4. Verbinden, dann wird nach User/Passwort gefragt, bei dem man die Uni Kennung angibt (nicht den STINE Nutzernamen).
  5. Bei einer VPN Verbindung lässt die Uni nur HTTP Verkehr über ihren eigenen Proxy zu, also muss man noch als Systemproxy: Server: proxy.uni-hamburg.de Port: 3128 einstellen. Es gibt auch ein Plugin für Firefox mit dem man Webproxies im Browser schnell umschalten kann.
  6. Profit.

P.S. Wer eine Lösung für Android gefunden hat, melde sich bitte oder hinterlasse einen Kommentar.