User:Magdesign

From postmarketOS Wiki

Creator of the opensource multimedia server https://pocketvj.com

Opensource nomad cycling the world since September 2022.

The idea to travel the world with an opensource phone died after hacking a year on pinephone and librem5 and a month before leaving, the pinephonepro started to melt on the backside...

I really do like to write documentation/howto/wiki and therefore I'd love to be a part of PostmarketOS community. Believe it or not, all the stuff is written on my pmos or my android phone, even the scripts, which took a lot of time and nerves. If you read this, drop me a line, it motivates me to know that you read the page here... xmpp: magdesign@conversations.im

Love and hate my OP6 running sxmo (daily driving since 3. Feb. 24).

Spent some time with droidian/phosh to have a camera, but phosh is really not my thing, i want to be able to create and fix stuff fast and easy and i love simple terminal pplications a lot.

podcast: https://cast.postmarketos.org/episode/39-Interview-magdesign/

git: https://codeberg.org/magdesign/

masto: @pocketvj@fosstodon.org

gemini://magdesign.flounder.online/index.gmi

about our travels:

https://pixelfed.socia/cyclingtogether

https://odysee.com/@sharinggoodmoments

  ____   ____ __  __  ___  ___  
/' _| \_/ /  V  |/__\| _,\/ __| 
`._`.> , <| \_/ | \/ | v_/ ,_ \ 
|___/_/ \_\_|_|_|\__/|_|  \___/ 
| | | || | |/ / |               
| 'V' || |   <| |               
!_/ \_!|_|_|\_\_|               

Owns devices

Device Notes
OnePlus 6 (oneplus-enchilada) sxmo, daily, many hacks


Userscripts

I wrote some useful scripts.

Use the installer 🤓

Work Around the Notch

Just add some random stuff to the bar.

First:

cp /usr/share/sxmo/default_hooks/sxmo_hook_statusbar.sh ~/.config/sxmo/hooks/


then add a few ooooo between the battery and the wifi symbol just above the line containing sxmobar -a -f "$fgcolor" -b "$bgcolor" -t "$style" \

with adding this line to the hook:

sxmobar -a notch 22 oooooooooo

Then disable tray icons in swaybar:

nano ~/.config/sxmo/sway

Scroll down to the Status Bar: section and just below position top add tray_output none


Then reboot and enjoy.

Set Darkmode

For Gnome apps:

gsettings set org.gnome.desktop.interface color-scheme prefer-dark


For Kde plasma-mobile apps:

sudo apk add plasma-integration

sudo apk add qqc2-breeze-style

Get the style file here.

Move it to where it belongs:

mv kdeglobals ~/.config

Now we need to set the environment variables (not sure if we need this, pasted once into terminal):

QT_QUICK_CONTROLS_STYLE=org.kde.breeze QT_QPA_PLATFORMTHEME=kde

thanks to user: x-m7


For Flatpaks

some flatpaks just refuse to run in dark mode, edit the launcher of each flatpak to contain the dark theme like this:

flatpak run --env=GTK_THEME=Adwaita:dark org.gnome.Fractal


Gtk apps can be forced with a prefix:

GTK_THEME=Adwaita:dark application 

Manage App Menu

Some stuff exist only as a flatpak, but it will not show in application menu... simply change in nano ~/.config/sxmo/hooks/sxmo_hook_apps.sh :

