Avoiding Select Audio Device Prompt on Dell XPS 15 under Ubuntu

Illustration

As a headphone user I find nothing more annoying than computer asking me every single freaking time what exactly did I plug in. While Windows drivers for Dell XPS 15 audio do allow you to select default, one is not so lucky under Linux.

However, Linux being configurable to a fault does offer a workaround.

You can append the following options to the end of /etc/modprobe.d/alsa-base.conf, followed by a reboot:

options snd-hda-intel model=headset-mic

This will lie a bit to sound driver and stop the darn questions.


PS: You can also use this one liner:

echo "options snd-hda-intel model=headset-mic" | sudo tee -a /etc/modprobe.d/alsa-base.conf

QSystemTrayIcon Not Showing Under Ubuntu

I wanted a simple system tray application that would work on both Windows and Linux. As C# doesn’t really have a proper GUI for Linux (albeit you can come a long way using Windows Forms), I decided to go with QT.

Showing system tray was really easy:

_tray = new QSystemTrayIcon(this);
connect(_tray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
         this, SLOT(onTrayActivate(QSystemTrayIcon::ActivationReason)));

_tray->setIcon(trayIcon);
_tray->setToolTip(QCoreApplication::applicationName());
_tray->show();

Under Windows it worked beautifully. Under Ubuntu - not so. QT example for tray icon was pretty much equivalent and it worked flawlessly. But my simple example just wouldn’t. It took me a while but I traced the issue.

Upon click I wanted to display a context menu. It seemed innocent enough to dynamically create it:

void MainWindow::onTrayActivate(QSystemTrayIcon::ActivationReason reason) {
  switch (reason) {
    case QSystemTrayIcon::Context: {
      QMenu menu(this);
      menu.addAction("&Show", this, SLOT(onTrayShow()));
      menu.addSeparator();
      menu.addAction("E&xit", this, SLOT(onTrayExit()));

      menu.exec(QCursor::pos());
    } break;

    case QSystemTrayIcon::DoubleClick: {
      onTrayShow();
    } break;

    default: break;
  }
}

And this works under Windows. But Ubuntu and it’s Unity GUI don’t really know what to do with tray icon without preassigned context menu. And thus tray icon is never actually displayed.

Once I figured that out, solution was simple. Just assign menu statically:

_tray = new QSystemTrayIcon(this);
connect(_tray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
         this, SLOT(onTrayActivate(QSystemTrayIcon::ActivationReason)));

QMenu* trayMenu = new QMenu(this);;
trayMenu->addAction("&Show", this, SLOT(onTrayShow()));
trayMenu->addSeparator();
trayMenu->addAction("E&xit", this, SLOT(onTrayExit()));
_tray->setContextMenu(trayMenu);

_tray->setIcon(trayIcon);
_tray->setToolTip(QCoreApplication::applicationName());
_tray->show();

Installing DropBox on ZFS

While I already wrote about expanding DropBox’s Ext4 volume on ZFS, I never actually wrote how to create one in the first place. I guess it’s time to fix that injustice.

First you need to create a volume of sufficient size. While you can just make it as big as your Dropbox allowance is, I would advise going with at least double of that. Not only this helps if you are doing ZFS snapshots (remember it’s copy-on-write) but it also helps if you are moving files around as Dropbox fully releases space only once the new files are created.

Whatever you decide, you need to create a volume and format it:

sudo zfs create -V 12G ^^pool^^/dropbox
sudo mkfs.ext4 /dev/zvol/^^pool^^/dropbox

Once volume is created, mounting the newly created volume within our user directory is in order:

mkdir /home/^^user^^/Dropbox
sudo mount /dev/zvol/^^pool^^/dropbox /home/^^user^^/Dropbox
sudo chown -R ^^user^^:^^user^^ Dropbox

Of course, to retain it between reboots one should add it to fstab:

echo "/dev/zvol/^^pool^^/dropbox /home/^^user^^/Dropbox ext4 defaults,_netdev 0 0" | sudo tee -a /etc/fstab

Do note the _netdev part as it ensures dropbox volume is mounted way after ZFS has already done so. Without it you might have a race condition and volume mounting might prevent subpools to be mounted under the same path.

Finally you can install Dropbox as you usually would. While it will complain about directory already being present, you can simply cancel directory selection and it will start syncing regardless.

Congratulations, your Dropbox is now on ZFS.

DaVinci Resolve and MP4 under Linux

If you try to import mp4 file to DaVinci Resolve under Linux, you will be greeted with audio-only experience if you’re lucky or nothing at all if you’re not. Unless you’re paying customer of DaVinci Resolve Studion, MP4 and AAC are not supported at all.

Conversion to an intermediate format is needed and good old ffmpeg can help here:

ffmpeg -i ^^input.mp4^^ \
    -c:v dnxhd -profile:v dnxhr_hq -pix_fmt yuv422p \
    -c:a pcm_s16le \
    -f mov ^^output.mov^^

Here I use DNxHR with HQ settings. Even this will generate file that’s much bigger than source. How much bigger depends on the source, but don’t be surprised to see it grow 16-fold or even higher.

Smaller alternative can be MPEG4 format but with a drop in quality even at its best settings:

ffmpeg -i ^^input.mp4^^ \
    -c:v mpeg4 -qscale:v 1 \
    -c:a pcm_s16le \
    -f mov ^^output.mov^^

These files can now be used as input to Resolve and editing can commence.

Once done with rendering a conversion to MP4 might be in order again. For this I use settings discussed on Video StackExchange. While the original discussion was for YouTube, I find their recommendations quite good as a starting point:

$ ffmpeg -i ^^render.mov^^ \
    -c:v libx264 -pix_fmt yuv420p -crf 16 \
    -force_key_frames 'expr:gte(t,n_forced/2)' -bf 2 \
    -vf yadif -use_editlist 0 \
    -movflags +faststart \
    -c:a aac -q:a 1 \
    -ac 2 -ar 48000 \
    -f mp4 ^^out.mp4^^

Mind you, all my cameras use YUV 4:2:0 and I don’t do any major editing so increasing YUV to 4:2:2 or even 4:4:4 makes no sense nor does increase to 10-bit resolution. Depending on which equipment you have, your mileage may vary.

Installing DaVinci Resolve on Ubuntu Dell XPS

When I first installed DaVinci Resolve on my Dell XPS under Ubuntu 19.04 I was greeted with stuck splash screen. What was I missing?

Well, the first issue was missing OpenCL. Fortunately that was easy to solve:

sudo apt install ocl-icd-opencl-dev

Other issue was missing nVidia driver. For some reason Resolve really dislikes nouveau driver. Therefore we have to upgrade driver a bit. I found that auto-install works perfectly for me:

sudo ubuntu-drivers autoinstall

Those who like to be more precise can always check which drivers are available and install only those:

ubuntu-drivers devices
 == /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
 modalias : pci:v000010DEd00001C8Dsv00001028sd000007BEbc03sc02i00
 vendor   : NVIDIA Corporation
 model    : GP107M [GeForce GTX 1050 Mobile]
 driver   : nvidia-driver-390 - distro non-free
 driver   : nvidia-driver-418 - distro non-free recommended
 driver   : xserver-xorg-video-nouveau - distro free builtin

sudo apt install nvidia-driver-418

With these two changes my DaVince Resolve can finally start properly.


PS: Interestingly, installing non-free nVidia driver solved Ubuntu getting stuck booting after incorrect password got entered.