# Blog

### Firefox: Enabling pixel scrolling with touchpads.

May 07, 2021 — ~redtrumpet

There is a bug in Firefox on Ubuntu that prevents precise scrolling when using a touchpad or a trackpoint. One way to fix[1] this is to start Firefox with MOZ_USE_XINPUT2=1 firefox, or put

MOZ_USE_XINPUT2=1


in /etc/environment.

[1] In fact this may trigger other bugs when a notification appears while scrolling.

tags: computers, documentation, ubuntu

### Enabling presentation mode via the command line

March 12, 2021 — ~redtrumpet

I recently added the following command to my ~/.profile

xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode -s false


It disables the xfce presentation mode on startup, because I frequently forget that I enabled it. The option -s true enables presentation mode, and -T toggles it. One can alse bind this to a key shortcut.

tags: computers, xfce, documentation

### Convert pdf to png with ImageMagick

February 27, 2021 — ~redtrumpet

ImageMagick allows an easy conversion between image files with the convert command. This also works with pdf-files, but by default the quality of a converted pdf-file will not allow one to read text. So fix this, use the -density option, adjusted to ones liking. I had good results with the following

convert -density 300 <file.pdf> <output.png>


Of course, one can also output to jpg or other file formats.

tags: pdf, convert, imagemagick, computers

### Automatically switch Xfce panel layout when pluggin in a monitor

February 02, 2021 — ~redtrumpet

This is my documentation of this blog post by Colin Robins. I’m quite thankful for his explanation, and really happy that it now works for me. His post is ~5 years old and I found a few things that don’t work exactly the same anymore. I tested everything on Xubuntu 20.04.

#### Panel configurations

The handy tool Xfce Panel profiles allows you to backup and export your different desired panel configurations. I named mine laptop.tar.bz2 and external-monitor.tar.bz2. You can load a different panel profile from the command line with

xfce4-panel-profiles load <profile>.tar.bz2


#### udev rule

udev is responsible for starting our service after connecting or disconnecting the external monitor. To use it we have write a udev rule, i.e. put the following into the file /etc/udev/rules.d/95-monitor-hotplug.rules

ACTION=="change", KERNEL=="card0", RUN+="/usr/bin/systemctl start hot_plug.service"


So I’m no expert on udev but AFAIK this tells udev to start the service hot_plug.service whenever there is a “change” concerning the video card output.

#### systemd service

So now we still have to write the systemd service hot_plug.service. Here are some basics about systemd services. To create our service write the following into the file /etc/systemd/system/hot_plug.service

[Unit]
Description=Monitor hotplug

[Service]
Type=simple
RemainAfterExit=no
User=jonas
ExecStart=/usr/bin/bash /usr/local/bin/hotplug_monitor.sh

[Install]
WantedBy=multi-user.target


Replace jonas by your username. So this service calls a script /usr/local/bin/hotplug_monitor.sh, which will do the actual work. For me this script is

#!/bin/bash

X_USER=jonas
export DISPLAY=:0
export XAUTHORITY=/home/$X_USER/.Xauthority export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus function connect() { xfce4-panel-profiles load /home/jonas/.config/xfce4-panel-profiles/external-monitor.tar.bz2 } function disconnect() { xfce4-panel-profiles load /home/jonas/.config/xfce4-panel-profiles/laptop.tar.bz2 } if [$(cat /sys/class/drm/card0-HDMI-A-1/status) == "connected" ] ; then
connect
elif [ \$(cat /sys/class/drm/card0-HDMI-A-1/status) == "disconnected" ] ; then
disconnect
else
exit
fi


Things you might want to adapt:

1. You should change X_USER to your username
2. I store the panel profiles in /home/jonas/.config/xfce4-panel-profiles/
3. Check if your external monitor is card0-HDMI-A-1. If you use VGA this might be something different.

If you want you can add other things that should be done when connecting the external monitor. I mostly use this with my Wacom tablet, so I also want to set the drawing area only on the tablet. So I added the line

# map the tablet input to the tablet's display
xsetwacom --set "Wacom One Pen Display 13 Pen stylus" MapToOutput HDMI-A-0