write_line_app() {
        executable="$1"
        label="$2"
        command="$3"
        if command -v "$executable" >/dev/null; then
                write_line "$label" "$command"
        fi

to:

write_line_app() {
        executable="$1"
        label="$2"
        command="$3"
        if command -v "$executable" >/dev/null; then
                write_line "$label" "$command"
        elif ls /var/lib/flatpak/app/"$executable" >/dev/null; then
                write_line "$label" "$command"
        fi

and add e.g. Flare like this:

write_line_app de.schmidhuberj.Flare "$icon_msg Flare" "flatpak run de.schmidhuberj.Flare"

Manage Menu's (Volup_one)

Copy the contextmenu hook to your user:

cp /usr/share/sxmo/default_hooks/sxmo_hook_contextmenu.sh ~/.config/sxmo/hooks/sxmo_contextmenu.sh

Then edit this copy.


For example to remove the Binaries from the System Menu, go down to: # Default system menu (no matches)

and remove the whole line containing $icon_grd Binaries.



Application specific Context Menu's

Can be really handy to set the most used shortcuts of a specific app.

In this example we add a menu for Krita with the most used commands.


we scroll to the block containing Firefox, and add a new one:

*krita*)
		# Krita
		CHOICES="
			$icon_fnd Open                   ^ 0 ^ sxmo_type -M Ctrl o
			$icon_sav Save                   ^ 0 ^ sxmo_type -M Ctrl s
			$icon_pst Paste                  ^ 0 ^ sxmo_type -M Ctrl v
			$icon_del Delete                 ^ 0 ^ sxmo_type -k Delete
			$icon_win Select                 ^ 0 ^ sxmo_type -M Ctrl r
			$icon_modem_disabled Deselect    ^ 0 ^ sxmo_type -M Ctrl -M Shift a
			$icon_wn2 Crop                   ^ 0 ^ sxmo_type c
			$icon_flt Fill                   ^ 0 ^ sxmo_type f
			$icon_modem_connected Gradient   ^ 0 ^ sxmo_type g
			$icon_dof HSV Adjust             ^ 0 ^ sxmo_type -M Ctrl u
			$icon_cls Close Image        	 ^ 0 ^ sxmo_type -M Ctrl w
		"
		WINNAME=Krita
		;;

Note: somehow i was not able to make Scale Image to New Size Ctrl + Alt + I; Resize Canvas and Enter working.



Copy content of SMS

(e.g. to copy into translator)

Search to block containing:

grep -qi -w "sms\|missed

and just above

$icon_aru Scroll up '


you add:

 $icon_cpy Copy        ^ 0 ^ sxmo_type -M Shift -M Ctrl c  

vim vs. nano vs. micro

change the standard to write sms..

export EDITOR="micro"

in

.config/sxmo/profile

Block callers

WIP

block annoying numbers in:

/usr/bin/sxmo_modem.sh

around line 130 is something called $SXMO_BLOCKFILE

so you can create a

 ~/.config/sxmo/block.tsv 

file containing the numbers to be blocked and it should work, right?

and here you find a basic call writeup.

Tor

Since there is no Tor-Browser in PostmarketOS

sudo apk add tor

sudo cp /etc/tor/torrc.sample /etc/tor/torrc

sudo service tor start

check if it is running with: sudo netstat -tunlp | grep tor

in Firefox Network Settings Select:

 Manual proxy configuration
 SOCKS Host 127.0.0.1  Port 9050

Tick the Proxy DNS when using SOCKS v5

For autostart Tor on boot:

sudo rc-update add tor default

This however, will not work in a country which Censors Tor connections, e.g. Iran, China...

You need to get obfs4proxy, its package name is lyrebird and you have to build it yourself.

Since you might not be able to access the official repo take my pre-built package, make lyrebird executable and copy it to /usr/local/bin/lyrebird try quickly if you can run it, if yes, it will throw an error like: lyrebird - must be run as a managed transport

Next make sure /etc/tor/torrc contains:

Log notice file /var/log/tor/notices.log
DataDirectory /var/lib/tor
ClientTransportPlugin obfs4 exec /usr/local/bin/lyrebird

then start or restart tor:

sudo rc-service tor start 

watch the log file while it tries to circumvent censorship:

sudo tail -f /var/log/tor/notices.log 

try in your configured browser. GOOD LUCK!

VPN

There is an issue in ModemManger which will not route your GSM traffic through VPN, so VPN is only working over Wifi!

When trying to fix this, you need to manually disable the default route through qmapmux0.0, but modemmanger automatically creates this route again.

No fixes for this right now...


Install OpenVPN support:

sudo apk add networkmanager-openvpn


Add OpenVPN setting:

sudo nmcli connection import type openvpn file /path/to/vpnfile.ovpn

Add username:

sudo nmcli connection modify $vpnname +vpn.data username=$myname

Add password:

sudo nano /etc/NetworkManager/system-connections/yourvpnname

if not there, add:

[vpn-secrets]

password=yourpassword

If password changes, use:

sudo nmcli connection modify $vpnname +vpn.secrets password=$password

Make sure that password-flags=0

Enable the connection (--ask if password is not stored):

nmcli connection up $vpnname

or

Enable the connection with grafical interface:

nmtui

Select it and enter password.

Hotspot

There is a bug or sourcehutthat you can not connect to hotspot of your pmos device with a modern device. The workaround is to create the hotspot from commandline and disable pmf or fix the /usr/bin/sxmo_networks.sh script with adding this on around line 219:

notify_sucess "Adding hotspot wifi" \
                nmcli device wifi hotspot ifname wlan0 con-name "Hotspot $SSID" \
                ssid "$SSID" channel "$channel" band bg password "$key"
                nmcli con down "Hotspot $SSID"
                nmcli c modify "Hotspot $SSID" 802-11-wireless-security.pmf 1
                nmcli c modify "Hotspot $SSID" wifi-sec.pmf disable
                nmcli con up "Hotspot $SSID"

Captive Login Page

When connecting to an internet with a captive login page, but its not shown, type in Firefox addressbar:

neverssl.com

GPS

If there is a SIM card inserted: Enable Modem GPS

mmcli -m any --location-enable-gps-nmea

mmcli -m any --location-enable-gps-raw 

mmcli -m any --location-get 


make GPS available to apps:

/usr/libexec/geoclue-2.0/demos/agent


sxmo userscript to launch pure-maps and osmin with gps & geoclue you find here.

Pure-Maps You need pure-maps and osmscout-server

After install execute osmscout-server-gui and download some maps. You need to get API-keys with registering on all the map provider service,it takes a moment, but is easy. When all done you can run pure-maps with the launcher-script. For offline navigation, first launch osmscout-server, wait a few seconds, then launch pure-maps. To find drinking water, dont use the search window, use Nearby venues from the menu.

If there is no SIM card inserted or/and modem deactivated mmcli will not work.

In this case:

ModemManager

to have gps without sim and powersaving... keep in mind that there are more gps mods todo, see below:

git clone https://gitlab.freedesktop.org/mobile-broadband/ModemManager.git
cd ModemManager
meson setup build --prefix=/usr --sysconfdir=/etc -Dbash_completion=false --buildtype=release -Dsystemd_suspend_resume=false -Dsystemd_journal=false -Dpowerd_suspend_resume=false -Dsystemdsystemunitdir=no

ninja -C build

sudo ninja -C build install

stuck with: need 'mbim-glib' ['>= 1.31.2'] found '1.30.0'

so we need to build this too...

sudo apk add gobject-introspection-dev help2man dbus-dev libgudev-dev polkit-dev libqmi-dev 

git clone https://gitlab.freedesktop.org/mobile-broadband/libmbim.git
cd libmbim

meson setup build --prefix=/usr -Dbash_completion=false

ninja -C build

sudo ninja -C build install

Location without Sim

we need modemmanger v1.23.4 or newer to get this working (see above). Then:

sudo apk add gnss-share gnss-share-geoclue
sudo rc-service gnss-share start

In /etc/geoclue/geoclue.conf set:

# Enable Modem-GPS source
enable=false

and in /etc/gnss-share.conf set:

device_driver="mm"

to check install and run the 'Satellite' app via flathub:

sudo flatpak install flathub page.codeberg.tpikonen.satellite

flatpak run --env=GTK_THEME=Adwaita:dark page.codeberg.tpikonen.satellite


Notes:

should we add the service to boot and rewrite geoclue.conf to /var/run/gnss-share.sock instead of gps-share.sock

https://gitlab.com/postmarketOS/gnss-share/-/merge_requests/15

https://gitlab.com/postmarketOS/gnss-share/-/merge_requests/17

Thanks to tpikonen for all the help!

Pure-Maps Style Tuning

WIP

Pure-maps does not show city names in the default offline mode. To change this, edit

/usr/share/osmscout-server/styles/mapboxgl/styles/osmbright.json


change under "id": "place-city"

"minzoom": 1,
"maxzoom": 18,

this will show the city names in zoomlevel 14.49 to 18

we still dont see it at lower levels, which i might find out one day hopefully...

note: select offline, type= default

the issue seems to be caused while importing the tiles we also need to import other zoom levels (after talking with rinigus on matrix).

check here whats going on:

https://github.com/rinigus/osmscout-server/blob/master/scripts/import/mapbox/run_planetiler.sh

https://github.com/onthegomap/planetiler


when solved, document in puremaps forum and github!

Osmin Style Tuning

WIP

we edit the cycle stylesheet to always show drinking waterspots

lets edit:

/usr/share/osmin/resources/stylesheets/cycle.oss

add

  [TYPE amenity_drinking_water] {
     NODE.ICON { name: drinking_water; }
     AREA.ICON { name: drinking_water; }
   }

we also need to make the symbol bigger and visible on all scaling layers...

Podman / Docker Installation

sudo apk add podman

sudo rc-update add cgroups

#remove folder so it will be created with the right permission on first run:
sudo rm -rf $HOME/.local/share/containers/storage

sudo touch /etc/subuid
sudo touch /etc/subgid

sudo usermod --add-subuids 100000-165535 --add-subgids 100000-165535 $(whoami)

-- reboot or logout/login  --

Offline Translation

Offline Translator LibreTranslate, was not able to make them run because of fucking censorshit (guys, please fix the vpn-gsm issue), however it works:

git clone https://github.com/LibreTranslate/LibreTranslate.git

cd LibreTranslate

# replace docker commands with podman:
sed -i 's/docker/podman/g' run.sh

sudo chmod +x run.sh

./run.sh --update --load-only en,de,fr,tr

# limit languages:
# the --update is a flag to update the language packs
#for other languauges see here: https://libretranslate.com/?source=tr&target=en&q=


Be aware that this will suck quite a bunch of data (i just emptied my data plan with this...)

After starting, visit with a browser:

http://0.0.0.0:5000

or use this script, change the url to http://localhost:5000/translate to easy query from terminal.

create a handle to start from apps menu hook:

write_line_app podman "$icon_edt LibreTranslate" "sxmo_terminal.sh ~/LibreTranslate/run.sh"

the podman entry is a bit of a hack, otherwise we have to add a variable to check which containers are installed, which is just too slow.

Offline Speech-to-Text

In 2024 they destroied the free internet and it turned out that the new online is offline, similar as it was with computers back in the 90ies, they ran without internet...

https://github.com/ideasman42/nerd-dictation

Install with:

sudo apk add sox
sudo apk add py3-srt --repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing
sudo apk add py3-vosk-api
git clone https://github.com/ideasman42/nerd-dictation.git
cd nerd-dictation
wget https://alphacephei.com/kaldi/models/vosk-model-small-en-us-0.15.zip
unzip vosk-model-small-en-us-0.15.zip
mv vosk-model-small-en-us-0.15 model
mkdir -p ~/.config/nerd-dictation
mv ./model ~/.config/nerd-dictation/
cp ~/sxmop6/configs/nerd-dictation.py
 ~/.config/nerd-dictation/


We need dotool to type stuff:

sudo apk add dotool
sudo udevadm control --reload && sudo udevadm trigger

Set the buttom microphone as default input (this may vary depending of your hardware and os version on stable it was hw:0,3 check with arecord -l

export AUDIODRIVER=alsa
AUDIODEV='hw:0,1'

To run:

./nerd-dictation begin --simulate-input-tool=DOTOOL --input=SOX

# Start speaking..

./nerd-dictation end

Get the launcher script here


copy [1] configuration file to enable punctuation to:

 ~/.config/nerd-dictation/nerd-dictation.py

to type 'enter' instead of writing it, add something to the config file.

To do:

  • add 'Enter' word as keystroke (~/.config/nerd-dictation/nerd-dictation.py or see examples on github)

Modify the keyboard to have a button (see below)

Offline Text-to-Speech

sudo apk add piper-tts
sudo apk add py3-piper-tts

Note: i had to manually remove piper in /usr/lib/python3.18/... and then reinstall via apk to get it running without complains


Download voices in the needed language here and locate them in structured folders:

mkdir -p ~/piper/models/en

Now test a realtime example:

echo 'This is running on postmarktOS.' | \
/usr/bin/piper --model $HOME/piper/models/en/en_US-lessac-medium.onnx --config $HOME/piper/models/en/en_en_US_lessac_medium_en_US-lessac-medium.onnx.json --output-raw | aplay -r 22050 -f S16_LE -t raw -


Note:

I made a launcher to read out loud what ocr_roi sees.

Next is to pipe other outputs to read out load, but dont know how yet.

Keyboard Modifications

git clone https://github.com/jjsullivan5196/wvkbd
sudo apk add wayland-dev pango-dev libxkbcommon-dev

cd wvkbd
micro layout.mobintl.h

go to // Emojis and make your modifications

 🚴 0x1F6B4
 🤓 0x1F913
 🤷‍ 0x1F937
 🚀 0x1F680
 🍷 0x1F377  
 🍺 0x1F37A  
 🔥 0x1F525
 🚲 0x1F6B2
 🌡️ 0x1F321
 🏕️ 0x1F3D5
 🫶 0x1FAF6


or just pull my custom file.

make
sudo make install

voila, all done.

To add new buttons to trigger stuff, we have to work with key combos and then define them in ~/.config/sxmo/sway

For the moment its not possible to trigger scripts directly or make longer than two-key combos, which might hopefully change once.


Lets do it like this:

In layout.mobintl.h search for:

{"Special", "Special", 1.5, Layout, 0, &layouts[Special]

replace or add a new line:

 {"󰍽", "󰍽", 1.0, Code, KEY_7, 0, Super},
  {"󰍬", "󰍬", 1.0, Code, KEY_8, 0, Super},

Note: the first two 󰍬 symbol ate the mouse, the others the mic cat /usr/share/sxmo/default_hooks/sxmo_hook_icons.sh | grep mic

make and install as written above.

Now we need to change the entry in ~/.config/sxmo/sway to trigger the nerd dictation toggle script, scroll down to:

# Workspaces:

   bindsym $mod+7 workspace number 7
   bindsym $mod+8 workspace number 8

and rewrite them to:


bindsym $mod+7 exec ~/sxmo-userscripts/launchers/touchpademulator_launcher.sh 

bindsym $mod+8 exec ~/sxmo-userscripts/launchers/dictation_launcher.sh

restart sway.

get the dictation launcher script, the touchpad launcher in the sxmop6 repo.

Note:

should we create a whole line of tools, including screenshot, ocr_roi, qr reader? i think this would be nice!

Make sure you build and install TouchpadEmulator as written below:

Touchpad Simulator

Sometimes its nice to have a mousepointer to handle desktop apps or for precision work.

As written above, we can then trigger this via keyboard! This section is about installing the patched TouchpadEmulator (thx2 fdelamotte) in pmos/sxmo. edit: there seems to be a click and drag issue in the patch

git clone https://gitlab.com/CalcProgrammer1/TouchpadEmulator.git
cd TouchpadEmulator
rm TouchpadEmulator.c
wget https://codeberg.org/magdesign/sxmo-userscripts/raw/branch/main/patches/touchpademulator/TouchpadEmulator.c
sudo apk add dbus-dev dbus-glib-dev
make
sudo make install
sudo modprobe uinput
sudo chmod 777 /dev/uinput

You are good to go. I know its not very nice to give full rights to uinput, maybe you have a better way to do it.

Set default applications

e.g. Define which app displays images sudo nano ~/.config/mimeapps.list

edit:

image/png=loupe.desktop

image/jpg=loupe.desktop

make sure you create a desktopfile for loupe in:

nano ~/.local/share/applications/loupe.desktop

containing:

[Desktop Entry]
Type=Application
Terminal=false
Exec=/usr/bin/loupe
Name=loupe
MimeType=image/png;image/jpg


maybe there can also be some settings made in:

/usr/bin/sxmo_open.sh

Allow Flatpak / e.g. Fractal to access folder

sudo flatpak override org.gnome.Fractal --filesystem=/home/me/

Modify Homescreen

Change the position of the clock on Homescreen:

 ~/.config/sxmo/conky.conf 

see the various configs here.

to put it to the right buttom edge, we modify alignment = 'middle_middle',

to:

alignment = 'bottom_right',

Just for fun, you can also add the info of the free available diskspace and the powerlevel:

 
${alignc}${font Sxmo:size=12}${exec df -h | awk '/root/ { print "Free: " $4 }'}
${alignc}${font Sxmo:size=12}${exec echo "Power:"}${exec upower -d | grep -m1 'percentage:' | awk '{print $2}'}

Get my custom conky.conf which shows status of modem, battery, data usage, networkspeed...

Networks Menu

to add a Disable GSM function, edit: /usr/bin/sxmo_networks.sh add:

togglegsm() {
                        if nmcli radio wwan | grep -q "enabled"; then
                                sxmo_notify_user.sh "Disabling GSM"
                                nmcli radio wwan off 
                        else
                                sxmo_notify_user.sh "Enabling GSM"
                                nmcli radio wwan on
                        fi
}

below $icon_cfg Nmtui add following code to toggle the menu entry:

$(
        if nmcli radio wwan | grep -q "enabled"; then
                printf "%s GSM Disable\n" $icon_modem_disabled
        else
                printf "%s GSM Enable\n" $icon_modem_registered
        fi
)

and

                        *"Nmtui" )
                                sxmo_terminal.sh nmtui || continue # Killeable
                                ;;
                        *"GSM Disable"|*"GSM Enable" )
                                togglegsm
                                ;;

and to share our wifi credentials we make another entry just before Ifconfig EOF:

$([ -z "$WIFI_ENABLED" ] || printf "%s Show Credentials\n" "$icon_wif")

and below, after the *"Scan Wifi Networks" ) block, we add:

