The recent patch to support the Nokia N900 offered a new dedicated
inputhandler hook. This would bring the number of those scripts to
three:
- the default three button, touchscreen support one we use on Pinephone
and most of the devices
- the one button e-reader one, which behave differently cause there is a
single state for the e-ink screen devices (no screenoff or screen
locked)
- and now this third one, cause the device got a non multi-touch support
screen, and a physical keyboard
I paused while reviewing this patch cause this is becoming too much
duplication. We had to think about this script, and how to deduplicate
the code as much as possible.
While investigating, I noted that with the recent addition
of sxmo_state_switch.sh, we could probaly unify cleanly the whole
management of the Sxmo state, on every devices.
With a simple refactorisation, I was able to change the available
states with a simple environment variable $SXMO_STATES. The default value
is of course "unlock lock screenoff", but on desktop it will become
"unlock locker", and on e-ink reader just "unlock".
This unify most of the variable code from the inputhandlers, cause all of them
can now call sxmo_state_switch.sh up/down in a common way. The last
pieces of code that is still dependent on the device type was the
sxmo_wakelock.sh part:
On three state mode devices, Sxmo remove the wakelock if the state is
"screenoff" after 3s of inactivity. On Pinenote Sxmo remove it when "unlock"
after 120s of inactivity. On desktop, we currently never suspend.
I managed to unify this by extending the "transition" method from
sxmo_state_switch.sh. The environment variables is
$SXMO_SUSPENDABLE_STATES:
By default (pinephone and other), we use "screenoff 3" as value.
On pinetab "unlock 120", and on desktop nothing explicit (we
never reach screenoff in this mode anyway).
It is possible to define multiple cases, ex "lock 120 screenoff 3", which
means 120s timeout while lock, and 3s timeout while screenoff.
It is now possible for a user, or a future device, to define a brand new
workflow, with different available states, and suspending behaviors.
This change also strip the state hooks of this responsibility, and ensure we
keep control over this behavior.
With those changes, we now can remove completely the subdirectories from the
hooks \o/
The in-screen keyboard specific case will be managed by an environment
variable, to disable it on Nokia 900, or devices that have a physical
keyboard (desktops too).
Previously, this hook was just removing the wake lock that prevent the
device to suspend. This was only up to sxmo_hook_block_suspend.sh to
prevent the device to suspend if some applications are active.
With this change, we glue the idle inhibitors just before unlocking the wake
lock.
It means that the user now can move the device to screenoff, with an
idle inhibitor programs running, without needing to add a dedicated rule
to the block_suspends hook.
This also remove the need of this sxmo_hold_a_bit 3s wakelock.
If a call is incomming and the proximity doesn't unlock the screen,
cause near initial state, or because it is bugged, then we was setting
the "menu" mode while screenoff. Which means the power button was
picking the dmenu entry instead of unlocking the device.
We disable the "menu" mode if the proximity lock turns the screen off,
so we should not set this mode if the initial state is screenoff.
Main goal here is to remove obsoletes rules, and to drop our 666 chmods.
Those are serious security holes. Requiring the user to be in the "input"
group is already very weak. Let's not make this worse.
Brightnessctl embark its own rules, so we can drop our lights related
rules.
We move the touchscreen in a more common by-path folder. We are in the input
group, so lisgd have access to it.
I don't know about stylus related rules, I don't think they are
necessary. Input devices are in the "input" group by default. I don't
think those need to be 666...
Relying on SXMO_DEVICE_NAME isn't great cause some devices (ex: the
Pinebook Pro) got a device name that isn't "desktop" but are considered
by Sxmo with a desktop mode. Because of the symlink of the hook folder
to desktop.
I think a dedicated environment variable is good enough to cover this
case.
- Fallback to using wtype to convert volume / power presses into
up/down/enter int menu mode if we don't know volume key names. This
costs some performance, but is only noticeable when scrolling quickly.
- Bind to all power and volume button devices. This will make it
possible to trigger {volup,voldown,powerbutton}_one events on any
device, even without a deviceprofile. This is necessary for unlocking
without a deviceprofile, it's also a big step towards not needing
deviceprofiles at all.
Chanes from v1:
- don't use the multikey script when we can't set the repeat rate of
volume buttons.
- don't bind to anything on desktop systems
- remove default values for vol and pwr that were causing issues
- remove SXMO_VOLUME_BUTTON="none" from pinenote deviceprofile since we
check if it's empty instead now
Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
Without those, every sxmo_migrate.sh ask the user if they want to remove
those. Adding a placeholder make it easy to differenciate known hooks,
and hooks that has been removed.
This also cleanup, merge or fix some existing hooks.
The services for programs that aren't provided by sxmo-utils often
conflict with services provided by distributions other than alpine. This
provides a flag that package maintainers can use to easily disable them
at build time.
Signed-off-by: Aren Moynihan <aren@peacevolution.org>
Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
this is technically overbroad, in that it blocks whenever Dino is
outputting audio, but in practice that's precise enough & Dino doesn't
expose any API to detect calls specifically.
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
Some pkill implementations match on /proc/pid/stat which is limited to
15 characters [1]. $KEYBOARD defaults to svkbd-mobile-intl which is more
then 15 characters, so use -f to match the full string. Note that sxmo
uses busybox pkill by default which does not have this limit.
[1] https://manpages.debian.org/buster/procps/pgrep.1.en.html (Notes)
This patch was previously applied, and then reverted by a careless
refactor, restore it.
Signed-off-by: Anjandev Momi <anjan@momi.ca>
Signed-off-by: Aren Moynihan <aren@peacevolution.org>
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
right now sxmo_killwindow.sh is exposed only via the (default) sxmo
input bindings/gestures. exposing this via the menu system allows more
leeway for exploring alternative input bindings.
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>