hosts/modules/gui/sxmo: remove
This commit is contained in:
parent
f3c3df2ca7
commit
10a985e7f9
|
@ -9,7 +9,6 @@ in
|
|||
imports = [
|
||||
./greetd.nix
|
||||
./gtk.nix
|
||||
./sxmo
|
||||
./theme
|
||||
];
|
||||
|
||||
|
|
|
@ -1,620 +0,0 @@
|
|||
# this work derives from noneucat's sxmo service/packages, found via NUR
|
||||
# - <repo:nix-community/nur-combined:repos/noneucat/modules/pinephone/sxmo.nix>
|
||||
# other nix works:
|
||||
# - <https://github.com/wentam/sxmo-nix>
|
||||
# - implements sxmo atop tinydm (also packaged by wentam)
|
||||
# - wentam cleans up sxmo-utils to be sealed. also patches to use systemd poweroff, etc
|
||||
# - packages a handful of anjan and proycon utilities
|
||||
# - packages <https://gitlab.com/kop316/mmsd/>
|
||||
# - packages <https://gitlab.com/kop316/vvmd/>
|
||||
# - <https://github.com/chuangzhu/nixpkgs-sxmo>
|
||||
# - implements sxmo as a direct systemd service -- apparently no DM
|
||||
# - packages sxmo-utils
|
||||
# - injects PATH into each script
|
||||
# other OS works:
|
||||
# - <https://git.sr.ht/~aren/sxmo-utils> (arch)
|
||||
# - perhaps sxmo-utils is best packaged via the `resholve` shell solver?
|
||||
#
|
||||
# sxmo upstream links:
|
||||
# - docs (rendered): <https://man.sr.ht/~anjan/sxmo-docs-next/>
|
||||
# - issue tracker: <https://todo.sr.ht/~mil/sxmo-tickets>
|
||||
# - mail list (patches): <https://lists.sr.ht/~mil/sxmo-devel>
|
||||
#
|
||||
# sxmo technical overview:
|
||||
# - inputs
|
||||
# - bonsaid: handles vol/power buttons
|
||||
# - it receives those buttons from dwm (if x11) harcoded in config.h or sway (if wayland)
|
||||
# - lisgd: handles gestures
|
||||
# - startup
|
||||
# - daemon based (lisgsd, idle_locker, statusbar_periodics)
|
||||
# - auto-started at login
|
||||
# - managable by `sxmo_jobs.sh`
|
||||
# - list available daemons: `sxmo_jobs.sh list`
|
||||
# - query if a daemon is active: `sxmo_jobs.sh running <my-daemon>`
|
||||
# - start daemon: `sxmo_jobs.sh start <my-daemon>`
|
||||
# - managable by `superctl`
|
||||
# - `superctl status`
|
||||
# - user hooks:
|
||||
# - live in ~/.config/sxmo/hooks/
|
||||
# - logs:
|
||||
# - live in ~/.local/state/sxmo.log
|
||||
# - ~/.local/state/superd.log
|
||||
# - ~/.local/state/superd/logs/<daemon>.log
|
||||
# - `journalctl --user --boot` (lightdm redirects the sxmo session stdout => systemd)
|
||||
#
|
||||
# - default components:
|
||||
# - DE: sway (if wayland), dwm (if X)
|
||||
# - menus: bemenu (if wayland), dmenu (if X)
|
||||
# - gestures: lisgd
|
||||
# - on-screen keyboard: wvkbd (if wayland), svkbd (if X)
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.sane.gui.sxmo;
|
||||
package = cfg.package;
|
||||
knownKeyboards = {
|
||||
# map keyboard package name -> name of binary to invoke
|
||||
wvkbd = "wvkbd-mobintl";
|
||||
svkbd = "svkbd-mobile-intl";
|
||||
};
|
||||
knownTerminals = {
|
||||
vte = "vte-2.91";
|
||||
};
|
||||
|
||||
systemd-cat = "${pkgs.systemd}/bin/systemd-cat";
|
||||
runWithLogger = identifier: cmd: pkgs.writeShellScript identifier ''
|
||||
echo "launching ${identifier}..." | ${systemd-cat} --identifier=${identifier}
|
||||
${cmd} 2>&1 | ${systemd-cat} --identifier=${identifier}
|
||||
'';
|
||||
|
||||
hookPkgs = {
|
||||
block_suspend = pkgs.static-nix-shell.mkBash {
|
||||
pname = "sxmo_hook_block_suspend.sh";
|
||||
pkgs = [ "procps" ];
|
||||
srcRoot = ./hooks;
|
||||
};
|
||||
inputhandler = pkgs.static-nix-shell.mkBash {
|
||||
pname = "sxmo_hook_inputhandler.sh";
|
||||
pkgs = [ "coreutils" "playerctl" "pulseaudio" ];
|
||||
srcRoot = ./hooks;
|
||||
};
|
||||
postwake = pkgs.static-nix-shell.mkBash {
|
||||
pname = "sxmo_hook_postwake.sh";
|
||||
pkgs = [ "coreutils" ];
|
||||
srcRoot = ./hooks;
|
||||
};
|
||||
rotate = pkgs.static-nix-shell.mkBash {
|
||||
pname = "sxmo_hook_rotate.sh";
|
||||
pkgs = {
|
||||
sway = config.sane.programs.sway.package.sway-unwrapped;
|
||||
};
|
||||
srcRoot = ./hooks;
|
||||
};
|
||||
start = pkgs.static-nix-shell.mkBash {
|
||||
pname = "sxmo_hook_start.sh";
|
||||
pkgs = [ "systemd" "xdg-user-dirs" ];
|
||||
srcRoot = ./hooks;
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options = with lib; {
|
||||
sane.gui.sxmo.enable = mkOption {
|
||||
default = false;
|
||||
type = types.bool;
|
||||
};
|
||||
sane.gui.sxmo.package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.sxmo-utils.override {
|
||||
preferSystemd = true;
|
||||
sway = config.sane.programs.sway.package.sway-unwrapped;
|
||||
};
|
||||
description = ''
|
||||
sxmo base scripts and hooks collection.
|
||||
consider overriding the outputs under /share/sxmo/default_hooks
|
||||
to insert your own user scripts.
|
||||
'';
|
||||
};
|
||||
sane.gui.sxmo.hooks = mkOption {
|
||||
type = types.attrsOf types.path;
|
||||
default = {
|
||||
# default upstream hooks
|
||||
# additional hooks are in subdirectories like three_button_touchscreen/
|
||||
# - sxmo_hook_inputhandler.sh
|
||||
# - sxmo_hook_lock.sh
|
||||
# - sxmo_hook_postwake.sh
|
||||
# - sxmo_hook_screenoff.sh
|
||||
# - sxmo_hook_unlock.sh
|
||||
# by including hooks here, updating the sxmo package also updates the hooks
|
||||
# without requiring any reboot
|
||||
"sxmo_hook_apps.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_apps.sh";
|
||||
# "sxmo_hook_block_suspend.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_block_suspend.sh";
|
||||
"sxmo_hook_call_audio.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_call_audio.sh";
|
||||
"sxmo_hook_contextmenu_fallback.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_contextmenu_fallback.sh";
|
||||
"sxmo_hook_contextmenu.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_contextmenu.sh";
|
||||
"sxmo_hook_desktop_widget.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_desktop_widget.sh";
|
||||
"sxmo_hook_discard.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_discard.sh";
|
||||
"sxmo_hook_hangup.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_hangup.sh";
|
||||
"sxmo_hook_icons.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_icons.sh";
|
||||
"sxmo_hook_lisgdstart.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_lisgdstart.sh";
|
||||
"sxmo_hook_logout.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_logout.sh";
|
||||
"sxmo_hook_missed_call.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_missed_call.sh";
|
||||
"sxmo_hook_mnc.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_mnc.sh";
|
||||
"sxmo_hook_modem.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_modem.sh";
|
||||
"sxmo_hook_mute_ring.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_mute_ring.sh";
|
||||
"sxmo_hook_network_down.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_network_down.sh";
|
||||
"sxmo_hook_network_pre_down.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_network_pre_down.sh";
|
||||
"sxmo_hook_network_pre_up.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_network_pre_up.sh";
|
||||
"sxmo_hook_network_up.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_network_up.sh";
|
||||
"sxmo_hook_notification.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_notification.sh";
|
||||
"sxmo_hook_notifications.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_notifications.sh";
|
||||
"sxmo_hook_pickup.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_pickup.sh";
|
||||
"sxmo_hook_restart_modem_daemons.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_restart_modem_daemons.sh";
|
||||
"sxmo_hook_ring.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_ring.sh";
|
||||
"sxmo_hook_rotate.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_rotate.sh";
|
||||
"sxmo_hook_screenoff.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_screenoff.sh";
|
||||
"sxmo_hook_scripts.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_scripts.sh";
|
||||
"sxmo_hook_sendsms.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_sendsms.sh";
|
||||
"sxmo_hook_smslog.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_smslog.sh";
|
||||
"sxmo_hook_sms.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_sms.sh";
|
||||
"sxmo_hook_start.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_start.sh";
|
||||
"sxmo_hook_statusbar.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_statusbar.sh";
|
||||
"sxmo_hook_stop.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_stop.sh";
|
||||
"sxmo_hook_tailtextlog.sh" = "${package}/share/sxmo/default_hooks/sxmo_hook_tailtextlog.sh";
|
||||
} // {
|
||||
# default hooks for this nix module, not upstreamable
|
||||
"sxmo_hook_block_suspend.sh" = "${hookPkgs.block_suspend}/bin/sxmo_hook_block_suspend.sh";
|
||||
"sxmo_hook_inputhandler.sh" = "${hookPkgs.inputhandler}/bin/sxmo_hook_inputhandler.sh";
|
||||
"sxmo_hook_postwake.sh" = "${hookPkgs.postwake}/bin/sxmo_hook_postwake.sh";
|
||||
"sxmo_hook_rotate.sh" = "${hookPkgs.rotate}/bin/sxmo_hook_rotate.sh";
|
||||
"sxmo_hook_start.sh" = "${hookPkgs.start}/bin/sxmo_hook_start.sh";
|
||||
"sxmo_suspend.sh" = "${pkgs.sxmo-suspend}/bin/sxmo_suspend.sh";
|
||||
};
|
||||
description = ''
|
||||
extra hooks to add with higher priority than the builtins
|
||||
'';
|
||||
};
|
||||
sane.gui.sxmo.terminal = mkOption {
|
||||
# type = types.nullOr (types.enum [ "foot" "st" "vte" ]);
|
||||
type = types.nullOr types.str;
|
||||
default = "foot";
|
||||
description = ''
|
||||
name of terminal to use for sxmo_terminal.sh.
|
||||
foot, st, and vte have special integrations in sxmo, but any will work.
|
||||
'';
|
||||
};
|
||||
sane.gui.sxmo.keyboard = mkOption {
|
||||
# type = types.nullOr (types.enum ["wvkbd"])
|
||||
type = types.nullOr types.str;
|
||||
default = "wvkbd";
|
||||
description = ''
|
||||
name of on-screen-keyboard to use for sxmo_keyboard.sh.
|
||||
this sets the KEYBOARD environment variable.
|
||||
see also: KEYBOARD_ARGS.
|
||||
'';
|
||||
};
|
||||
sane.gui.sxmo.settings = mkOption {
|
||||
description = ''
|
||||
environment variables used to configure sxmo.
|
||||
e.g. SXMO_UNLOCK_IDLE_TIME or SXMO_VOLUME_BUTTON.
|
||||
'';
|
||||
type = types.submodule {
|
||||
freeformType = types.attrsOf types.str;
|
||||
options =
|
||||
let
|
||||
mkSettingsOpt = default: description: mkOption {
|
||||
inherit default description;
|
||||
type = types.nullOr types.str;
|
||||
};
|
||||
in {
|
||||
SXMO_BAR_SHOW_BAT_PER = mkSettingsOpt "1" "show battery percentage in statusbar";
|
||||
SXMO_DISABLE_CONFIGVERSION_CHECK = mkSettingsOpt "1" "allow omitting the configversion line from user-provided sxmo dotfiles";
|
||||
SXMO_UNLOCK_IDLE_TIME = mkSettingsOpt "300" "how many seconds of inactivity before locking the screen"; # lock -> screenoff happens 8s later, not configurable
|
||||
# SXMO_WM = mkSettingsOpt "sway" "sway or dwm. ordinarily initialized by sxmo_{x,w}init.sh";
|
||||
SXMO_NO_AUDIO = mkSettingsOpt "" "don't start pipewire/pulseaudio in sxmo_hook_start.sh, don't show audio in statusbar, disable audio menu";
|
||||
SXMO_STATES = mkSettingsOpt "unlock screenoff" "list of states the device should support (unlock, lock, screenoff)";
|
||||
SXMO_SWAY_SCALE = mkSettingsOpt "1" "sway output scale";
|
||||
SXMO_WOB_DISABLE = mkSettingsOpt "" "disable the on-screen volume display";
|
||||
};
|
||||
};
|
||||
default = {};
|
||||
};
|
||||
sane.gui.sxmo.noidle = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "inhibit lock-on-idle and screenoff-on-idle";
|
||||
};
|
||||
sane.gui.sxmo.nogesture = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "don't start lisgd gesture daemon by default";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkMerge [
|
||||
{
|
||||
sane.programs.sxmoApps = {
|
||||
packageUnwrapped = null;
|
||||
suggestedPrograms = [
|
||||
"guiApps"
|
||||
"bemenu" # specifically to import its theming
|
||||
"bonsai"
|
||||
"sfeed" # want this here so that the user's ~/.sfeed/sfeedrc gets created
|
||||
# "superd" # make superctl (used by sxmo) be on PATH
|
||||
# "sway-autoscaler"
|
||||
"waybar-sxmo-status"
|
||||
];
|
||||
|
||||
persist.byStore.cryptClearOnBoot = [
|
||||
# builds to be 10's of MB per day
|
||||
# ".local/state/superd/logs"
|
||||
".local/share/sxmo/modem" # SMS
|
||||
".local/share/sxmo/notifications" # so i can see new SMS messages. not sure actually if this needs persisting or if it'll re-hydrate from modem.
|
||||
];
|
||||
};
|
||||
|
||||
sane.programs.waybar-sxmo-status = {
|
||||
packageUnwrapped = pkgs.static-nix-shell.mkBash {
|
||||
pname = "waybar-sxmo-status";
|
||||
srcRoot = ./.;
|
||||
pkgs = {
|
||||
sxmo-utils = package;
|
||||
"sxmo-utils.runtimeDeps" = package.runtimeDeps;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
{
|
||||
# TODO: lift to option declaration
|
||||
# N.B.: TERMCMD was renamed SXMO_TERMINAL on 2023/08/29
|
||||
sane.gui.sxmo.settings.SXMO_TERMINAL = lib.mkIf (cfg.terminal != null)
|
||||
(lib.mkDefault (knownTerminals."${cfg.terminal}" or cfg.terminal));
|
||||
sane.gui.sxmo.settings.KEYBOARD = lib.mkIf (cfg.keyboard != null)
|
||||
(lib.mkDefault (knownKeyboards."${cfg.keyboard}" or cfg.keyboard));
|
||||
}
|
||||
|
||||
(lib.mkIf cfg.enable (lib.mkMerge [
|
||||
{
|
||||
sane.programs.sway.enableFor.user.colin = true;
|
||||
sane.programs.waybar.config = {
|
||||
top = import ./waybar-top.nix;
|
||||
fontSize = 14;
|
||||
};
|
||||
sane.programs.sway.config = {
|
||||
# N.B. missing from upstream sxmo config here is:
|
||||
# - `bindsym $mod+g exec sxmo_hook_locker.sh`
|
||||
# - `bindsym $mod+t exec sxmo_appmenu.sh power`
|
||||
# - `bindsym $mod+i exec sxmo_wmmenu.sh windowswitcher`
|
||||
# - `bindsym $mod+p exec sxmo_appmenu.sh`
|
||||
# - `bindsym $mod+Shift+p exec sxmo_appmenu.sh sys`
|
||||
# - `input * xkb_options compose:ralt`
|
||||
# these could be added, but i don't see much benefit.
|
||||
font = "pango:monospace 10";
|
||||
mod = "Mod1"; # prefer Alt
|
||||
workspace_layout = "tabbed";
|
||||
|
||||
# screenshot_cmd = "sxmo_screenshot.sh";
|
||||
extra_lines =
|
||||
let
|
||||
sxmo_init = pkgs.writeShellScript "sxmo_init.sh" ''
|
||||
# perform the same behavior as sxmo_{x,w}init.sh -- but without actually launching wayland/X11
|
||||
# this amounts to:
|
||||
# - setting env vars (e.g. getting the hooks onto PATH)
|
||||
# - placing default configs in ~ for sxmo-launched services (sxmo_migrate.sh)
|
||||
# - binding vol/power buttons (sxmo_swayinitconf.sh)
|
||||
# - launching sxmo_hook_start.sh
|
||||
#
|
||||
# the commands here are similar to upstream sxmo_winit.sh, but not identical and the ordering may be different
|
||||
|
||||
# profile may contain SXMO_DEVICE_NAME which is used by _sxmo_load_environment so load it early
|
||||
source "$XDG_CONFIG_HOME/sxmo/profile"
|
||||
# sourcing upstream sxmo_init.sh triggers _sxmo_load_environment
|
||||
# which ensures SXMO_* environment variables are set
|
||||
source ${package}/etc/profile.d/sxmo_init.sh
|
||||
# _sxmo_prepare_dirs ensures ~/.cache/sxmo & other XDG dirs exist with correct perms & owner
|
||||
_sxmo_prepare_dirs
|
||||
# migrate tells sxmo to provide the following default files:
|
||||
# - ~/.config/sxmo/profile
|
||||
# - ~/.config/fontconfig/conf.d/50-sxmo.conf
|
||||
# - ~/.config/sxmo/sway
|
||||
# - ~/.config/foot/foot.ini
|
||||
# - ~/.config/mako/config
|
||||
# - ~/.config/sxmo/bonsai_tree.json
|
||||
# - ~/.config/wob/wob.ini
|
||||
# - ~/.config/sxmo/conky.conf
|
||||
sxmo_migrate.sh sync
|
||||
# various things may have happened above that require me to re-load the profile here:
|
||||
# - _sxmo_load_environment sources a deviceprofile.sh file, which may override my profile settings.
|
||||
# very obvious if you set a non-default SXMO_SWAY_SCALE.
|
||||
# - sxmo_migrate.sh may have provided a default profile, if i failed to
|
||||
source "$XDG_CONFIG_HOME/sxmo/profile"
|
||||
# place my non-specialized hooks at higher precedence than the default device-hooks
|
||||
# alternative would be to move my hooks to ~/.config/sxmo/hooks/<device-name>.
|
||||
export PATH="$XDG_CONFIG_HOME/sxmo/hooks:$PATH"
|
||||
|
||||
# kill anything leftover from the previous sxmo run. this way we can (try to) be reentrant
|
||||
echo "sxmo_init: killing stale daemons (if active)"
|
||||
sxmo_jobs.sh stop all
|
||||
pkill bemenu
|
||||
pkill wvkbd
|
||||
pkill superd
|
||||
|
||||
# configure vol/power-button input mapping (upstream SXMO has this in sway config)
|
||||
echo "sxmo_init: configuring sway bindings/displays with:"
|
||||
echo "SXMO_POWER_BUTTON: $SXMO_POWER_BUTTON"
|
||||
echo "SXMO_VOLUME_BUTTON: $SXMO_VOLUME_BUTTON"
|
||||
echo "SXMO_SWAY_SCALE: $SXMO_SWAY_SCALE"
|
||||
sxmo_swayinitconf.sh
|
||||
|
||||
echo "sxmo_init: invoking sxmo_hook_start.sh with:"
|
||||
echo "PATH: $PATH"
|
||||
sxmo_hook_start.sh
|
||||
'';
|
||||
in ''
|
||||
# TODO: some of this is probably unnecessary
|
||||
mode "menu" {
|
||||
# just a placeholder for "menu" mode
|
||||
bindsym --input-device=1:1:1c21800.lradc XF86AudioMute exec nothing
|
||||
}
|
||||
bindsym button2 kill
|
||||
bindswitch lid:on exec sxmo_wm.sh dpms on
|
||||
bindswitch lid:off exec sxmo_wm.sh dpms off
|
||||
|
||||
exec 'printf %s "$SWAYSOCK" > "$XDG_RUNTIME_DIR"/sxmo.swaysock'
|
||||
|
||||
# XXX(2023/12/04): this shouldn't be necessary, but without this Komikku fails to launch because XDG_SESSION_TYPE is unset
|
||||
|
||||
exec dbus-update-activation-environment --systemd XDG_SESSION_TYPE
|
||||
exec_always ${sxmo_init}
|
||||
'';
|
||||
};
|
||||
|
||||
sane.programs.sxmoApps.enableFor.user.colin = true;
|
||||
|
||||
sane.programs.sway-autoscaler.config.defaultScale = builtins.fromJSON cfg.settings.SXMO_SWAY_SCALE;
|
||||
|
||||
# sxmo internally uses doas instead of sudo
|
||||
security.doas.enable = true;
|
||||
security.doas.wheelNeedsPassword = false;
|
||||
|
||||
# lightdm-mobile-greeter: "The name org.a11y.Bus was not provided by any .service files"
|
||||
services.gnome.at-spi2-core.enable = true;
|
||||
|
||||
environment.systemPackages = [
|
||||
package
|
||||
] ++ lib.optionals (cfg.terminal != null) [ pkgs."${cfg.terminal}" ]
|
||||
++ lib.optionals (cfg.keyboard != null) [ pkgs."${cfg.keyboard}" ];
|
||||
|
||||
environment.sessionVariables = {
|
||||
XDG_DATA_DIRS = [
|
||||
# TODO: only need the share/sxmo directly linked
|
||||
"${package}/share"
|
||||
];
|
||||
} // (lib.filterAttrs (k: v:
|
||||
k == "SXMO_DISABLE_CONFIGVERSION_CHECK" # read before `profile` is sourced
|
||||
|| k == "SXMO_TERMINAL" # for apps launched via `swaymsg exec -- sxmo_terminal.sh ...`
|
||||
)
|
||||
cfg.settings
|
||||
);
|
||||
|
||||
|
||||
sane.programs.bonsai.config.transitions = let
|
||||
doExec = inputName: transitions: {
|
||||
type = "exec";
|
||||
command = [
|
||||
"setsid"
|
||||
"-f"
|
||||
"sxmo_hook_inputhandler.sh"
|
||||
inputName
|
||||
];
|
||||
inherit transitions;
|
||||
};
|
||||
onDelay = ms: transitions: {
|
||||
type = "delay";
|
||||
delay_duration = ms * 1000000;
|
||||
inherit transitions;
|
||||
};
|
||||
onEvent = eventName: transitions: {
|
||||
type = "event";
|
||||
event_name = eventName;
|
||||
inherit transitions;
|
||||
};
|
||||
friendlyToBonsai = { trigger ? null, terminal ? false, timeout ? {}, power_pressed ? {}, power_released ? {}, voldown_pressed ? {}, voldown_released ? {}, volup_pressed ? {}, volup_released ? {} }@args:
|
||||
if trigger != null then [
|
||||
(doExec trigger (friendlyToBonsai (builtins.removeAttrs args ["trigger"])))
|
||||
] else let
|
||||
events = [ ]
|
||||
++ (lib.optional (timeout != {}) (onDelay (timeout.ms or 400) (friendlyToBonsai (builtins.removeAttrs timeout ["ms"]))))
|
||||
++ (lib.optional (power_pressed != {}) (onEvent "power_pressed" (friendlyToBonsai power_pressed)))
|
||||
++ (lib.optional (power_released != {}) (onEvent "power_released" (friendlyToBonsai power_released)))
|
||||
++ (lib.optional (voldown_pressed != {}) (onEvent "voldown_pressed" (friendlyToBonsai voldown_pressed)))
|
||||
++ (lib.optional (voldown_released != {}) (onEvent "voldown_released" (friendlyToBonsai voldown_released)))
|
||||
++ (lib.optional (volup_pressed != {}) (onEvent "volup_pressed" (friendlyToBonsai volup_pressed)))
|
||||
++ (lib.optional (volup_released != {}) (onEvent "volup_released" (friendlyToBonsai volup_released)))
|
||||
;
|
||||
in assert terminal -> events == []; events;
|
||||
|
||||
# trigger ${button}_hold_N every `holdTime` ms until ${button} is released
|
||||
recurseHold = button: { count ? 1, maxHolds ? 5, prefix ? "", holdTime ? 600, ... }@opts: lib.optionalAttrs (count <= maxHolds) {
|
||||
"${button}_released".terminal = true; # end the hold -> back to root state
|
||||
timeout = {
|
||||
ms = holdTime;
|
||||
trigger = "${prefix}${button}_hold_${builtins.toString count}";
|
||||
} // (recurseHold button (opts // { count = count+1; }));
|
||||
};
|
||||
|
||||
# trigger volup_tap_N or voldown_tap_N on every tap.
|
||||
# if a volume button is held, then switch into `recurseHold`'s handling instead
|
||||
volumeActions = { count ? 1, maxTaps ? 5, prefix ? "", timeout ? 600, ... }@opts: lib.optionalAttrs (count != maxTaps) {
|
||||
volup_pressed = (recurseHold "volup" opts) // {
|
||||
volup_released = {
|
||||
trigger = "${prefix}volup_tap_${builtins.toString count}";
|
||||
timeout.ms = timeout;
|
||||
} // (volumeActions (opts // { count = count+1; }));
|
||||
};
|
||||
voldown_pressed = (recurseHold "voldown" opts) // {
|
||||
voldown_released = {
|
||||
trigger = "${prefix}voldown_tap_${builtins.toString count}";
|
||||
timeout.ms = timeout;
|
||||
} // (volumeActions (opts // { count = count+1; }));
|
||||
};
|
||||
};
|
||||
in friendlyToBonsai {
|
||||
# map sequences of "events" to an argument to pass to sxmo_hook_inputhandler.sh
|
||||
|
||||
# map: power (short), power (short) x2, power (long)
|
||||
power_pressed.timeout.ms = 900; # press w/o release. this is a long timeout because it's tied to the "kill window" action.
|
||||
power_pressed.timeout.trigger = "powerhold";
|
||||
power_pressed.power_released.timeout.trigger = "powerbutton_one";
|
||||
power_pressed.power_released.timeout.ms = 300;
|
||||
power_pressed.power_released.power_pressed.trigger = "powerbutton_two";
|
||||
|
||||
# map: volume taps and holds
|
||||
volup_pressed = (recurseHold "volup" {}) // {
|
||||
# this either becomes volup_hold_* (via recurseHold, above) or:
|
||||
# - a short volup_tap_1 followed by:
|
||||
# - a *finalized* volup_1 (i.e. end of action)
|
||||
# - more taps/holds, in which case we prefix it with `modal_<action>`
|
||||
# to denote that we very explicitly entered this state.
|
||||
#
|
||||
# it's clunky: i do it this way so that voldown can map to keyboard/terminal in unlock mode
|
||||
# but trigger media controls in screenoff
|
||||
# in a way which *still* allows media controls if explicitly entered into via a tap on volup first
|
||||
volup_released = (volumeActions { prefix = "modal_"; }) // {
|
||||
trigger = "volup_tap_1";
|
||||
timeout.ms = 300;
|
||||
timeout.trigger = "volup_1";
|
||||
};
|
||||
};
|
||||
voldown_pressed = (volumeActions {}).voldown_pressed // {
|
||||
trigger = "voldown_start";
|
||||
};
|
||||
};
|
||||
|
||||
# sxmo puts in /share/sxmo:
|
||||
# - profile.d/sxmo_init.sh
|
||||
# - appcfg/
|
||||
# - default_hooks/
|
||||
# - and more
|
||||
# environment.pathsToLink = [ "/share/sxmo" ];
|
||||
|
||||
# if superd fails to start a service within 100ms, it'll try to start again
|
||||
# the fallout of this is that during intense lag (e.g. OOM or swapping) it can
|
||||
# start the service many times.
|
||||
# see <repo:craftyguy/superd:internal/cmd/cmd.go>
|
||||
# startTimerDuration = 100 * time.Millisecond
|
||||
# TODO: better fix may be to patch `sxmo_hook_lisgdstart.sh` and force it to behave as a singleton
|
||||
# systemd.services."dedupe-sxmo-lisgd" = {
|
||||
# description = "kill duplicate lisgd processes started by superd";
|
||||
# serviceConfig = {
|
||||
# Type = "oneshot";
|
||||
# };
|
||||
# script = ''
|
||||
# if [ "$(${pkgs.procps}/bin/pgrep -c lisgd)" -gt 1 ]; then
|
||||
# echo 'killing duplicated lisgd daemons'
|
||||
# ${pkgs.psmisc}/bin/killall lisgd # let superd restart it
|
||||
# fi
|
||||
# '';
|
||||
# wantedBy = [ "multi-user.target" ];
|
||||
# };
|
||||
# systemd.timers."dedupe-sxmo-lisgd" = {
|
||||
# wantedBy = [ "dedupe-sxmo-lisgd.service" ];
|
||||
# timerConfig = {
|
||||
# OnUnitActiveSec = "2min";
|
||||
# };
|
||||
# };
|
||||
|
||||
sane.user.fs = lib.mkMerge [
|
||||
{
|
||||
# link the superd services into a place where systemd can find them.
|
||||
# the unit files should be compatible, except maybe for PATH handling
|
||||
# ".config/systemd/user/autocutsel-primary.service".symlink.target = "${package}/share/superd/services/autocutsel-primary.service";
|
||||
# ".config/systemd/user/autocutsel.service".symlink.target = "${package}/share/superd/services/autocutsel.service";
|
||||
# ".config/systemd/user/bonsaid.service".symlink.target = "${package}/share/superd/services/bonsaid.service";
|
||||
# # ".config/systemd/user/dunst.service".symlink.target = "${package}/share/superd/services/dunst.service";
|
||||
# # ".config/systemd/user/mako.service".symlink.target = "${package}/share/superd/services/mako.service";
|
||||
# ".config/systemd/user/mmsd-tng.service".symlink.target = "${package}/share/superd/services/mmsd-tng.service";
|
||||
# ".config/systemd/user/sxmo_autosuspend.service".symlink.target = "${package}/share/superd/services/sxmo_autosuspend.service";
|
||||
# ".config/systemd/user/sxmo_battery_monitor.service".symlink.target = "${package}/share/superd/services/sxmo_battery_monitor.service";
|
||||
# ".config/systemd/user/sxmo_conky.service".symlink.target = "${package}/share/superd/services/sxmo_conky.service";
|
||||
# ".config/systemd/user/sxmo_desktop_widget.service".symlink.target = "${package}/share/superd/services/sxmo_desktop_widget.service";
|
||||
# ".config/systemd/user/sxmo_hook_lisgd.service".symlink.target = "${package}/share/superd/services/sxmo_hook_lisgd.service";
|
||||
# ".config/systemd/user/sxmo_menumode_toggler.service".symlink.target = "${package}/share/superd/services/sxmo_menumode_toggler.service";
|
||||
# ".config/systemd/user/sxmo_modemmonitor.service".symlink.target = "${package}/share/superd/services/sxmo_modemmonitor.service";
|
||||
# ".config/systemd/user/sxmo_networkmonitor.service".symlink.target = "${package}/share/superd/services/sxmo_networkmonitor.service";
|
||||
# ".config/systemd/user/sxmo_notificationmonitor.service".symlink.target = "${package}/share/superd/services/sxmo_notificationmonitor.service";
|
||||
# ".config/systemd/user/sxmo_soundmonitor.service".symlink.target = "${package}/share/superd/services/sxmo_soundmonitor.service";
|
||||
# ".config/systemd/user/sxmo_wob.service".symlink.target = "${package}/share/superd/services/sxmo_wob.service";
|
||||
# ".config/systemd/user/sxmo-x11-status.service".symlink.target = "${package}/share/superd/services/sxmo-x11-status.service";
|
||||
# ".config/systemd/user/unclutter.service".symlink.target = "${package}/share/superd/services/unclutter.service";
|
||||
# ".config/systemd/user/unclutter-xfixes.service".symlink.target = "${package}/share/superd/services/unclutter-xfixes.service";
|
||||
# ".config/systemd/user/vvmd.service".symlink.target = "${package}/share/superd/services/vvmd.service";
|
||||
|
||||
# service code further below tells systemd to put ~/.config/sxmo/hooks on PATH, but it puts hooks/bin on PATH instead, so symlink that
|
||||
".config/sxmo/hooks/bin".symlink.target = ".";
|
||||
|
||||
".cache/sxmo/sxmo.noidle" = lib.mkIf cfg.noidle {
|
||||
symlink.text = "";
|
||||
};
|
||||
".cache/sxmo/sxmo.nogesture" = lib.mkIf cfg.nogesture {
|
||||
symlink.text = "";
|
||||
};
|
||||
".config/sxmo/profile".symlink.text = let
|
||||
mkKeyValue = key: value: ''export ${key}="${value}"'';
|
||||
in
|
||||
lib.generators.toKeyValue { inherit mkKeyValue; } cfg.settings;
|
||||
}
|
||||
(lib.mapAttrs' (name: value: {
|
||||
# sxmo's `_sxmo_load_environments` adds to PATH:
|
||||
# - ~/.config/sxmo/hooks/$SXMO_DEVICE_NAME
|
||||
# - ~/.config/sxmo/hooks
|
||||
name = ".config/sxmo/hooks/${name}";
|
||||
value.symlink.target = value;
|
||||
}) cfg.hooks)
|
||||
];
|
||||
|
||||
sane.user.services = let
|
||||
sxmoPath = [ package ] ++ package.runtimeDeps;
|
||||
sxmoEnvSetup = ''
|
||||
# mimic my sxmo_init.sh a bit. refer to the actual sxmo_init.sh above for details.
|
||||
# the specific ordering, and the duplicated profile sourcing, matters.
|
||||
export HOME="''${HOME:-/home/colin}"
|
||||
export XDG_CONFIG_HOME="''${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||
source "$XDG_CONFIG_HOME/sxmo/profile"
|
||||
source ${package}/etc/profile.d/sxmo_init.sh
|
||||
source "$XDG_CONFIG_HOME/sxmo/profile"
|
||||
export PATH="$XDG_CONFIG_HOME/sxmo/hooks:$PATH:${lib.makeBinPath sxmoPath}"
|
||||
'';
|
||||
sxmoService = name: {
|
||||
description = "sxmo ${name}";
|
||||
script = ''
|
||||
${sxmoEnvSetup}
|
||||
exec sxmo_${name}.sh
|
||||
'';
|
||||
serviceConfig.Type = "simple";
|
||||
serviceConfig.Restart = "always";
|
||||
serviceConfig.RestartSec = "20s";
|
||||
};
|
||||
in {
|
||||
# these are defined here, and started mostly in sxmo_hook_start.sh.
|
||||
# the ones commented our here are the ones i explicitly no longer use.
|
||||
# uncommenting them here *won't* cause them to be auto-started.
|
||||
sxmo_autosuspend = sxmoService "autosuspend";
|
||||
# sxmo_battery_monitor = sxmoService "battery_monitor";
|
||||
sxmo_desktop_widget = sxmoService "hook_desktop_widget";
|
||||
sxmo_hook_lisgd = sxmoService "hook_lisgdstart";
|
||||
sxmo_menumode_toggler = sxmoService "menumode_toggler";
|
||||
sxmo_modemmonitor = sxmoService "modemmonitor";
|
||||
# sxmo_networkmonitor = sxmoService "networkmonitor";
|
||||
sxmo_notificationmonitor = sxmoService "notificationmonitor";
|
||||
# sxmo_soundmonitor = sxmoService "soundmonitor";
|
||||
# sxmo_wob = sxmoService "wob";
|
||||
sxmo-x11-status = sxmoService "status_xsetroot";
|
||||
|
||||
bonsaid.script = lib.mkBefore sxmoEnvSetup;
|
||||
};
|
||||
}
|
||||
]))
|
||||
];
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p procps
|
||||
|
||||
# Basic exponential backoff, this should save some resources if we're blocked by
|
||||
# the same thing for a while
|
||||
delay() {
|
||||
sleep "$delay_time"
|
||||
delay_time="$((delay_time*2))"
|
||||
if [ "$delay_time" -gt 45 ]; then
|
||||
delay_time=45
|
||||
fi
|
||||
}
|
||||
|
||||
wait_item() {
|
||||
delay_time=1
|
||||
while $1 > /dev/null 2>&1; do
|
||||
echo "Blocking suspend for $1"
|
||||
waited=1
|
||||
delay
|
||||
done
|
||||
}
|
||||
|
||||
##################################### below is original, not shared with upstream sxmo_hook_block_suspend.sh
|
||||
|
||||
casting_go2tv() {
|
||||
pgrep -f go2tv
|
||||
}
|
||||
|
||||
# forward to the next block_suspend.sh script (if any).
|
||||
# have to handle the case where this script is on PATH, and also when it was called without being on PATH.
|
||||
# the implementation here causes us to call ourselves exactly once, at most (or twice, if there are duplicate PATH entries)
|
||||
SXMO_HOOK_BLOCK_SUSPEND_DEPTH=$((${SXMO_HOOK_BLOCK_SUSPEND_DEPTH:-0} + 1))
|
||||
echo "recurse counter: $SXMO_HOOK_BLOCK_SUSPEND_DEPTH"
|
||||
|
||||
block_suspend_next=true
|
||||
FWD_COUNT=0
|
||||
IFS=:
|
||||
for p in $PATH ; do
|
||||
echo "testing: $p/sxmo_hook_block_suspend.sh"
|
||||
if $(test -x "$p/sxmo_hook_block_suspend.sh"); then
|
||||
FWD_COUNT=$(($FWD_COUNT + 1))
|
||||
fi
|
||||
if [ "$FWD_COUNT" -eq "$SXMO_HOOK_BLOCK_SUSPEND_DEPTH" ]; then
|
||||
block_suspend_next="$p/sxmo_hook_block_suspend.sh"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
while [ "$waited" != "0" ]; do
|
||||
waited=0
|
||||
|
||||
echo "forwarding to: $block_suspend_next"
|
||||
SXMO_HOOK_BLOCK_SUSPEND_DEPTH="$SXMO_HOOK_BLOCK_SUSPEND_DEPTH" "$block_suspend_next"
|
||||
|
||||
# wait for my own items last. else, we could wait for go2tv, then wait for internals, and in the meantime go2tv was re-spawned.
|
||||
wait_item casting_go2tv
|
||||
done
|
|
@ -1,144 +0,0 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p coreutils -p playerctl -p pulseaudio
|
||||
|
||||
# input map considerations
|
||||
# - using compound actions causes delays.
|
||||
# e.g. if volup->volup is a distinct action from volup, then single-volup action is forced to wait the maximum button delay.
|
||||
# - actions which are to be responsive should therefore have a dedicated key.
|
||||
# - a dedicated "kill" combo is important for unresponsive fullscreen apps, because appmenu doesn't show in those
|
||||
# - although better may be to force appmenu to show over FS apps
|
||||
# - bonsai mappings are static, so buttons can't benefit from non-compounding unless they're mapped accordingly for all lock states
|
||||
# - this limitation could be removed, but with work
|
||||
#
|
||||
# example of a design which considers these things:
|
||||
# - when unlocked:
|
||||
# - volup toggle -> app menu
|
||||
# - voldown press -> keyboard
|
||||
# - voldown hold -> terminal
|
||||
# - power x2 -> screenoff
|
||||
# - hold power -> kill app
|
||||
# - when locked:
|
||||
# - volup tap -> volume up
|
||||
# - volup hold -> media seek forward
|
||||
# - voldown tap -> volume down
|
||||
# - voldown hold -> media seek backward
|
||||
# - power x1 -> screen on
|
||||
# - power x2 -> play/pause media
|
||||
# some trickiness allows for media controls in unlocked mode:
|
||||
# - volup tap -> enter media mode
|
||||
# - i.e. in this state, vol tap/hold is mapped to volume/seek
|
||||
# - if, after entering media mode, no more taps occur, then we trigger the default app-menu action
|
||||
# limitations/downsides:
|
||||
# - power mappings means phone is artificially slow to unlock.
|
||||
# - media controls when unlocked have quirks:
|
||||
# - mashing voldown to decrease the volume will leave you with a toggled keyboard.
|
||||
# - seeking backward isn't possible except by first tapping volup.
|
||||
|
||||
|
||||
# increments to use for volume adjustment
|
||||
VOL_INCR=5
|
||||
|
||||
# replicating the naming from upstream sxmo_hook_inputhandler.sh...
|
||||
ACTION="$1"
|
||||
STATE=$(cat "$SXMO_STATE")
|
||||
|
||||
noop() {
|
||||
true
|
||||
}
|
||||
|
||||
handle_with() {
|
||||
echo "sxmo_hook_inputhandler.sh: STATE=$STATE ACTION=$ACTION: handle_with: $@"
|
||||
"$@"
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
# state is one of:
|
||||
# - "unlock" => normal operation; display on and touchscreen on
|
||||
# - "screenoff" => display off and touchscreen off
|
||||
# - "lock" => display on but touchscreen disabled
|
||||
# - "proximity{lock,unlock}" => intended for when in a phone call
|
||||
|
||||
if [ "$STATE" = "unlock" ]; then
|
||||
case "$ACTION" in
|
||||
# powerbutton_one: intentional default to no-op
|
||||
# powerbutton_two: intentional default to screenoff
|
||||
"powerhold")
|
||||
# power thrice: kill active window
|
||||
handle_with sxmo_killwindow.sh
|
||||
;;
|
||||
|
||||
"volup_tap_1")
|
||||
# swallow: this could be the start to a media control (multi taps / holds),
|
||||
# or it could be just a single tap -> release, handled next/below
|
||||
handle_with noop
|
||||
;;
|
||||
"volup_1")
|
||||
# volume up once: app-specific menu w/ fallback to SXMO system menu
|
||||
handle_with sxmo_appmenu.sh
|
||||
;;
|
||||
|
||||
"voldown_start")
|
||||
# volume down once: toggle keyboard
|
||||
handle_with sxmo_keyboard.sh toggle
|
||||
;;
|
||||
"voldown_hold_2")
|
||||
# hold voldown to launch terminal
|
||||
# note we already triggered the keyboard; that's fine: usually keyboard + terminal go together :)
|
||||
# voldown_hold_1 frequently triggers during short taps meant only to reveal the keyboard,
|
||||
# so prefer a longer hold duration
|
||||
handle_with sxmo_terminal.sh
|
||||
;;
|
||||
"voldown_tap_1")
|
||||
# swallow, to prevent keyboard from also triggering media controls
|
||||
handle_with noop
|
||||
;;
|
||||
voldown_hold_*)
|
||||
# swallow, to prevent terminal from also triggering media controls
|
||||
handle_with noop
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ "$STATE" = "screenoff" ]; then
|
||||
case "$ACTION" in
|
||||
"powerbutton_two")
|
||||
# power twice => toggle media player
|
||||
handle_with playerctl play-pause
|
||||
;;
|
||||
"powerhold")
|
||||
# power toggle during deep sleep often gets misread as power hold, so treat same
|
||||
handle_with sxmo_state.sh set unlock
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# default actions
|
||||
case "$ACTION" in
|
||||
"powerbutton_one")
|
||||
# power once => unlock
|
||||
handle_with sxmo_state.sh set unlock
|
||||
;;
|
||||
"powerbutton_two")
|
||||
# power twice => screenoff
|
||||
handle_with sxmo_state.sh set screenoff
|
||||
;;
|
||||
# powerbutton_three: intentional no-op because overloading the kill-window handler is risky
|
||||
|
||||
volup_tap*|modal_volup_tap*)
|
||||
handle_with pactl set-sink-volume @DEFAULT_SINK@ +"$VOL_INCR%"
|
||||
;;
|
||||
voldown_tap*|modal_voldown_tap*)
|
||||
handle_with pactl set-sink-volume @DEFAULT_SINK@ -"$VOL_INCR%"
|
||||
;;
|
||||
|
||||
volup_hold*|modal_volup_hold*)
|
||||
handle_with playerctl position 30+
|
||||
;;
|
||||
voldown_hold*|modal_voldown_hold*)
|
||||
handle_with playerctl position 10-
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
handle_with noop
|
|
@ -1,51 +0,0 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p coreutils
|
||||
|
||||
# the default sxmo_postwake handler checks if the modem is offline
|
||||
# and if so installs a wakelock to block suspend for 30s.
|
||||
# that's a questionable place to install that logic, and i want to keep stuff
|
||||
# out of the wake-from-sleep critical path, so i'm overriding this hook to disable that.
|
||||
|
||||
declare -A newmap
|
||||
wowlan_reason[0x0]="not wowlan"
|
||||
|
||||
# mappings are found in megi's linux: drivers/staging/rtl8723cs/include/hal_com.h
|
||||
wowlan_reason[0x1]="RX_PAIRWISEKEY"
|
||||
wowlan_reason[0x2]="RX_GTK"
|
||||
wowlan_reason[0x3]="RX_FOURWAY_HANDSHAKE"
|
||||
wowlan_reason[0x4]="RX_DISASSOC"
|
||||
wowlan_reason[0x8]="RX_DEAUTH"
|
||||
wowlan_reason[0x9]="RX_ARP_REQUEST"
|
||||
wowlan_reason[0x10]="FW_DECISION_DISCONNECT"
|
||||
wowlan_reason[0x21]="RX_MAGIC_PKT"
|
||||
wowlan_reason[0x22]="RX_UNICAST_PKT"
|
||||
wowlan_reason[0x23]="RX_PATTERN_PKT"
|
||||
wowlan_reason[0x24]="RTD3_SSID_MATCH"
|
||||
wowlan_reason[0x30]="RX_REALWOW_V2_WAKEUP_PKT"
|
||||
wowlan_reason[0x31]="RX_REALWOW_V2_ACK_LOST"
|
||||
wowlan_reason[0x40]="ENABLE_FAIL_DMA_IDLE"
|
||||
wowlan_reason[0x41]="ENABLE_FAIL_DMA_PAUSE"
|
||||
wowlan_reason[0x42]="RTIME_FAIL_DMA_IDLE"
|
||||
wowlan_reason[0x43]="RTIME_FAIL_DMA_PAUSE"
|
||||
wowlan_reason[0x55]="RX_PNO"
|
||||
#ifdef CONFIG_WOW_KEEP_ALIVE_PATTERN
|
||||
wowlan_reason[0x60]="WOW_KEEPALIVE_ACK_TIMEOUT"
|
||||
wowlan_reason[0x61]="WOW_KEEPALIVE_WAKE"
|
||||
#endif/*CONFIG_WOW_KEEP_ALIVE_PATTERN*/
|
||||
wowlan_reason[0x66]="AP_OFFLOAD_WAKEUP"
|
||||
wowlan_reason[0xfd]="CLK_32K_UNLOCK"
|
||||
wowlan_reason[0xfe]="CLK_32K_LOCK"
|
||||
|
||||
wowlan_text="$(cat /proc/net/rtl8723cs/wlan0/wowlan_last_wake_reason)"
|
||||
wowlan_bits="${wowlan_text/last wake reason: /}"
|
||||
wowlan_reason="${wowlan_reason[$wowlan_bits]}"
|
||||
echo "exited suspend: $wowlan_text ($wowlan_reason)"
|
||||
if [ "$wowlan_bits" != "0x0" ]; then
|
||||
# give time for userspace to respond to the wake event.
|
||||
# IM clients might have to re-establish TCP connections, perform sync, etc
|
||||
# until finally receiving the event which the system woke for,
|
||||
# TODO: if we suspended only very briefly, likely all the networking is in sync
|
||||
# and we don't have to wait this long.
|
||||
# there's no easy way *here* to know how long we slept for, though.
|
||||
sxmo_wakelock.sh lock postwake_work 25s
|
||||
fi
|
|
@ -1,16 +0,0 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p sway
|
||||
|
||||
# called whenever sxmo_rotate.sh is invoked.
|
||||
# i.e. whenever the screen is rotated manually, or automatically if autorotate is enabled.
|
||||
# $1 = the new orientation
|
||||
# possible values are "normal", "invert", "left" and "right"
|
||||
|
||||
# exit fullscreen, if any app is in FS.
|
||||
# this benefits UX because:
|
||||
# - most of my FS use is in landscape mode
|
||||
# - when i toggle apps or desktops i always do so in portrait mode
|
||||
# - therefore when i rotate landscape -> portrait mode, i almost never want fullscreen anymore.
|
||||
if [ "$1" = "normal" ] || [ "$1" = "invert" ]; then
|
||||
swaymsg fullscreen disable
|
||||
fi
|
|
@ -1,95 +0,0 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p systemd -p xdg-user-dirs
|
||||
# this is based on upstream sxmo-utils sxmo_hook_start.sh
|
||||
# but modified for nixos integration and specialize a bit to my needs
|
||||
. sxmo_common.sh
|
||||
|
||||
# Create xdg user directories, such as ~/Pictures
|
||||
xdg-user-dirs-update
|
||||
|
||||
sxmo_jobs.sh start daemon_manager
|
||||
|
||||
# Periodically update some status bar components
|
||||
# don't: statusbar is managed by waybar
|
||||
# sxmo_hook_statusbar.sh all
|
||||
# sxmo_jobs.sh start statusbar_periodics sxmo_run_aligned.sh 60 \
|
||||
# sxmo_hook_statusbar.sh periodics
|
||||
|
||||
# TODO: start these externally, via `wantedBy` in nix
|
||||
# don't: i don't use mako
|
||||
# superctl start mako
|
||||
# systemctl --user start sxmo_wob
|
||||
systemctl --user start sxmo_menumode_toggler
|
||||
systemctl --user start bonsaid
|
||||
# don't: sway background is managed externally
|
||||
# swaymsg output '*' bg "$SXMO_BG_IMG" fill
|
||||
|
||||
# To setup initial lock state
|
||||
sxmo_state.sh set unlock
|
||||
|
||||
# Turn on auto-suspend
|
||||
if [ -w "/sys/power/wakeup_count" ] && [ -f "/sys/power/wake_lock" ]; then
|
||||
systemctl --user start sxmo_autosuspend
|
||||
fi
|
||||
|
||||
# Turn on lisgd
|
||||
if [ ! -e "$XDG_CACHE_HOME"/sxmo/sxmo.nogesture ]; then
|
||||
systemctl --user start sxmo_hook_lisgd
|
||||
fi
|
||||
|
||||
if [ "$(command -v ModemManager)" ]; then
|
||||
# Turn on the dbus-monitors for modem-related tasks
|
||||
systemctl --user start sxmo_modemmonitor
|
||||
|
||||
# place a wakelock for 120s to allow the modem to fully warm up (eg25 +
|
||||
# elogind/systemd would do this for us, but we don't use those.)
|
||||
sxmo_wakelock.sh lock sxmo_modem_warming_up 120s
|
||||
fi
|
||||
|
||||
# don't: conky is managed externally
|
||||
# superctl start sxmo_conky
|
||||
|
||||
# Monitor the battery
|
||||
# don't: this is *exclusively* for sxmo_hook_statusbar.sh, which i don't use.
|
||||
# systemctl --user start sxmo_battery_monitor
|
||||
|
||||
# It watch network changes and update the status bar icon by example
|
||||
# don't: this is for sxmo_hook_statusbar.sh, which i don't use.
|
||||
# this means we never call sxmo_hook_network_{up,down,...}, but the defaults are no-op anyway
|
||||
# systemctl --user start sxmo_networkmonitor
|
||||
|
||||
# The daemon that display notifications popup messages
|
||||
# more importantly: it lights the led green when a notification arrives
|
||||
systemctl --user start sxmo_notificationmonitor
|
||||
|
||||
# monitor for headphone for statusbar
|
||||
# this also invokes `wob` whenever the volume is changed
|
||||
# don't: my volume monitoring is handled by sway
|
||||
# systemctl --user start sxmo_soundmonitor
|
||||
|
||||
# rotate UI based on physical display angle by default
|
||||
if [ -n "$SXMO_AUTOROTATE" ]; then
|
||||
# TODO: this could use ~/.cache/sxmo/sxmo.autorotate like for lisgd above
|
||||
sxmo_jobs.sh start autorotate sxmo_autorotate.sh
|
||||
fi
|
||||
|
||||
# Play a funky startup tune if you want (disabled by default)
|
||||
#mpv --quiet --no-video ~/welcome.ogg &
|
||||
|
||||
# mmsd and vvmd
|
||||
if [ -f "${SXMO_MMS_BASE_DIR:-"$HOME"/.mms/modemmanager}/mms" ]; then
|
||||
systemctl --user start mmsd-tng
|
||||
fi
|
||||
|
||||
if [ -f "${SXMO_VVM_BASE_DIR:-"$HOME"/.vvm/modemmanager}/vvm" ]; then
|
||||
systemctl --user start vvmd
|
||||
fi
|
||||
|
||||
# add some warnings if things are not setup correctly
|
||||
if ! command -v "sxmo_deviceprofile_$SXMO_DEVICE_NAME.sh"; then
|
||||
sxmo_notify_user.sh --urgency=critical \
|
||||
"No deviceprofile found $SXMO_DEVICE_NAME. See: https://sxmo.org/deviceprofile"
|
||||
fi
|
||||
|
||||
sxmo_migrate.sh state || sxmo_notify_user.sh --urgency=critical \
|
||||
"Config needs migration" "$? file(s) in your sxmo configuration are out of date and disabled - using defaults until you migrate (run sxmo_migrate.sh)"
|
|
@ -1,122 +0,0 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p sxmo-utils -p sxmo-utils.runtimeDeps
|
||||
#
|
||||
# usage:
|
||||
# waybar-sxmo-status widget1 [ widget2 [...]]
|
||||
#
|
||||
# where each widget is one of:
|
||||
# - modem-state
|
||||
# - modem-tech
|
||||
# - modem-signal
|
||||
# - wifi-status
|
||||
# - volume
|
||||
|
||||
# sxmo_hook_statusbar.sh assumes:
|
||||
# - mmcli, jq on PATH
|
||||
# - sxmo_hook_icons.sh and sxmo_common.sh are sourcable
|
||||
# - from sxmo_common, it only uses sxmobar (and aliases jq=gojq)
|
||||
|
||||
# setup environment so that the hooks will be on PATH:
|
||||
# - sxmo_hook_statusbar.sh
|
||||
# - sxmo_hook_icons.sh
|
||||
export HOME="${HOME:-/home/colin}"
|
||||
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||
export PATH="$XDG_CONFIG_HOME/sxmo/hooks:$PATH"
|
||||
|
||||
# ensure that sxmo_audio.sh tells us the volume instead of early-returning
|
||||
export SXMO_NO_AUDIO=
|
||||
|
||||
# clunky interaction between us and sxmo_hook_statusbar.sh:
|
||||
# - we export `sxmobar` to it, but within that function cannot modify the environment
|
||||
# of *this* script, because it gets run in a different process.
|
||||
# - so, `sxmobar` prints info to stdout, and then this script re-interprets that info.
|
||||
# - practically, `sxmobar` prints shell commands, and then this script `eval`s them, to achieve that IPC.
|
||||
sxmobar() {
|
||||
action="$1"
|
||||
shift
|
||||
if [ "$action" = "-a" ]; then
|
||||
while [ -n "$*" ]; do
|
||||
arg="$1"
|
||||
case "$arg" in
|
||||
"-f"|"-b"|"-t"|"-e")
|
||||
# foreground/background/text/emphasis: ignore it
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
# begin arguments
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "setitem $@"
|
||||
fi
|
||||
}
|
||||
export -f sxmobar
|
||||
|
||||
setitem() {
|
||||
id="$1"
|
||||
priority="$2"
|
||||
value="$3"
|
||||
case "$id" in
|
||||
modem-state)
|
||||
modem_state="$value"
|
||||
;;
|
||||
modem-tech)
|
||||
modem_tech="$value"
|
||||
;;
|
||||
modem-signal)
|
||||
modem_signal="$value"
|
||||
;;
|
||||
wifi-status)
|
||||
wifi_status="$value"
|
||||
;;
|
||||
volume)
|
||||
volume="$value"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
while [ -n "$*" ]; do
|
||||
variable="$1"
|
||||
shift
|
||||
case "$variable" in
|
||||
"--verbose")
|
||||
set -x
|
||||
;;
|
||||
"modem-state")
|
||||
if [ -z "$modem_state" ]; then
|
||||
eval "$(sxmo_hook_statusbar.sh modem)"
|
||||
fi
|
||||
echo -n "$modem_state"
|
||||
;;
|
||||
"modem-tech")
|
||||
if [ -z "$modem_tech" ]; then
|
||||
eval "$(sxmo_hook_statusbar.sh modem)"
|
||||
fi
|
||||
echo -n "$modem_tech"
|
||||
;;
|
||||
"modem-signal")
|
||||
if [ -z "$modem_signal" ]; then
|
||||
eval "$(sxmo_hook_statusbar.sh modem)"
|
||||
fi
|
||||
echo -n "$modem_signal"
|
||||
;;
|
||||
"wifi-status")
|
||||
if [ -z "$wifi_status" ]; then
|
||||
eval "$(sxmo_hook_statusbar.sh network wifi wlan0)"
|
||||
fi
|
||||
echo -n "$wifi_status"
|
||||
;;
|
||||
"volume")
|
||||
if [ -z "$volume" ]; then
|
||||
eval "$(sxmo_hook_statusbar.sh volume)"
|
||||
fi
|
||||
echo -n "$volume"
|
||||
;;
|
||||
*)
|
||||
echo -n "UNK: $variable"
|
||||
;;
|
||||
esac
|
||||
done
|
|
@ -1,85 +0,0 @@
|
|||
# docs: https://github.com/Alexays/Waybar/wiki/Configuration
|
||||
# format specifiers: https://fmt.dev/latest/syntax.html#syntax
|
||||
# this is merged with the sway/waybar-top.nix defaults
|
||||
{
|
||||
height = 26;
|
||||
|
||||
modules-left = [ "sway/workspaces" ];
|
||||
modules-center = [ ];
|
||||
modules-right = [
|
||||
"custom/swaync"
|
||||
"clock"
|
||||
"battery"
|
||||
"custom/sxmo-sane"
|
||||
# "custom/sxmo"
|
||||
# "custom/sxmo/modem-state"
|
||||
# "custom/sxmo/modem-tech"
|
||||
# "custom/sxmo/modem-signal"
|
||||
# "custom/sxmo/wifi"
|
||||
];
|
||||
|
||||
"sway/workspaces" = {
|
||||
all-outputs = true;
|
||||
# force the bar to always show even empty workspaces
|
||||
persistent-workspaces = {
|
||||
"1" = [];
|
||||
"2" = [];
|
||||
"3" = [];
|
||||
"4" = [];
|
||||
"5" = [];
|
||||
};
|
||||
};
|
||||
|
||||
"custom/sxmo-sane" = {
|
||||
# this calls all the SXMO indicators, inline.
|
||||
# so it works even without the "statusbar periodics" sxmo service running.
|
||||
interval = 2;
|
||||
format = "{}";
|
||||
exec = "waybar-sxmo-status modem-state modem-tech modem-signal wifi-status volume";
|
||||
};
|
||||
|
||||
"custom/sxmo" = {
|
||||
# this gives wifi state, battery, mic/speaker, lockstate, time all as one widget.
|
||||
# a good starting point, but may want to split these apart later to make things configurable.
|
||||
# the values for this bar are computed in sxmo:configs/default_hooks/sxmo_hook_statusbar.sh
|
||||
exec = "sxmo_status.sh";
|
||||
interval = 1;
|
||||
format = "{}";
|
||||
};
|
||||
# not ported: battery, ethernet
|
||||
"custom/sxmo/modem-state" = {
|
||||
exec = "cat /run/user/1000/sxmo_status/default/10-modem-state";
|
||||
interval = 2;
|
||||
format = "{}";
|
||||
};
|
||||
"custom/sxmo/modem-tech" = {
|
||||
exec = "cat /run/user/1000/sxmo_status/default/11-modem-tech";
|
||||
interval = 2;
|
||||
format = "{}";
|
||||
};
|
||||
"custom/sxmo/modem-signal" = {
|
||||
exec = "cat /run/user/1000/sxmo_status/default/12-modem-signal";
|
||||
interval = 2;
|
||||
format = "{}";
|
||||
};
|
||||
"custom/sxmo/wifi" = {
|
||||
exec = "cat /run/user/1000/sxmo_status/default/30-wifi-status";
|
||||
interval = 2;
|
||||
format = "{}";
|
||||
};
|
||||
"custom/sxmo/volume" = {
|
||||
exec = "cat /run/user/1000/sxmo_status/default/50-volume";
|
||||
interval = 2;
|
||||
format = "{}";
|
||||
};
|
||||
"custom/sxmo/state" = {
|
||||
exec = "cat /run/user/1000/sxmo_status/default/90-state";
|
||||
interval = 2;
|
||||
format = "{}";
|
||||
};
|
||||
"custom/sxmo/time" = {
|
||||
exec = "cat /run/user/1000/sxmo_status/default/99-time";
|
||||
interval = 2;
|
||||
format = "{}";
|
||||
};
|
||||
}
|
|
@ -23,6 +23,5 @@ in
|
|||
|
||||
config = {
|
||||
sane.programs.sway.config.background = lib.mkDefault cfg.png;
|
||||
sane.gui.sxmo.settings.SXMO_BG_IMG = lib.mkDefault (builtins.toString cfg.png);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user