sxmo_terminal.sh -- bash -c "nmcli dev wifi show-password; read -p 'Press enter to close';" 

Screen Color Adjustment

This are just notes of an unfinished journey. I tried so far without luck:

wl-gammrelay, wl-gammarelay-rs, wlsunset, gammastep, wlr-randr

for example:

gammastep -O 5000K

Warning: Zero outputs support gamma adjustment.

Warning: 1/1 output(s) do not support gamma adjustment.

So lets dive deeper:

ls /sys/class/backlight/ae94000.dsi.0


actual_brightness
bl_power
brightness
device
max_brightness

power
scale
subsystem
type
uevent

nothing about color.

To turn the screen very dark we can do this an it works:

echo 8 > /sys/class/backlight/ae94000.dsi.0/brightness

but not color, rgb? rgba?

ah, maybe fbset:

fbset

mode "1080x2280-0"
#D: 0.000 MHZ, H: 0.000 kHZ. V:
0.000 Hz
geometry 1080 2280 1080 2280 32
timings 0 O 0 0 0 0 0
accel false
rgba 8/16,8/8,8/0,0/0

ok, first time i read something about color, but what now, maybe create custom profiles in /etc/fb.modes and try to load them..

or go deeper into i2c, really?

sudo ddcutil environment

sudo ddcutil detect

