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.

Further adaptions

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