QtSoundModem & SystemD Autostart

Creating /home/pi/startqtsm

#!/bin/bash
# Change working directory to where QtSoundModem.ini is
cd /home/pi/bin

# Launch invisibly
# /home/pi/bin/piQtSoundModem nogui

# Comment out the below if using the above nogui option.

# Launch with GUI

# Set the display number here. If HDMI connected monitor, # this is usually :0
# For VNC sessions, this is determined in the desktop-
# check it with echo $DISPLAY in a shell within the VNC.

DISPLAY=:0
export DISPLAY
/home/pi/bin/piQtSoundModem

Setting permissions

chmod 755 /home/pi/bin/startqtsm

If using GUI mode, ensure it actually opens on your screen by running /home/pi/bin/startqtsm in a new terminal. If not, check your DISPLAY number again.

Installing necessary packages:

sudo apt install screen

Creating qtsm.service for systemd autostart

sudo nano /lib/systemd/system/qtsm.service

Insert the following into qtsm.service

[Unit]
Description=QtSoundModem Start Script by PE1RRR
After=network.target

[Service]
Type=forking
WorkingDirectory=/home/pi/bin
Restart=always
RestartSec=20
StartLimitInterval=60
StartLimitBurst=3
User=pi
Group=pi
ExecStart=/usr/bin/screen -S QTSM-Console -d -m /home/pi/bin/startqtsm
SyslogIdentifier=QTSM-Debug

[Install]
WantedBy=multi-user.target

Initiate the systemd intergration

sudo systemctl daemon-reload
sudo systemctl enable qtsm.service

Start QtSoundModem

sudo service qtsm start

If in GUI mode, QtSoundModem should appear on your desktop. For both GUI and nogui modes, a console is kept by the ‘screen’ application installed earlier, this is accessible with:

As user pi:

screen -r QTSM-Console

Or if feeling lucky:

screen -r QTSM

This will pattern match against running screen sessions.

Stopping QTSM

If you quit QtSoundModem, it’ll reopen 20 seconds later automatically, which might be intentional but if you want to stop it, you’ll need to stop the service:

sudo service qtsm stop

Disabling the service:

sudo service qtsm stop
sudo systemctl disable qtsm.service

Gotchas

If you have executed QtSoundModem as root prior, then the configuration file will have been changed to root ownership as well, this can be a nuisance if trying to reconfigure modems in the GUI as it won’t be able to retain settings. Force the ownership of the file to owner ‘pi’ with:

sudo chown pi:pi /home/pi/bin/QtSoundModem.ini

Soundcard Permissions

Usually user ‘pi’ is already a member of the audio /etc/group that provides access to the soundcard devices. If you are using a different user you will need to add them to the ‘audio’ group.

useradd -G audio <username>