To change the button on the pen to right click instead of middle click I use

# map the button on the pen to right click
xsetwacom --set "Wacom One Pen Display 13 Pen stylus" Button 2 "button +3"


tags: computers, udev, systemd, xfce

### Sonos and Samba on Ubuntu 20.04

November 02, 2020 — ~redtrumpet

Googling around, one easily finds a bunch of complaints, that Sonos devices only support SMBv1, which is pretty outdated and supposedly insecure. If you use a recent Samba installation, SMBv1 is disabled by default, e.g. in Ubuntu 20.04. Most posts claim that putting the line

ntlm auth = ntlmv1-permitted

in the Samba configuration /etc/samba/smb.conf will reenable SMBv1, so that your Sonos can access your music library. I have found that this does not work, at least with Ubuntu 20.04. Maybe something was different with 18.04?

To enable SMBv1 on Ubuntu 20.04, you can use the line

server min protocol = NT1

This works, and you don't even need the ntlm auth parameter.

Thanks to Nelson, who wrote about the same thing in this blog post.

tags: sonos, computers

### Some power series

May 20, 2020 — ~redtrumpet

Today I studied genera, which provide a way to produce toopological invariants of manifolds. Genera are intimately related to invertible power series which start with $$1 + \dotsb$$. For example the common genus $$L$$-genus belongs to the power series of $\frac{x}{\tanh(x)}.$ The so called Â-genus looks even more intimidating, it belongs to the power series of $\frac{\sqrt{x}/2}{\tanh(\sqrt{x}/2)}.$ So this leaves the question: Why are those functions above analytic? Formally, they are not even defined at $$x = 0$$, because you end up with $$\frac{0}{0}$$. Nevertheless both functions are indeed defined at $$x = 0$$, and both are analytic, meaning that you can write them as a power series $\sum_{k=0}^\infty c_k x^k$ for certain coefficients $$c_k$$. I want to explain how to derive the power series representation, i.e. how to compute the $$c_k$$ for both series.

Let's start with unrolling the definitions: $\tanh(x) = \frac{\sinh(x)}{\cosh(x)},$ and $$\cosh$$ and $$\sinh$$ are defined by $\sinh = \frac{1}{2}(e^x - e^{-x}) \text{ and } \cosh = \frac{1}{2}(e^x + e^{-x}).$ Using the well-known series expansion of $$e^x$$, we can write $\sinh = \frac{1}{2}\left(\sum_{k=0}^\infty \frac{x^k}{k!} - \sum_{k=0}^\infty (-1)^k \frac{x^k}{k!}\right) = \frac{1}{2} \left(\sum_k \frac{x^{2k+1}}{(2k+1)!} \right)$ and $\cosh = \frac{1}{2}\left(\sum_{k=0}^\infty \frac{x^k}{k!} + \sum_{k=0}^\infty (-1)^k \frac{x^k}{k!}\right) = \frac{1}{2} \left(\sum_k \frac{x^{2k}}{(2k)!} \right).$ The next stop is to compute the

tags: math

### Some drawings

May 08, 2020 — ~redtrumpet

When this semester started during the Covid-19 pandemic, I got a Wacom graphics tablet to be able to discuss mathematics over the internet. But I also enjoyed playing around with it in Krita, which is a free drawing program. So here I want to share some of my drawings, in chronological order.

This palm tree was one of my first experiments with my new tablet, and I like how it turned out.

This faces where drawn for an art exchange I did with some friends.

This one is named Rotschopf, which is German for Redhead. It was supposed to represent one of my roleplaying characters, a male seer that knows some magic, but nothing too fancy. Unfortunately it turned out to be more feminine than anticipated. Nevertheless it inspired me to create this post.

tags: art

### KaTeX Test

May 01, 2020 — ~redtrumpet

Just some math tests: $$a^2 + b^2 = c^2$$. And so on $\int_a^b f(x) dx = F(b) - F(a)$

Let's see how basic number theory looks: $$a \mid b$$.

tags: math