https://moverest.xyz/blog/control-display-with-ddc-ci/

Kde Plasma mobile has working nightlight on the same device, but i dont know yet how they do it.

After all this, why not just hack a .png screen overlay to get a nightmode?

 swayimg -g $myresolution --config="general.transparency=none" $overlay2 


It works, but we need to put it on top without blocking touch input, then you can have this really stupid workaround 😂

swayimg does not support event forwarding


How to achieve this? Maybe swaymsg -t anything fullscreen input surface 0

see pics.

It seems that we have to use wlroots,create an input surface of 0 so it jumps to the next layer, sadly i have zero knowledge of C code and the bash commands are very limited...

https://manpages.debian.org/bullseye/sway/sway.5.en.html

https://manpages.debian.org/bullseye/sway/sway-input.5.en.html

https://wayland.app/protocols/wayland#wl_surface:request:set_input_region


Clight

wip

# dependencies

sudo apk add popt-dev gsl-dev libconfig-dev 
# you must use the release package!
wget https://github.com/FedeDP/libmodule/archive/refs/tags/5.0.1.zip
unzip 5.0.1.zip
cd libmodule-5.0.1

mkdir build
cd build
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=lib ../
make
sudo make install

# Clight
git clone https://github.com/FedeDP/Clight.git
cd Clight
mkdir build
cd build
cmake \
    -G "Unix Makefiles" \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_LIBDIR=lib \
    -DCMAKE_BUILD_TYPE="Release" \
    ..
