dt.iki.fi

Sailfish OS ‑ Command Line Interface & Customisation

This article has a parent article. It contains some preliminaries to the topics here.

Doing Things on the Command Line-up-

MTP (the same protocol Android devices use) will expose the /home/nemo folder to the connecting computer, both to graphical and command line applications. But it hides some files and folders from the connected system.

A more powerful way is to connect through a terminal via SSH, as explained here.

The phone's shell and my beloved URxvt terminal emulator have difficulties communicating. I installed xterm on my computer and am using this to connect to the phone. Works perfectly.

Of course one can always use the terminal app directly on the phone. It gives full access to the system via devel-su, just as via SSH.

nano-up-

On your phone, you might want to install nano, a useful & ubiquitous CLI editor:
devel-su pkcon install nano

It does not come with a nanorc file; I recommend copying one from another machine and moving it to /etc/nanorc. That way settings apply to all users. Make sure to enable syntax highlighting by adding this line:
include "/usr/share/nano/*.nanorc"

sqlite3-up-

To view & edit SQLITE databases directly on the phone. The sqlite3 executable is not installed, but the package sqlite is available. It does not show up in either Jolla or Openrepos appstores, but you can install it like this:

[root@Your_Phone]# pkcon install sqlite

SSHFS-up-

SSHFS can mount part of a remote filesystem locally via ssh.

On SailfishOS this means that I can listen to music or watch video straight from that remote location - no more media servers! In fact I can access all files with both GUI and CLI applications.

Here's how:

First, try to get normal ssh working from your phone to a server, preferably passwordless with an authentication key. Once this works reliably:

  • Install sshfs-fuse-2 (OpenRepos/Storeman). Don't be alarmed by its age, it uses SailfishOS' very own ssh binary to make a secure connection!

  • formulate a suitable command or use a toggle script like this one:

    sh
    #!/bin/bash exec 2>&1 # dependency checks for dep in mount grep sshfs ssh fusermount; do command -V $dep >/dev/null || exit 1 done mountdir="/home/nemo/server" # just an example location="remote_user@domain_or_IP:/path/to/dir" port=XXX # preferably something other than 22! identity="/home/nemo/.ssh/your_server_s_key_file" sshfs_options="follow_symlinks,ServerAliveInterval=15,reconnect,\ IdentitiesOnly=yes,IdentityFile=$identity,port=$port,\ compression=yes,debug,sshfs_debug,loglevel=debug" if [[ $(mount|grep -o "$mountdir") == "$mountdir" ]] then echo "$mountdir is already mounted. Unmounting..." fusermount -u -z "$mountdir" exit 0 fi if sshfs -C -o "$sshfs_options" "$location" "$mountdir" & then echo "Mounted $location on $mountdir" echo "Run $0 again to terminate connection." exit 0 else echo "Mounting $location failed" fusermount -u -z "$mountdir" exit 1 fi

Executing the script the first time will mount, executing it another time will unmount. It's very chatty, if you need to use the terminal it was started in you might want to remove all three debug options.

Ambiences-up-

Ambiences can be quickly created from images/photos, but I find this process a little lacking: images are resized in a way that can reduce their quality, and I do not have enough control over the colours used.
The default ambiences are stored in /usr/share/ambience. They are simple folders with a configuration file (*.ambience), a background image and optionally also sounds.
Everything is straigthforward. You can create your own ambiences from scratch, however they need to be stored in /usr/share/ambience, I have not found a way to store them anywhere under /home/nemo.

Here's an example:

$> ls /usr/share/ambience/white-on-black/*
/usr/share/ambience/white-on-black/white-on-black.ambience
/usr/share/ambience/white-on-black/images:
white-on-black.png
$> cat /usr/share/ambience/white-on-black/white-on-black.ambience
{
    "displayName"               : "White on Black",
    "wallpaper"                 : "black.png",
    "highlightColor"            : "#ffffff",
    "secondaryHighlightColor"   : "#dddddd",
    "primaryColor"              : "#ffffff",
    "secondaryColor"            : "#aaaaaa",
    "ringerVolume"              : 100,
    "colorScheme"               : "lightondark",
    "favorite"                  : true,
    "timestamp"                 : "2021-09-19T10:00:00",
    "version"                   : 3
}

The image should be the height of your phone's screen, and square. In my case: 1920x1920px.

You will need to be root (devel-su) to create & edit these files & folders.
There's also an option to create a package directly on your phone, but I haven't gone to such lengths.

When ready, restart the ambience daemon: systemctl --user restart ambienced.

Also have a look at the other .ambience files:

Disable High Volume Warning-up-

Disclaimer: be aware that doing this you remove a safety feature and could damage your hearing. Use at your own risk.

It's the same idiotic warning one also gets on Android phones when listening on headphones (or anything pugged into the audio jack). It blocks raising the volume above a certain level until some sort of OK button is tapped. Listening to audio while cycling, this gets very annoying, because it kicks in seemingly randomly once or twice a day.

To get rid of it, you can install Patchmanager 3.0 and select "Disable High Volume Warning" from the Web catalog, install it, then Apply.
Since the last OS-update (4.0.x) there does not seem to be a suitable patch anymore.
Patchmanager is now in CHUM (compatible with 4.4.0.64 as of right now) and the "Disable High Volume Warning" is found in the Web catalog.

Other Methods-up-

To completely disable it, edit /etc/pulse/mainvolume-listening-time-notifier.conf (also see "SSH" and "Becoming root" from the main article). Replace

mode-list = lineout,hs

with

#mode-list = lineout,hs
mode-list = 

Alternatively you can also comment out every line in the file, or move it to a place where pulseaudio does not see it anymore, e.g.:

mv /etc/pulse/mainvolume-listening-time-notifier.conf ..

And reboot.

Source.

It appears to be completely gone after that, I can always raise the volume as high as it goes, but I cannot shake the feeling that the maximum volume sometimes doesn't go as high as it used to. I still have a lot to learn about pulseaudio, especially on this device. In any case, after the latest upgrade this change was gone. I'm taking the chance to try something different.

Collection of Notes-up-

I found this pastebin (archive) with a gdb of pulseaduio. It shows me which module loads the config file in question and what it does with it:

D: [pulseaudio] module-meego-mainvolume.c: Read long listening time notifier config from /etc/pulse/mainvolume-listening-time-notifier.conf
D: [pulseaudio] conf-parser.c: Parsing configuration file '/etc/pulse/mainvolume-listening-time-notifier.conf'
D: [pulseaudio] module-meego-mainvolume.c: Notifier conf role-list add: "x-maemo"
D: [pulseaudio] module-meego-mainvolume.c: Notifier conf mode-list add: "lineout"
D: [pulseaudio] module-meego-mainvolume.c: Notifier conf mode-list add: "hs"
D: [pulseaudio] listening-watchdog.c: Restore counter value 0 minutes (0 seconds)
D: [pulseaudio] module-meego-mainvolume.c: Long listening time notifier setup done.

Not that I understand very much, but I wonder what will happen if i simply remove/rename that file. A search for listening-watchdog finds a file in ~/.config/pulse with a .simple extension. It is not plain text, I have no idea what to do with it.
There is some documentation about pulseaudio modules.

It is possible to install gdb, as well as alsa-utils:

pkcon install gdb alsa-utils

Alsamixer is unusable but I can get some information through aplay, amixer etc.

mce-tools-up-

Tools for interacting with mce (Mode Control Entity).

#> zypper install mce-tools

Provides the command line tool mcetool which allows to set and read various - well, modes on your phone.
Try mcetool -h.
E.g.: disable lock screen animation:

$> mcetool --set-lockscreen-animation=disabled