I managed to get this working with the help of Claude (AI). It’s a quick workaround, not a polished solution: there’s no entry in Settings for now, and the flashlight simply follows the privacy switch.
I’m sharing the code as-is, so use it at your own risk. It’s just what worked for me, and I’m not claiming it’s the best way to do it (folder choice, structure, etc.). Feel free to adapt it or improve on it.
Tested on: Jolla Phone 2026, Sailfish OS 5.2.0.18
To remove everything: disable the service, then delete the unit file and the script.
Note: it relies on the privacyModeActiveChanged D-Bus signal, so it may break if that changes in a future update.
- Test the flashlight by hand
busctl --user get-property org.sailfish.flashlight.provider /org/sailfish/flashlight/provider org.sailfish.flashlight.provider flashlightOn
busctl --user call org.sailfish.flashlight.provider /org/sailfish/flashlight/provider org.sailfish.flashlight.provider toggleFlashlight
The flashlight should turn on, and a second call turns it off.
- Create the script
mkdir -p ~/bin
cat > ~/bin/privacy-flashlight.sh << 'EOF'
#!/bin/sh
SVC=org.sailfish.flashlight.provider
OBJ=/org/sailfish/flashlight/provider
IFACE=org.sailfish.flashlight.provider
set_flashlight() {
want="$1"
cur=$(busctl --user get-property $SVC $OBJ $IFACE flashlightOn | awk '{print $2}')
if [ "$cur" != "$want" ]; then
busctl --user call $SVC $OBJ $IFACE toggleFlashlight > /dev/null
fi
}
dbus-monitor --session "type='signal',interface='org.sailfishos.privacyswitch',member='privacyModeActiveChanged'" |
while read -r line; do
case "$line" in
*"boolean true"*) set_flashlight true ;;
*"boolean false"*) set_flashlight false ;;
esac
done
EOF
chmod +x ~/bin/privacy-flashlight.sh
The script reads the flashlight state before acting, because toggleFlashlight flips the state on every call. For the opposite behavior (flashlight off when the switch is on), swap true and false in the two set_flashlight lines.
Test: run ~/bin/privacy-flashlight.sh, flip the physical switch, then stop it with Ctrl+C.
- Start it automatically
mkdir -p ~/.config/systemd/user
cat > ~/.config/systemd/user/privacy-flashlight.service << 'EOF'
[Unit]
Description=Flashlight linked to the privacy switch
After=dbus.service
[Service]
ExecStart=%h/bin/privacy-flashlight.sh
Restart=on-failure
[Install]
WantedBy=user-session.target
EOF
systemctl --user daemon-reload
systemctl --user start privacy-flashlight.service
systemctl --user status privacy-flashlight.service --no-pager