make

see issue

Customize Gestures

Copy the standard lisgd configuration file to make custom edits:

cp /usr/share/sxmo/default_hooks/sxmo_hook_lisgdstart.sh ~/.config/sxmo/hooks/sxmo_hook_lisgdstart.sh

Now you can start modifying gestures on your custom copy (adding short swipes somehow helps predicting medium swipes better)

add the short swipe gestures with editing:

nano ~/.config/sxmo/hooks/sxmo_hook_lisgdstart.sh

and add:

-g "1,RL,*,S,setsid -f sxmo_hook_inputhandler.sh shortoneleft" \ 
-g "1,LR,*,S,setsid -f sxmo_hook_inputhandler.sh shortoneright" \

keep in mind that the order where you write it, matters!

To define a gesture only when a specific program is running, search for your hardware specific sxmo_hook_inputhandler.sh:

which sxmo_hook_inputhandler.sh

and when found, copy it to your user config:

cp /usr/share/sxmo/default_hooks/oneplus,enchilada/sxmo_hook_inputhandler.sh ~/.config/sxmo/hooks/sxmo_hook_inputhandler.sh

In this example we add a custom firefox prev/next swipe gesture handler:

nano ~/.config/sxmo/hooks/sxmo_hook_inputhandler.sh

just below this lines:

#special context-sensitive handling
case "$WMCLASS" in

Add this:

case "$WMCLASS" in
        *"firefox-esr"*)
                case "$ACTION" in
                        "mediumoneright")
                                sxmo_type.sh -M Alt -P Right -p Right -m Alt
                                exit 0
                                ;;
                        "mediumoneleft")
                                sxmo_type.sh -M Alt -P Left -p Left -m Alt
                                exit 0
                                ;;
                esac
                ;;

The swipes actually works best when in the address bar, but you should for sure tweak your Firefox to get rid of tabs, see below in this wiki.


Notes:

If afterwards something does not work, like menu opening or whatever, you made a typo somewhere, when you are an idiot like me, who has no computer and is doing the changes directly on phone, there might be typos....


Corner Swipes

Now we know the the concept.

Lets change the button left corner to show the power status and remaining time of our battery:

For this, again in sxmo_hook_inputhandler.sh we look for the line:

"bottomleftcorner"

lets comment: sxmo_state.sh set lock

and write instead: ~/.config/sxmo/userscripts/powerlevel.sh

before and after the else

and we also want to access the powerlevel without unlocking the phone, so just above:

esac
        #we're locked, don't process the rest of the script
        exit 0

we add:

                       "bottomleftcorner")
                        ~/.config/sxmo/userscripts/powerlevel.sh
                        exit
                        ;;


reboot.

Customize Hardware Buttons for your App

When not already there, copy inputhandler to user.

cp /usr/share/sxmo/default_hooks/sxmo_hook_inputhandler.sh ~/.config/sxmo/hooks/sxmo_hook_inputhandler.sh

Now you can start modifying what the volume and power buttons shall do when a specific programm is running.

Note that it can also handle headless running scripts and is not bound to names of sway windows.

