2023-05-16 11:09:57 +00:00
# this work derives from noneucat's sxmo service/packages, found via NUR
# - <repo:nix-community/nur-combined:repos/noneucat/modules/pinephone/sxmo.nix>
2023-05-17 06:58:37 +00:00
# other nix works:
# - <https://github.com/wentam/sxmo-nix>
2023-05-17 10:18:11 +00:00
# - 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/>
2023-05-17 06:58:37 +00:00
# - <https://github.com/chuangzhu/nixpkgs-sxmo>
2023-05-17 10:18:11 +00:00
# - implements sxmo as a direct systemd service -- apparently no DM
# - packages sxmo-utils
# - injects PATH into each script
2023-10-09 22:05:37 +00:00
# other OS works:
# - <https://git.sr.ht/~aren/sxmo-utils> (arch)
2023-05-17 10:18:11 +00:00
# - perhaps sxmo-utils is best packaged via the `resholve` shell solver?
2023-05-17 00:25:14 +00:00
#
2023-07-21 22:46:14 +00:00
# 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>
2023-05-17 00:25:14 +00:00
#
# sxmo technical overview:
# - inputs
2023-10-08 17:12:53 +00:00
# - bonsaid: handles vol/power buttons
# - it receives those buttons from dwm (if x11) harcoded in config.h or sway (if wayland)
2023-05-17 00:25:14 +00:00
# - lisgd: handles gestures
# - startup
# - daemon based (lisgsd, idle_locker, statusbar_periodics)
# - auto-started at login
2023-11-20 02:31:55 +00:00
# - 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>`
2023-05-17 06:58:37 +00:00
# - managable by `superctl`
# - `superctl status`
2023-05-17 00:25:14 +00:00
# - user hooks:
# - live in ~/.config/sxmo/hooks/
# - logs:
# - live in ~/.local/state/sxmo.log
2023-05-17 06:58:37 +00:00
# - ~/.local/state/superd.log
# - ~/.local/state/superd/logs/<daemon>.log
2023-08-26 09:40:07 +00:00
# - `journalctl --user --boot` (lightdm redirects the sxmo session stdout => systemd)
2023-05-17 00:25:14 +00:00
#
# - 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)
2023-07-13 22:20:26 +00:00
{ config , lib , pkgs , . . . }:
2023-05-16 11:09:57 +00:00
let
2023-05-17 06:58:37 +00:00
cfg = config . sane . gui . sxmo ;
2023-09-05 17:20:48 +00:00
package = cfg . package ;
2023-07-03 22:27:29 +00:00
knownKeyboards = {
# map keyboard package name -> name of binary to invoke
wvkbd = " w v k b d - m o b i n t l " ;
svkbd = " s v k b d - m o b i l e - i n t l " ;
} ;
knownTerminals = {
vte = " v t e - 2 . 9 1 " ;
} ;
2023-08-26 12:28:25 +00:00
systemd-cat = " ${ pkgs . systemd } / b i n / s y s t e m d - c a t " ;
runWithLogger = identifier : cmd : pkgs . writeShellScript identifier ''
echo " l a u n c h i n g ${ identifier } . . . " | $ { systemd-cat } - - identifier = $ { identifier }
$ { cmd } 2 > & 1 | $ { systemd-cat } - - identifier = $ { identifier }
'' ;
2023-09-24 17:48:18 +00:00
hookPkgs = {
inputhandler = pkgs . static-nix-shell . mkBash {
pname = " s x m o _ h o o k _ i n p u t h a n d l e r . s h " ;
2023-11-20 07:35:23 +00:00
pkgs = [ " c o r e u t i l s " " p l a y e r c t l " " p u l s e a u d i o " ] ;
2023-10-11 02:05:55 +00:00
src = ./hooks ;
2023-09-24 17:48:18 +00:00
} ;
2023-09-27 21:42:55 +00:00
postwake = pkgs . static-nix-shell . mkBash {
pname = " s x m o _ h o o k _ p o s t w a k e . s h " ;
2023-10-10 00:35:32 +00:00
pkgs = [ " c o r e u t i l s " ] ;
2023-09-27 21:42:55 +00:00
src = ./hooks ;
} ;
rotate = pkgs . static-nix-shell . mkBash {
pname = " s x m o _ h o o k _ r o t a t e . s h " ;
2023-10-11 02:05:55 +00:00
pkgs = [ " s w a y " ] ;
2023-09-27 21:42:55 +00:00
src = ./hooks ;
2023-10-11 02:05:55 +00:00
} ;
screenoff = pkgs . static-nix-shell . mkBash {
pname = " s x m o _ h o o k _ s c r e e n o f f . s h " ;
2023-09-27 21:42:55 +00:00
pkgs = [ " s w a y " ] ;
2023-10-11 02:05:55 +00:00
src = ./hooks ;
2023-09-27 21:42:55 +00:00
} ;
2023-09-24 17:48:18 +00:00
start = pkgs . static-nix-shell . mkBash {
pname = " s x m o _ h o o k _ s t a r t . s h " ;
2023-10-08 17:12:53 +00:00
pkgs = [ " s y s t e m d " " x d g - u s e r - d i r s " ] ;
2023-10-11 02:05:55 +00:00
src = ./hooks ;
2023-09-24 17:48:18 +00:00
} ;
2023-10-22 09:36:08 +00:00
suspend = pkgs . static-nix-shell . mkPython3Bin {
2023-10-08 01:57:01 +00:00
pname = " s x m o _ s u s p e n d . s h " ;
2023-10-22 09:36:08 +00:00
pkgs = [ " r t l 8 7 2 3 c s - w o w l a n " " u t i l - l i n u x " ] ;
2023-10-11 02:05:55 +00:00
src = ./hooks ;
2023-10-22 13:01:33 +00:00
extraMakeWrapperArgs = [ " - - a d d - f l a g s " " - - v e r b o s e " ] ;
2023-10-08 01:57:01 +00:00
} ;
2023-09-24 17:48:18 +00:00
} ;
2023-05-16 11:09:57 +00:00
in
{
2023-05-19 10:18:26 +00:00
options = with lib ; {
2023-05-16 11:09:57 +00:00
sane . gui . sxmo . enable = mkOption {
default = false ;
type = types . bool ;
} ;
2023-05-19 10:18:26 +00:00
sane . gui . sxmo . greeter = mkOption {
2023-08-26 12:28:25 +00:00
type = types . enum [
" g r e e t d - p h o g "
2023-09-04 01:06:16 +00:00
" g r e e t d - s w a y - g t k g r e e t "
2023-08-26 12:28:25 +00:00
" g r e e t d - s w a y - p h o g "
" g r e e t d - s x m o "
" l i g h t d m - m o b i l e "
] ;
2023-08-26 19:55:36 +00:00
# default = "lightdm-mobile";
default = " g r e e t d - s w a y - p h o g " ;
2023-05-19 10:18:26 +00:00
description = ''
which greeter to use .
2023-09-04 01:06:16 +00:00
" g r e e t d - p h o g " = > phosh-based greeter . keypad ( 0 -9 ) with option to open an on-screen keyboard .
" g r e e t d - s w a y - p h o g " = > phog , but uses sway as the compositor instead of phoc .
2023-08-26 19:54:58 +00:00
requires a patched phog , since sway doesn't provide the Wayland global " z p h o c _ l a y e r _ s h e l l _ e f f e c t s _ v 1 " .
2023-09-04 01:06:16 +00:00
" g r e e t d - s x m o " = > launch sxmo directly from greetd , no auth .
this means no keychain unlocked or encrypted home mounted .
" l i g h t d m - m o b i l e " = > keypad style greeter . can only enter digits 0 -9 as password .
" g r e e t d - s w a y - g t k g r e e t " = > layered sway greeter . keyboard-only user/pass input ; impractical on mobile .
2023-05-19 10:18:26 +00:00
'' ;
} ;
2023-06-23 08:38:23 +00:00
sane . gui . sxmo . package = mkOption {
type = types . package ;
2023-11-19 23:44:48 +00:00
default = pkgs . sxmo-utils . override { preferSystemd = true ; } ;
2023-05-17 06:58:37 +00:00
description = ''
2023-06-23 09:13:57 +00:00
sxmo base scripts and hooks collection .
consider overriding the outputs under /share/sxmo/default_hooks
to insert your own user scripts .
2023-05-17 06:58:37 +00:00
'' ;
} ;
2023-09-05 17:20:48 +00:00
sane . gui . sxmo . hooks = mkOption {
type = types . attrsOf types . path ;
default = {
2023-10-07 00:21:13 +00:00
# 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
" s x m o _ h o o k _ a p p s . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ a p p s . s h " ;
" s x m o _ h o o k _ b l o c k _ s u s p e n d . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ b l o c k _ s u s p e n d . s h " ;
" s x m o _ h o o k _ c a l l _ a u d i o . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ c a l l _ a u d i o . s h " ;
" s x m o _ h o o k _ c o n t e x t m e n u _ f a l l b a c k . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ c o n t e x t m e n u _ f a l l b a c k . s h " ;
" s x m o _ h o o k _ c o n t e x t m e n u . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ c o n t e x t m e n u . s h " ;
" s x m o _ h o o k _ d e s k t o p _ w i d g e t . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ d e s k t o p _ w i d g e t . s h " ;
" s x m o _ h o o k _ d i s c a r d . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ d i s c a r d . s h " ;
" s x m o _ h o o k _ h a n g u p . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ h a n g u p . s h " ;
" s x m o _ h o o k _ i c o n s . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ i c o n s . s h " ;
" s x m o _ h o o k _ l i s g d s t a r t . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ l i s g d s t a r t . s h " ;
" s x m o _ h o o k _ l o g o u t . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ l o g o u t . s h " ;
" s x m o _ h o o k _ m i s s e d _ c a l l . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ m i s s e d _ c a l l . s h " ;
" s x m o _ h o o k _ m n c . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ m n c . s h " ;
" s x m o _ h o o k _ m o d e m . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ m o d e m . s h " ;
" s x m o _ h o o k _ m u t e _ r i n g . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ m u t e _ r i n g . s h " ;
" s x m o _ h o o k _ n e t w o r k _ d o w n . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ n e t w o r k _ d o w n . s h " ;
" s x m o _ h o o k _ n e t w o r k _ p r e _ d o w n . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ n e t w o r k _ p r e _ d o w n . s h " ;
" s x m o _ h o o k _ n e t w o r k _ p r e _ u p . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ n e t w o r k _ p r e _ u p . s h " ;
" s x m o _ h o o k _ n e t w o r k _ u p . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ n e t w o r k _ u p . s h " ;
" s x m o _ h o o k _ n o t i f i c a t i o n . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ n o t i f i c a t i o n . s h " ;
" s x m o _ h o o k _ n o t i f i c a t i o n s . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ n o t i f i c a t i o n s . s h " ;
" s x m o _ h o o k _ p i c k u p . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ p i c k u p . s h " ;
2023-10-09 20:37:51 +00:00
" s x m o _ h o o k _ p o w e r o f f . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ p o w e r o f f . s h " ;
" s x m o _ h o o k _ r e b o o t . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ r e b o o t . s h " ;
2023-10-07 00:21:13 +00:00
" s x m o _ h o o k _ r e s t a r t _ m o d e m _ d a e m o n s . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ r e s t a r t _ m o d e m _ d a e m o n s . s h " ;
" s x m o _ h o o k _ r i n g . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ r i n g . s h " ;
" s x m o _ h o o k _ r o t a t e . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ r o t a t e . s h " ;
" s x m o _ h o o k _ s c r i p t s . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ s c r i p t s . s h " ;
" s x m o _ h o o k _ s e n d s m s . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ s e n d s m s . s h " ;
" s x m o _ h o o k _ s m s l o g . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ s m s l o g . s h " ;
" s x m o _ h o o k _ s m s . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ s m s . s h " ;
" s x m o _ h o o k _ s t a r t . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ s t a r t . s h " ;
" s x m o _ h o o k _ s t a t u s b a r . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ s t a t u s b a r . s h " ;
" s x m o _ h o o k _ s t o p . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ s t o p . s h " ;
" s x m o _ h o o k _ t a i l t e x t l o g . s h " = " ${ package } / s h a r e / s x m o / d e f a u l t _ h o o k s / s x m o _ h o o k _ t a i l t e x t l o g . s h " ;
} // {
# default hooks for this nix module, not upstreamable
2023-09-24 18:13:49 +00:00
" s x m o _ h o o k _ i n p u t h a n d l e r . s h " = " ${ hookPkgs . inputhandler } / b i n / s x m o _ h o o k _ i n p u t h a n d l e r . s h " ;
" s x m o _ h o o k _ p o s t w a k e . s h " = " ${ hookPkgs . postwake } / b i n / s x m o _ h o o k _ p o s t w a k e . s h " ;
2023-09-27 21:42:55 +00:00
" s x m o _ h o o k _ r o t a t e . s h " = " ${ hookPkgs . rotate } / b i n / s x m o _ h o o k _ r o t a t e . s h " ;
2023-10-11 02:05:55 +00:00
" s x m o _ h o o k _ s c r e e n o f f . s h " = " ${ hookPkgs . screenoff } / b i n / s x m o _ h o o k _ s c r e e n o f f . s h " ;
2023-09-27 21:42:55 +00:00
" s x m o _ h o o k _ s t a r t . s h " = " ${ hookPkgs . start } / b i n / s x m o _ h o o k _ s t a r t . s h " ;
2023-10-08 01:57:01 +00:00
" s x m o _ s u s p e n d . s h " = " ${ hookPkgs . suspend } / b i n / s x m o _ s u s p e n d . s h " ;
2023-09-05 17:20:48 +00:00
} ;
description = ''
extra hooks to add with higher priority than the builtins
'' ;
} ;
2023-05-17 06:58:37 +00:00
sane . gui . sxmo . terminal = mkOption {
2023-05-18 11:10:28 +00:00
# type = types.nullOr (types.enum [ "foot" "st" "vte" ]);
2023-05-31 04:27:27 +00:00
type = types . nullOr types . str ;
2023-05-19 08:04:17 +00:00
default = " f o o t " ;
2023-05-17 06:58:37 +00:00
description = ''
2023-05-18 11:10:28 +00:00
name of terminal to use for sxmo_terminal . sh .
foot , st , and vte have special integrations in sxmo , but any will work .
2023-05-17 06:58:37 +00:00
'' ;
} ;
2023-05-24 06:06:16 +00:00
sane . gui . sxmo . keyboard = mkOption {
# type = types.nullOr (types.enum ["wvkbd"])
2023-05-31 04:27:27 +00:00
type = types . nullOr types . str ;
2023-05-24 06:06:16 +00:00
default = " w v k b d " ;
description = ''
name of on-screen-keyboard to use for sxmo_keyboard . sh .
this sets the KEYBOARD environment variable .
see also : KEYBOARD_ARGS .
'' ;
} ;
2023-05-19 09:36:17 +00:00
sane . gui . sxmo . settings = mkOption {
description = ''
environment variables used to configure sxmo .
e . g . SXMO_UNLOCK_IDLE_TIME or SXMO_VOLUME_BUTTON .
'' ;
2023-06-20 00:13:39 +00:00
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 " " s h o w b a t t e r y p e r c e n t a g e i n s t a t u s b a r " ;
2023-08-28 21:53:43 +00:00
SXMO_DISABLE_CONFIGVERSION_CHECK = mkSettingsOpt " 1 " " a l l o w o m i t t i n g t h e c o n f i g v e r s i o n l i n e f r o m u s e r - p r o v i d e d s x m o d o t f i l e s " ;
2023-06-20 00:13:39 +00:00
SXMO_UNLOCK_IDLE_TIME = mkSettingsOpt " 3 0 0 " " h o w m a n y s e c o n d s o f i n a c t i v i t y b e f o r e l o c k i n g t h e s c r e e n " ; # lock -> screenoff happens 8s later, not configurable
2023-09-04 11:10:30 +00:00
# SXMO_WM = mkSettingsOpt "sway" "sway or dwm. ordinarily initialized by sxmo_{x,w}init.sh";
2023-11-19 23:55:41 +00:00
SXMO_NO_AUDIO = mkSettingsOpt " 1 " " d o n ' t s t a r t p i p e w i r e / p u l s e a u d i o i n s x m o _ h o o k _ s t a r t . s h " ;
2023-11-20 06:53:59 +00:00
SXMO_STATES = mkSettingsOpt " u n l o c k s c r e e n o f f " " l i s t o f s t a t e s t h e d e v i c e s h o u l d s u p p o r t ( u n l o c k , l o c k , s c r e e n o f f ) " ;
2023-11-21 08:14:52 +00:00
SXMO_SWAY_SCALE = mkSettingsOpt " 1 " " s w a y o u t p u t s c a l e " ;
2023-06-20 00:13:39 +00:00
} ;
} ;
default = { } ;
2023-05-19 09:36:17 +00:00
} ;
2023-06-20 00:05:06 +00:00
sane . gui . sxmo . noidle = mkOption {
type = types . bool ;
default = false ;
description = " i n h i b i t l o c k - o n - i d l e a n d s c r e e n o f f - o n - i d l e " ;
} ;
2023-07-25 10:56:29 +00:00
sane . gui . sxmo . nogesture = mkOption {
type = types . bool ;
default = false ;
description = " d o n ' t s t a r t l i s g d g e s t u r e d a e m o n b y d e f a u l t " ;
} ;
2023-05-16 11:09:57 +00:00
} ;
2023-11-20 02:31:23 +00:00
imports = [
./bonsai.nix
] ;
2023-05-19 10:18:26 +00:00
config = lib . mkMerge [
2023-05-16 11:09:57 +00:00
{
sane . programs . sxmoApps = {
package = null ;
suggestedPrograms = [
" g u i A p p s "
2023-10-09 00:07:13 +00:00
" b e m e n u " # specifically to import its theming
2023-09-03 08:48:43 +00:00
" s f e e d " # want this here so that the user's ~/.sfeed/sfeedrc gets created
2023-10-09 00:24:47 +00:00
# "superd" # make superctl (used by sxmo) be on PATH
2023-11-26 22:03:57 +00:00
# "sway-autoscaler"
2023-05-16 11:09:57 +00:00
] ;
2023-07-13 06:58:48 +00:00
2023-11-08 15:32:50 +00:00
persist . byStore . cryptClearOnBoot = [
2023-07-13 06:58:48 +00:00
# builds to be 10's of MB per day
2023-10-09 00:24:47 +00:00
# ".local/state/superd/logs"
2023-11-27 06:46:57 +00:00
" . l o c a l / s h a r e / s x m o / m o d e m " # SMS
" . l o c a l / s h a r e / s x m o / n o t i f i c a t i o n s " # so i can see new SMS messages. not sure actually if this needs persisting or if it'll re-hydrate from modem.
2023-07-13 06:58:48 +00:00
] ;
2023-05-16 11:09:57 +00:00
} ;
}
2023-06-20 00:13:39 +00:00
{
# TODO: lift to option declaration
2023-09-12 10:06:01 +00:00
# N.B.: TERMCMD was renamed SXMO_TERMINAL on 2023/08/29
sane . gui . sxmo . settings . SXMO_TERMINAL = lib . mkIf ( cfg . terminal != null )
2023-07-03 22:27:29 +00:00
( lib . mkDefault ( knownTerminals . " ${ cfg . terminal } " or cfg . terminal ) ) ;
2023-06-20 00:13:39 +00:00
sane . gui . sxmo . settings . KEYBOARD = lib . mkIf ( cfg . keyboard != null )
2023-07-03 22:27:29 +00:00
( lib . mkDefault ( knownKeyboards . " ${ cfg . keyboard } " or cfg . keyboard ) ) ;
2023-06-20 00:13:39 +00:00
}
2023-07-13 07:17:09 +00:00
( lib . mkIf cfg . enable ( lib . mkMerge [
{
2023-09-04 11:10:30 +00:00
sane . gui . sway = {
enable = true ;
2023-09-05 04:25:58 +00:00
# we manage the greeter ourselves (TODO: merge this into sway config as well)
2023-09-04 11:10:30 +00:00
useGreeter = false ;
2023-12-01 07:43:20 +00:00
waybar . top = import ./waybar-top.nix { inherit pkgs ; } ;
2023-09-06 02:11:57 +00:00
# reset extra waybar style
waybar . extra_style = " " ;
2023-09-05 04:25:58 +00:00
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.
2023-09-16 14:59:12 +00:00
font = " p a n g o : m o n o s p a c e 1 0 " ;
2023-09-06 07:55:03 +00:00
mod = " M o d 1 " ; # prefer Alt
2023-12-03 13:03:57 +00:00
# about xwayland:
# - required by many electron apps, though some electron apps support NIXOS_OZONE_WL=1 for native wayland.
# - when xwayland is enabled, KOreader incorrectly chooses the X11 backend
# -> slower; blurrier
# - xwayland uses a small amount of memory (like 30MiB, IIRC?)
xwayland = false ;
2023-09-05 04:25:58 +00:00
workspace_layout = " t a b b e d " ;
2023-09-06 07:55:03 +00:00
2023-09-05 04:25:58 +00:00
brightness_down_cmd = " s x m o _ b r i g h t n e s s . s h d o w n " ;
brightness_up_cmd = " s x m o _ b r i g h t n e s s . s h u p " ;
screenshot_cmd = " s x m o _ s c r e e n s h o t . s h " ;
extra_lines =
let
sxmo_init = pkgs . writeShellScript " s x m o _ i n i t . s h " ''
# 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
2023-09-23 11:20:20 +00:00
#
# 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
2023-09-05 04:25:58 +00:00
source " $ X D G _ C O N F I G _ H O M E / s x m o / p r o f i l e "
2023-09-23 11:20:20 +00:00
# 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
2023-09-05 04:25:58 +00:00
_sxmo_prepare_dirs
2023-09-05 18:21:26 +00:00
# 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
2023-09-05 04:25:58 +00:00
sxmo_migrate . sh sync
2023-09-23 11:20:20 +00:00
# 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 " $ X D G _ C O N F I G _ H O M E / s x m o / p r o f i l e "
# 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 = " $ X D G _ C O N F I G _ H O M E / s x m o / h o o k s : $ P A T H "
2023-09-05 04:25:58 +00:00
# kill anything leftover from the previous sxmo run. this way we can (try to) be reentrant
echo " s x m o _ i n i t : k i l l i n g s t a l e d a e m o n s ( i f a c t i v e ) "
2023-11-20 02:31:55 +00:00
sxmo_jobs . sh stop all
2023-09-05 04:25:58 +00:00
pkill bemenu
pkill wvkbd
pkill superd
# configure vol/power-button input mapping (upstream SXMO has this in sway config)
2023-09-23 11:20:20 +00:00
echo " s x m o _ i n i t : c o n f i g u r i n g s w a y b i n d i n g s / d i s p l a y s w i t h : "
2023-09-05 09:14:32 +00:00
echo " S X M O _ P O W E R _ B U T T O N : $ S X M O _ P O W E R _ B U T T O N "
echo " S X M O _ V O L U M E _ B U T T O N : $ S X M O _ V O L U M E _ B U T T O N "
2023-09-23 11:20:20 +00:00
echo " S X M O _ S W A Y _ S C A L E : $ S X M O _ S W A Y _ S C A L E "
2023-09-05 04:25:58 +00:00
sxmo_swayinitconf . sh
echo " s x m o _ i n i t : i n v o k i n g s x m o _ h o o k _ s t a r t . s h w i t h : "
echo " P A T H : $ P A T H "
sxmo_hook_start . sh
'' ;
in ''
# TODO: some of this is probably unnecessary
mode " m e n u " {
# just a placeholder for "menu" mode
bindsym - - input-device = 1 : 1 : 1 c21800 . 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
2023-12-05 08:50:19 +00:00
2023-09-05 04:25:58 +00:00
exec ' printf % s " $ S W A Y S O C K " > " $ X D G _ R U N T I M E _ D I R " /sxmo.swaysock '
2023-12-05 08:50:19 +00:00
# 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
2023-09-05 04:25:58 +00:00
exec_always $ { sxmo_init }
'' ;
} ;
2023-09-04 11:10:30 +00:00
} ;
2023-07-13 07:17:09 +00:00
sane . programs . sxmoApps . enableFor . user . colin = true ;
2023-05-16 11:09:57 +00:00
2023-11-21 08:14:52 +00:00
sane . programs . sway-autoscaler . config . defaultScale = builtins . fromJSON cfg . settings . SXMO_SWAY_SCALE ;
2023-07-13 08:20:30 +00:00
# sxmo internally uses doas instead of sudo
security . doas . enable = true ;
security . doas . wheelNeedsPassword = false ;
2023-05-23 10:54:55 +00:00
2023-07-13 08:20:30 +00:00
# lightdm-mobile-greeter: "The name org.a11y.Bus was not provided by any .service files"
services . gnome . at-spi2-core . enable = true ;
2023-09-03 08:48:43 +00:00
2023-07-13 07:17:09 +00:00
# TODO: could use `displayManager.sessionPackages`?
environment . systemPackages = [
2023-09-05 08:48:18 +00:00
package
2023-09-04 11:10:30 +00:00
pkgs . bonsai # sway (not sxmo) needs to exec `bonsaictl` by name (sxmo_swayinitconf.sh)
2023-07-13 07:17:09 +00:00
] ++ lib . optionals ( cfg . terminal != null ) [ pkgs . " ${ cfg . terminal } " ]
++ lib . optionals ( cfg . keyboard != null ) [ pkgs . " ${ cfg . keyboard } " ] ;
2023-05-19 08:03:51 +00:00
2023-07-13 07:17:09 +00:00
environment . sessionVariables = {
XDG_DATA_DIRS = [
# TODO: only need the share/sxmo directly linked
2023-09-05 08:48:18 +00:00
" ${ package } / s h a r e "
2023-07-13 07:17:09 +00:00
] ;
2023-09-26 00:15:28 +00:00
} // ( lib . filterAttrs ( k : v :
k == " S X M O _ D I S A B L E _ C O N F I G V E R S I O N _ C H E C K " # read before `profile` is sourced
|| k == " S X M O _ T E R M I N A L " # for apps launched via `swaymsg exec -- sxmo_terminal.sh ...`
)
2023-08-29 06:33:20 +00:00
cfg . settings
) ;
2023-05-19 10:18:26 +00:00
2023-11-20 06:46:44 +00:00
sane . gui . sxmo . bonsaid . transitions = let
2023-11-20 08:44:10 +00:00
doExec = inputName : transitions : {
2023-11-20 06:46:44 +00:00
type = " e x e c " ;
command = [
" s e t s i d "
" - f "
" s x m o _ h o o k _ i n p u t h a n d l e r . s h "
inputName
] ;
2023-11-20 08:44:10 +00:00
inherit transitions ;
2023-11-20 06:46:44 +00:00
} ;
2023-11-20 08:44:10 +00:00
onDelay = ms : transitions : {
2023-11-20 06:46:44 +00:00
type = " d e l a y " ;
2023-11-20 08:44:10 +00:00
delay_duration = ms * 1000000 ;
inherit transitions ;
2023-11-20 06:46:44 +00:00
} ;
onEvent = eventName : transitions : {
type = " e v e n t " ;
event_name = eventName ;
inherit transitions ;
} ;
2023-11-20 08:44:10 +00:00
friendlyToBonsai = { timeout ? null , trigger ? null , power_pressed ? { } , power_released ? { } , voldown_pressed ? { } , voldown_released ? { } , volup_pressed ? { } , volup_released ? { } } @ args :
if trigger != null then [
( doExec trigger ( friendlyToBonsai ( builtins . removeAttrs args [ " t r i g g e r " ] ) ) )
] else [
( lib . mkIf ( timeout != null ) ( onDelay ( timeout . ms or 400 ) ( friendlyToBonsai ( builtins . removeAttrs timeout [ " m s " ] ) ) ) )
2023-11-20 07:23:47 +00:00
( lib . mkIf ( power_pressed != { } ) ( onEvent " p o w e r _ p r e s s e d " ( friendlyToBonsai power_pressed ) ) )
( lib . mkIf ( power_released != { } ) ( onEvent " p o w e r _ r e l e a s e d " ( friendlyToBonsai power_released ) ) )
( lib . mkIf ( voldown_pressed != { } ) ( onEvent " v o l d o w n _ p r e s s e d " ( friendlyToBonsai voldown_pressed ) ) )
( lib . mkIf ( voldown_released != { } ) ( onEvent " v o l d o w n _ r e l e a s e d " ( friendlyToBonsai voldown_released ) ) )
( lib . mkIf ( volup_pressed != { } ) ( onEvent " v o l u p _ p r e s s e d " ( friendlyToBonsai volup_pressed ) ) )
( lib . mkIf ( volup_released != { } ) ( onEvent " v o l u p _ r e l e a s e d " ( friendlyToBonsai volup_released ) ) )
] ;
2023-11-20 09:07:51 +00:00
recurseVolUpDown = ttl : if ttl == 0 then {
} else {
voldown_pressed = {
trigger = " p o w e r h o l d _ v o l d o w n " ;
timeout . ms = 1000 ;
power_released = { } ;
} // recurseVolUpDown ( ttl - 1 ) ;
volup_pressed = {
trigger = " p o w e r h o l d _ v o l u p " ;
timeout . ms = 1000 ;
power_released = { } ;
} // recurseVolUpDown ( ttl - 1 ) ;
} ;
2023-11-20 07:23:47 +00:00
in friendlyToBonsai {
# map sequences of "events" to an argument to pass to sxmo_hook_inputhandler.sh
2023-11-20 08:44:10 +00:00
# tap the power button N times to trigger N different actions
2023-12-05 08:54:18 +00:00
power_pressed . timeout . ms = 1100 ; # press w/o release. this is a long timeout because it's tied to the "kill window" action, and interacts with the volume adjustments.
2023-11-20 09:12:43 +00:00
power_pressed . timeout . trigger = " p o w e r h o l d " ;
2023-11-20 08:44:10 +00:00
power_pressed . power_released . timeout . trigger = " p o w e r b u t t o n _ o n e " ;
2023-11-20 09:12:43 +00:00
power_pressed . power_released . timeout . ms = 600 ; # long timeout to make `powertoggle_*` easier
power_pressed . power_released . power_pressed . trigger = " p o w e r b u t t o n _ t w o " ;
# power_pressed.power_released.power_released.timeout.trigger = "powerbutton_two";
# power_pressed.power_released.power_released.power_released.trigger = "powerbutton_three";
2023-11-20 07:23:47 +00:00
2023-11-20 08:44:10 +00:00
# tap power, then tap up/down after releasing it
power_pressed . power_released . voldown_pressed . trigger = " p o w e r t o g g l e _ v o l d o w n " ;
power_pressed . power_released . volup_pressed . trigger = " p o w e r t o g g l e _ v o l u p " ;
# chording: hold power and then tap vol-up N times to adjust the volume by N increments.
2023-11-20 09:07:51 +00:00
# XXX: HOLDING POWER LIKE THIS IS RISKY. but the default hard-power-off is like 10s, so... i guess this works until it becomes a problem...?
power_pressed . voldown_pressed = ( recurseVolUpDown 5 ) . voldown_pressed ;
power_pressed . volup_pressed = ( recurseVolUpDown 5 ) . volup_pressed ;
2023-11-20 07:23:47 +00:00
2023-11-20 08:44:10 +00:00
# tap just one of the volume buttons.
volup_pressed . trigger = " v o l u p _ o n e " ;
2023-12-05 10:02:19 +00:00
voldown_pressed . trigger = " v o l d o w n _ o n e " ;
voldown_pressed . voldown_released = { } ; # return to root state
voldown_pressed . timeout . trigger = " v o l d o w n _ h o l d " ;
voldown_pressed . timeout . ms = 500 ;
2023-11-20 07:23:47 +00:00
} ;
2023-11-20 06:46:44 +00:00
2023-09-04 11:10:30 +00:00
# sxmo puts in /share/sxmo:
# - profile.d/sxmo_init.sh
# - appcfg/
# - default_hooks/
# - and more
# environment.pathsToLink = [ "/share/sxmo" ];
2023-07-13 07:17:09 +00:00
systemd . services . " s x m o - s e t - p e r m i s s i o n s " = {
2023-09-17 08:44:31 +00:00
# TODO: some of these could be modified to be udev rules
2023-07-13 07:17:09 +00:00
description = " c o n f i g u r e s p e c i f i c / s y s a n d / d e v n o d e s t o b e w r i t a b l e b y s x m o s c r i p t s " ;
serviceConfig = {
Type = " o n e s h o t " ;
2023-09-05 08:48:18 +00:00
ExecStart = " ${ package } / b i n / s x m o _ s e t p e r m i s s i o n s . s h " ;
2023-07-13 07:17:09 +00:00
} ;
2023-09-17 08:44:31 +00:00
wantedBy = [ " m u l t i - u s e r . t a r g e t " ] ;
2023-07-13 07:17:09 +00:00
} ;
2023-07-12 10:03:58 +00:00
2023-07-24 01:36:13 +00:00
# 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>
2023-11-26 07:01:13 +00:00
# startTimerDuration = 100 * time.Millisecond
2023-07-24 01:36:13 +00:00
# TODO: better fix may be to patch `sxmo_hook_lisgdstart.sh` and force it to behave as a singleton
2023-10-09 00:24:47 +00:00
# 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";
# };
# };
2023-07-24 01:36:13 +00:00
2023-09-05 17:20:48 +00:00
sane . user . fs = lib . mkMerge [
{
2023-10-08 17:12:53 +00:00
# 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
" . c o n f i g / s x m o / h o o k s / b i n " . symlink . target = " . " ;
2023-09-05 17:20:48 +00:00
" . c a c h e / s x m o / s x m o . n o i d l e " = lib . mkIf cfg . noidle {
symlink . text = " " ;
} ;
" . c a c h e / s x m o / s x m o . n o g e s t u r e " = lib . mkIf cfg . nogesture {
symlink . text = " " ;
} ;
" . c o n f i g / s x m o / p r o f i l e " . symlink . text = let
mkKeyValue = key : value : '' e x p o r t ${ 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 = " . c o n f i g / s x m o / h o o k s / ${ name } " ;
value . symlink . target = value ;
} ) cfg . hooks )
] ;
2023-10-08 17:12:53 +00:00
sane . user . services = let
2023-10-09 00:24:47 +00:00
sxmoPath = [
" / e t c / p r o f i l e s / p e r - u s e r / c o l i n " # so as to launch user-enabled applications (like g4music, etc)
" / r u n / w r a p p e r s " # for doas, and anything else suid
" / r u n / c u r r e n t - s y s t e m / s w " # for things installed system-wide, especially flock
] ++ [ 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 " $ X D G _ C O N F I G _ H O M E / s x m o / p r o f i l e "
source $ { package } /etc/profile.d/sxmo_init.sh
source " $ X D G _ C O N F I G _ H O M E / s x m o / p r o f i l e "
export PATH = " $ X D G _ C O N F I G _ H O M E / s x m o / h o o k s : $ P A T H "
'' ;
2023-10-08 17:12:53 +00:00
sxmoService = name : {
description = " s x m o ${ name } " ;
path = sxmoPath ;
2023-10-09 00:24:47 +00:00
script = ''
$ { sxmoEnvSetup }
exec sxmo_ $ { name } . sh
'' ;
2023-10-08 17:12:53 +00:00
serviceConfig . Type = " s i m p l e " ;
serviceConfig . Restart = " a l w a y s " ;
serviceConfig . RestartSec = " 2 0 s " ;
} ;
in {
sxmo_autosuspend = sxmoService " a u t o s u s p e n d " ;
sxmo_battery_monitor = sxmoService " b a t t e r y _ m o n i t o r " ;
sxmo_desktop_widget = sxmoService " h o o k _ d e s k t o p _ w i d g e t " ;
sxmo_hook_lisgd = sxmoService " h o o k _ l i s g d s t a r t " ;
sxmo_menumode_toggler = sxmoService " m e n u m o d e _ t o g g l e r " ;
sxmo_modemmonitor = sxmoService " m o d e m m o n i t o r " ;
sxmo_networkmonitor = sxmoService " n e t w o r k m o n i t o r " ;
sxmo_notificationmonitor = sxmoService " n o t i f i c a t i o n m o n i t o r " ;
sxmo_soundmonitor = sxmoService " s o u n d m o n i t o r " ;
sxmo_wob = sxmoService " w o b " ;
sxmo-x11-status = sxmoService " s t a t u s _ x s e t r o o t " ;
2023-11-20 02:31:23 +00:00
bonsaid . path = sxmoPath ;
bonsaid . script = lib . mkBefore sxmoEnvSetup ;
2023-10-08 17:12:53 +00:00
} ;
2023-07-13 07:17:09 +00:00
}
2023-05-23 04:43:27 +00:00
2023-07-13 07:17:09 +00:00
( lib . mkIf ( cfg . greeter == " l i g h t d m - m o b i l e " ) {
2023-11-08 15:32:50 +00:00
sane . persist . sys . byStore . plaintext = [
2023-07-13 06:56:03 +00:00
# this takes up 4-5 MB of fontconfig and mesa shader caches.
# it could optionally be cleared on boot.
{ path = " / v a r / l i b / l i g h t d m " ; user = " l i g h t d m " ; group = " l i g h t d m " ; mode = " 0 7 7 0 " ; }
] ;
2023-07-13 07:17:09 +00:00
services . xserver = {
enable = true ;
2023-05-19 10:18:26 +00:00
2023-07-13 07:17:09 +00:00
displayManager . lightdm . enable = true ;
displayManager . lightdm . greeters . mobile . enable = true ;
displayManager . lightdm . extraSeatDefaults = ''
user-session = swmo
2023-05-19 10:18:26 +00:00
'' ;
2023-07-13 07:17:09 +00:00
displayManager . sessionPackages = with pkgs ; [
2023-09-05 08:48:18 +00:00
package # this gets share/wayland-sessions/swmo.desktop linked
2023-07-13 07:17:09 +00:00
] ;
# taken from gui/phosh:
# NB: setting defaultSession has the critical side-effect that it lets org.freedesktop.AccountsService
# know that our user exists. this ensures lightdm succeeds when calling /org/freedesktop/AccountsServices ListCachedUsers
# lightdm greeters get the login users from lightdm which gets it from org.freedesktop.Accounts.ListCachedUsers.
# this requires the user we want to login as to be cached.
displayManager . job . preStart = ''
$ { pkgs . systemd } /bin/busctl call org . freedesktop . Accounts /org/freedesktop/Accounts org . freedesktop . Accounts CacheUser s colin
'' ;
2023-06-23 08:30:18 +00:00
} ;
2023-07-13 07:17:09 +00:00
} )
2023-06-23 08:30:18 +00:00
2023-09-04 01:06:16 +00:00
( lib . mkIf ( cfg . greeter == " g r e e t d - s w a y - g t k g r e e t " ) {
2023-09-02 00:49:44 +00:00
sane . gui . greetd = {
2023-07-13 07:17:09 +00:00
enable = true ;
2023-09-02 00:49:44 +00:00
sway . enable = true ;
sway . gtkgreet . enable = true ;
2023-09-02 00:54:05 +00:00
sway . gtkgreet . session . name = " s x m o - o n - g t k g r e e t " ;
2023-09-04 11:10:30 +00:00
sway . gtkgreet . session . command = " ${ pkgs . sway } / b i n / s w a y - - d e b u g " ;
2023-07-13 07:17:09 +00:00
} ;
} )
2023-05-23 04:43:27 +00:00
2023-08-26 12:28:25 +00:00
( lib . mkIf ( cfg . greeter == " g r e e t d - s w a y - p h o g " ) {
2023-09-02 00:49:44 +00:00
sane . gui . greetd = {
2023-08-26 12:28:25 +00:00
enable = true ;
2023-09-02 00:49:44 +00:00
sway . enable = true ;
sway . greeterCmd = " ${ pkgs . phog } / l i b e x e c / p h o g " ;
2023-08-26 12:28:25 +00:00
} ;
2023-09-08 10:59:31 +00:00
# phog locates sxmo_winit.sh (or sway.desktop) via <env>/share/wayland-sessions
2023-08-26 12:28:25 +00:00
environment . pathsToLink = [ " / s h a r e / w a y l a n d - s e s s i o n s " ] ;
} )
2023-08-26 09:40:07 +00:00
( lib . mkIf ( cfg . greeter == " g r e e t d - p h o g " ) {
2023-09-02 00:49:44 +00:00
sane . gui . greetd = {
2023-08-25 01:25:07 +00:00
enable = true ;
2023-09-02 00:49:44 +00:00
session . name = " p h o g " ;
session . command = " ${ pkgs . phog } / b i n / p h o g " ;
2023-08-25 01:25:07 +00:00
} ;
2023-09-08 10:59:31 +00:00
# phog locates sxmo_winit.sh (or sway.desktop) via <env>/share/wayland-sessions
2023-08-25 13:29:29 +00:00
environment . pathsToLink = [ " / s h a r e / w a y l a n d - s e s s i o n s " ] ;
2023-08-25 01:25:07 +00:00
} )
2023-08-26 12:28:25 +00:00
( lib . mkIf ( cfg . greeter == " g r e e t d - s x m o " ) {
2023-09-02 00:49:44 +00:00
sane . gui . greetd = {
2023-08-26 12:28:25 +00:00
enable = true ;
2023-09-02 00:49:44 +00:00
session . name = " s x m o " ;
2023-09-05 08:48:18 +00:00
# session.command = "${package}/bin/sxmo_winit.sh";
2023-09-04 11:10:30 +00:00
session . command = " ${ pkgs . sway } / b i n / s w a y - - d e b u g " ;
2023-09-02 00:49:44 +00:00
session . user = " c o l i n " ;
2023-08-26 12:28:25 +00:00
} ;
} )
2023-07-13 07:17:09 +00:00
# old, greeterless options:
2023-05-19 10:18:26 +00:00
# services.xserver.windowManager.session = [{
# name = "sxmo";
# desktopNames = [ "sxmo" ];
# start = ''
2023-09-05 08:48:18 +00:00
# ${package}/bin/sxmo_xinit.sh &
2023-05-19 10:18:26 +00:00
# waitPID=$!
# '';
# }];
# services.xserver.enable = true;
2023-07-13 07:17:09 +00:00
] ) )
2023-05-16 11:09:57 +00:00
] ;
}