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"

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:

    #!/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.

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.

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 = 

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 upgrade to 3.3.x 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/pule 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.