In this example we look for my-script.sh which, when running, should be killed with the volume up key:

nano ~/.config/sxmo/hooks/sxmo_hook_inputhandler.sh


I have no exact idea whats going on here, so i search for

 "volup_one") 

and go to the result which looks ok'ish to me below #standard handling , after ~line 338 something and add the kill command to:


"volup_one")
		kill $(pgrep my_script) #kill my tool, comments are important!
		sxmo_appmenu.sh
		exit
		;;

This should be it.

How to add more button functions

There is this nice powerlevel.sh script which gives me information about the powerlevel. It would be nice to have fast access to it. So we would like to push the Power Button four times (since all other pushes are useful used).

we already know

nano ~/.config/sxmo/hooks/sxmo_hook_inputhandler.sh

and we know the section #standard handling

"powerbutton_three")
		sxmo_terminal.sh
		exit 0
		;;

where we easy could change sxmo_terminal.sh to whatever we'd like.

Since we want to trigger on 4 pushes, we create a new entry containing:

"powerbutton_four")
		/home/me/.config/sxmo/userscripts/powerlevel.sh 
		exit 0
		;;

But we also need to get the information that the knob is pushed 4 times.

So we have to edit:

nano .config/sxmo/bonsai_tree.json

wow, what a file, looks like an art drawing, however, since I am editing all the satuff you see and read here on one of my phones, this is a really difficult one... lets add below we:

{
                "type": "event",
                "event_name": "power_released",
                "transitions": [
                  {
                    "type": "exec",
                    "command": [
                      "setsid",
                      "-f",
                      "sxmo_hook_inputhandler.sh",
                      "powerbutton_three"
                    ]
                  }
                ]
              }


              {
                "type": "event",
                "event_name": "power_released",
                "transitions": [
                  {
                    "type": "exec",
                    "command": [
                      "setsid",
                      "-f",
                      "sxmo_hook_inputhandler.sh",
                      "powerbutton_three"
                    ]
                  }
                ]
              },
              
              {
                "type": "event",
                "event_name": "power_released",
                "transitions": [
                  {
                    "type": "exec",
                    "command": [
                      "setsid",
                      "-f",
                      "sxmo_hook_inputhandler.sh",
                      "powerbutton_four"
                    ]
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  },

Then restart bonsaid with

superctl restart bonsaid

If it throws no error, you did good in counting brackets...

https://gist.github.com/magdesign/085344b504409839e791378dbb5aa792


Here we realize it way too hard to hit it 4 times, but i leave the write up as reference

How you can do it the bad way

Go to /dev/input/by-path/ check each entry with cat and pushing on some buttons:

cat /dev/input/by-path/platform-gpio-keys-event

you will get weird output, but you get some output. yea! Since there are several events in /dev/input/by-path/ you can just count them from top to buttom to know eachs number for the next step. Mine was the 3rd.

So this time we check

 cat /dev/input/event3 

or whichever will react to your button presses.

As soon as you found it, you can listen to it in my_script.sh as simple as:

while true; do
if inotifywait -e modify /dev/input/event3: then
echo "its pressed, lets execute something"
fi
break
done

insted of just an echo, you could kill your script with:

kill $(pgrep my_script.sh)

Firefox Tweaks

Mobile friendlier layout

first we need to get bash support:

sudo apk add bash

then we remove the standard solution:

sudo apk del mobile-config-firefox 

then we grab user0`s script from codeberg, make it executable and run it (make sure to select "Add Recommended Preferences"):

git clone https://codeberg.org/user0/Mobile-Friendly-Firefox.git
sudo chmod +x Mobile-Friendly-Firefox/install.sh
bash Mobile-Friendly-Firefox/install.sh

Disable warning when closing tabs:

micro ~/.mozilla/firefox/*.default-release/user.js

set it to false.

Remove Items from URL Bar

Long click onto the item and select remove.

Force Website Mobile

Some websites do not show in mobile version and are then hard to read. Press:

 ctrl + shift + m 

and select iphoneSE layout on top left.

Block Search Results

Get rid of reddit, pinterest etc.

Visit: https://letsblock.it/filters/search-results

generate the filterlist and copy it to your ublock MyFilters.

Search Engine

By default, mobile-config-firefox adds a policies entry to get rid of invasive stuff.

While this is a great idea it my cause some trouble for users living in non-free countries.

To enable google search engine, you can edit:

./etc/firefox/policies/policies.json

Be aware that, in a free country, it makes sense to avoid google.com as search engine and at least use startpage, 4get, SearxNG, or any other search which does not expose your privacy.

"I need privacy, not because my actions are questionable, because the judgement and intentions of big institutions are questionable"

Delete SMS

This is WIP The whole magic must go into /usr/bin/sxmo_modemtext.sh

To find out a list who texted so far: $(sxmo_contacts.sh --texted)

They lay in .local/share/sxmo/modem/<sender>/sms.txt

Summary:

Create a list of all text messages with $(sxmo_contacts.sh --texted), display this list in a bmenu, when selected => promt: sure? | cancel => rm .local/share/sxmo/modem/

First try to understand the existing code, then write a a delete only script, finally implement into sxmo_modemtext.sh


Battery Empty Warning

WIP

Send a warning and shutdown at the right time. see issue.

My solution is a custom hook, which works, but misses a function to tell 'yes i know, dont send me more warning prompts' and it does not work when in suspend mode.

There is also an charging issue which prevents to charge with a solar panel.

Audio Equalizer & Effects

Make sure you installed

sudo apk add easyeffects lsp-plugins lsp-plugins-lv2 calf

Start your audioplayer and launch easyeffects to make quality adjustments.

The layout has its challanges. Maybe we can send a gtk scaling command when opening.

Output and Recording volume can be adjusted with alsamixer

To test your microphone, visit https://mictests.com/ and record something.

Audio

since i do not understand pipewire audio, i start to dig and document here. a good base to start is its documentation: https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/Config-PipeWire#configuration-file-pipewireconf

WIP

as in the time of writing, there is no option to select audio output through the earpiece. you have to run pavucontrol go to Configuration and select the Make a phone call profile. Then we are able to play music for maybe a minute before it crashes/freezes. By analyzing all configurations the only difference between all sinks and the earpiece: in unused state all sinks are SUSPENDED, but the earpiece is IDLE.

You can check with:

pactl list short sinks

there is also a very nice tool for a node based view of audio in-/outputs:

qpwgraph

what i try to do is to play music over the speaker and switch this while playing to the earpiece. its the first step into debugging why calls dont really work. I think the error lies in loading this profiles in runtime. so far i could not figure out why we switch profiles instead of having all in/outputs in one profile and switch the stuff with a mixer. with this approach we could also switch music from loudspeaker to earpiece when wanted and i guess evwrything would stay more stable.. so lets dig where to write such a basic configuration file... wip


For a nice understanding of the audio routing:

 wpctl status

in sxmo the stuff gets switched with /usr/share/sxmo/default_hooks/sxmo_hook_call_audio.sh enable and /usr/bin/sxmo_modemaudio.sh over dbus.

Kernel Downgrade

WIP

You just made an update, now the phone boots into a black screen. Seems to be a kernel error and you should downgrade to an older version, get one here

When you are lucky, you can just pmbootstrap flasher flash_kernel and you are ready to go, but if you meanwhile upgrade pmbootstrap. you need to:


1. pmbootstrap init

2. make all the needed choices (in this example we use an op6)

3. pmbootstrap install --fde

4. copy your working kernel apk to the chroot dir: sudo cp /path/of/linux-postmarketos-qcom-sdm845-6.9.0-r0.330773b0.apk ~/.local/var/pmbootstrap/chroot_rootfs_oneplus-enchilada

5. pmbootstrap chroot -r

6. add the kernel package: apk add --allow-untrusted linux-postmarketos-qcom-sdm845-6.9.0-r0.330773b0.apk

7. exit

8. pmbootstrap export

9. now you need to fix the bootimage uuuid with abootimg:

sudo ./abootimg -u /tmp/postmarketOS-export/boot.img -c "cmdline = console=ttyMSM0,115200 pmos_rootfsopts=defaults"

10. finally flash the boot: pmbootstrap flasher boot

11. your phone may only boot once, to fix this, reinstall the kernel from a terminal on the phone.

thanks to craftyguy[m] and caleb

Install Stock Android 9.0.8

Using edl mode

Especially when you have errors, wrong partitions, broken gps or broken wifi, it makes sense to bring the OnePlus 6 back to a factory state with this method, be aware that it might take some time and nerves. Sometimes you need to repeat steps, but this method works. There is still a lot of stuff going on behind the scenes we dont know and cant understand.


Install following tools first:

- If you are not a Linux user, run bkerler`s liveCD image instead.

- Don`t use any fancy usb cable with blinking led`s and super highspeed charging capabilities.


For OnePlus6, download fulldowngrade_wipe_MSM_17819_181025_2315_user_MP1_release.zip (its on your search engine).

Unpack and decrypt payload:

 payload-dumper-go payload.bin

Now is time to start the first edl command written further down. It will wait for a device, filling the terminal with dots ..... then bring your phone into edl mode:

  1. Turn off phone
  2. Hold volume up + volume down
  3. Plugin usb cable (you should feel a vibration)
  4. The edl command which wrote some dots in terminal, now starts to execute 

(on your computer, while the phone screen stays black and only a white led next to the earpiece is shown)

  5. Write all necessary files with the edl tool:


./edl w boot_a boot.img
./edl w boot_b boot.img

./edl w dtbo_a dtbo.img
./edl w dtbo_b dtbo.img

./edl w abl_a abl.img
./edl w abl_b abl.img

./edl w aop_a aop.img
./edl w aop_b aop.img

./edl w bluetooth_a bluetooth.img
./edl w bluetooth_b bluetooth.img

./edl w cmnlib_a cmnlib.img
./edl w cmnlib_b cmnlib.img

./edl w cmnlib64_a cmnlib64.img
./edl w cmnlib64_b cmnlib64.img

./edl w devcfg_a devcfg.img
./edl w devcfg_b devcfg.img

./edl w dsp_a dsp.img
./edl w dsp_b dsp.img

./edl w fw_4j1ed_a fw_4j1ed.img
./edl w fw_4j1ed_b fw_4j1ed.img

./edl w fw_4u1ea_a fw_4u1ea.img
./edl w fw_4u1ea_b fw_4u1ea.img

./edl w hyp_a hyp.img
./edl w hyp_b hyp.img

./edl w keymaster_a keymaster.img
./edl w keymaster_b keymaster.img

./edl w LOGO_a LOGO.img
./edl w LOGO_b LOGO.img

./edl w modem_a modem.img
./edl w modem_b modem.img

./edl w oem_stanvbk oem_stanvbk.img

./edl w qupfw_a qupfw.img
./edl w qupfw_b qupfw.img

./edl w storsec_a storsec.img
./edl w storsec_b storsec.img

./edl w system_a system.img
./edl w system_b system.img

./edl w tz_a tz.img
./edl w tz_b tz.img

./edl w vbmeta_a vbmeta.img
./edl w vbmeta_b vbmeta.img

./edl w vendor_a vendor.img
./edl w vendor_b vendor.img

./edl w xbl_a xbl.img
./edl w xbl_b xbl.img

./edl w xbl_config_a xbl_config.img
./edl w xbl_config_a xbl_config.img

./edl reset

  6. After rebooting the phone into Android, enable wifi, bluetooth, location.
     Sometimes it just hangs in a google animation. You can ignore this and start flashing pmos with pmbootstrap.
  7. Flash PostmarketOS with pmbootstrap
  8. fastboot erase dtbo


Notes:

- If you have a bootloop, just run first edl command, try pressing all buttons on phone and plugin usb cable repetitively until edl catches the phone, then proceed.

- Trying to downgrade android with edl can also result in a kind of dead phone (no response, just black, very hard to get edl mode again). I had this on a 256GB version the trick here is time consuming but it works:

first edl OnePlus6Oxygen_22.J.62_OTA_0620_all_2111252336_287bcb1636d743d3, then boot into fastboot and install twrp:


fastboot flash recovery TWRP-3.6.2_11-OP6xT.zip

then boot into twrp and push the zip:

adb push fulldowngrade_wipe_MSM_17819_181025_2315_user_MP1_release.zip /sdcard

then in twrp select install and install the zip

boot, this will take a while but you are in android 9.0.2, next get OnePlus6Oxygen_22_OTA_033_all_1908012012_0b41e6554cc7409a.zip copy it to the phone and install it from the software installer menu. Then switch to fastboot set_active b and do the same. Finally you did it, you have Android 9.0.8 on your OP6 to be ready to flash PostmarketOS. Please drop me a line if this helped you :-)

- If you think your phone is bricked, there is a 99,9% chance that it is not bricked! Push the power button very long to turn it off, then push all buttons and plugin the usb cable, try this a hundred times, sometimes restart edl, switch to different usb slots on your computer, it will bring it once into edl mode.... just keep on plugin/out and remember to take a tee break before you loose your nerves... if i can do it, you can do it!

- I installed LineageOS, Android, Ubports, Droidian, Mobian, PostmarketOS, bricked the partitions, had a dead phone, had boot loops, somehow i always brought it back to life (its just annoying and time consuming).

Icon WARNING: If you see a 'crash dump' screen, plug the phone again to your computer and run edl without any commands. Provide the logs here.

external screen

copied from matrix channel:


This can be achieved with the 6T/6: see this issue/discussion: https://gitlab.com/postmarketOS/pmaports/-/issues/2295 You need to manually switch to Host mode (see the OP6 wiki) (instead of the automatic switching for OTG that others mentioned earlier) You also need to enable certain kernel options: forspecifically DRM_UDL: https://wiki.postmarketos.org/wiki/Displaylink Use the links above to see if you can get the HP adapter mentioned off eBay. Any DL-1x5 or DL-1x0 firmware models (wavlink, pluggable, diamond, HP, sabrent, siig all have models that are compatible)


To do List

  • wifis with same name get displayed more than once, fix /usr/bin/sxmo_networks.sh, add awk '!seen[$0]++' or something similar.
  • add a $icon_wif symbol in the add wifi menu when a connection is open and then also skip the password entry (/usr/bin/sxmo_networks.sh).
  • scan and display only open wifis:

nmcli -f SSID,SECURITY dev wifi

nmcli -f SSID,SECURITY dev wifi | tail -n +2 | grep -rv "WPA" | awk '!seen[$0]++' | sed '/^--/d'
  • find a solution/hack to fake an usb cable connect/unconnect command to work around this.
  • check of there is a click and drag issue in the touchpad emulator patch and fix it.
  • gestures: 3 finger down makes screenshot; change workspace to buttom swipe; 3 finger up open scaling. sadly this interacts with the running applications...

and get rid of mainstream communication

  • modify the youtube script or write a new one to audio download: yt-dlp -f 251 -x $URL
  • fix the various headphone, speaker icons on sxmobar to be less clutered and more logical (hooks/sxmo_hook_statusbar.sh)
  • how to use hydra to get around annoying hotel captive portals wich only last for a certain amount of time
  • sms deleter

Essential sxmo wiki sites

https://wiki.postmarketos.org/wiki/Sxmo:Oneplus6

https://wiki.postmarketos.org/wiki/User:Fdelamotte/dogfooding

https://wiki.postmarketos.org/wiki/sxmo/Tips_and_Tricks

Essential Packages

default sxmo apps which are defined in mimetypes but not installed by default in pmos and should be added:

zathura

nsxiv

playerctl


Following is just a note to myself:

gnome-calculator loupe gnome-keyring rsync nano bash-completion networkmanager-openvpn bash vnstat zxing tesseract-ocr tesseract-ocr-data-eng wl-clipboard imagemagick wf-recorder calcurse git git-email macchanger numberstation pure-maps gnome-passwordsafe flatpak syncthing amberol dino podman tor lyrebird foliate nheko baobab gcc alpine-sdk krita kdenlive

Terminal Apps

https://github.com/bvaisvil/zenith

https://github.com/yorukot/superfile

https://github.com/ikebastuz/wiper

https://github.com/genescu/currency-exchange

https://github.com/SOF3/lpl

https://github.com/JustPretender/discovery-rs

https://github.com/Y2Z/monolith


Flatpaks

I hate flatpaks, they eat all my data and diskspace. Its like a truck delivering an envelope...

flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo


sudo flatpak install flathub chat.delta.desktop
sudo flatpak install flathub de.schmidhuberj.Flare

Briar Secure Messenger does not run due to missing libskiko-linux-arm64.so.sha256