1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7
8with lib;
9
10let
11 cfg = config.services.xserver.desktopManager.surf-display;
12
13 surfDisplayConf = ''
14 # Surf Kiosk Display: Wrap around surf browser and turn your
15 # system into a browser screen in KIOSK-mode.
16
17 # default download URI for all display screens if not configured individually
18 DEFAULT_WWW_URI="${cfg.defaultWwwUri}"
19
20 # Enforce fixed resolution for all displays (default: not set):
21 #DEFAULT_RESOLUTION="1920x1080"
22
23 # HTTP proxy URL, if needed (default: not set).
24 #HTTP_PROXY_URL="http://webcache:3128"
25
26 # Setting for internal inactivity timer to restart surf-display
27 # if the user goes inactive/idle.
28 INACTIVITY_INTERVAL="${builtins.toString cfg.inactivityInterval}"
29
30 # log to syslog instead of .xsession-errors
31 LOG_TO_SYSLOG="yes"
32
33 # Launch pulseaudio daemon if not already running.
34 WITH_PULSEAUDIO="yes"
35
36 # screensaver settings, see "man 1 xset" for possible options
37 SCREENSAVER_SETTINGS="${cfg.screensaverSettings}"
38
39 # disable right and middle pointer device click in browser sessions while keeping
40 # scrolling wheels' functionality intact... (consider "pointer" subcommand on
41 # xmodmap man page for details).
42 POINTER_BUTTON_MAP="${cfg.pointerButtonMap}"
43
44 # Hide idle mouse pointer.
45 HIDE_IDLE_POINTER="${cfg.hideIdlePointer}"
46
47 ${cfg.extraConfig}
48 '';
49
50in
51{
52 options = {
53 services.xserver.desktopManager.surf-display = {
54 enable = mkEnableOption "surf-display as a kiosk browser session";
55
56 defaultWwwUri = mkOption {
57 type = types.str;
58 default = "${pkgs.surf-display}/share/surf-display/empty-page.html";
59 defaultText = literalExpression ''"''${pkgs.surf-display}/share/surf-display/empty-page.html"'';
60 example = "https://www.example.com/";
61 description = "Default URI to display.";
62 };
63
64 inactivityInterval = mkOption {
65 type = types.int;
66 default = 300;
67 example = 0;
68 description = ''
69 Setting for internal inactivity timer to restart surf-display if the
70 user goes inactive/idle to get a fresh session for the next user of
71 the kiosk.
72
73 If this value is set to zero, the whole feature of restarting due to
74 inactivity is disabled.
75 '';
76 };
77
78 screensaverSettings = mkOption {
79 type = types.separatedString " ";
80 default = "";
81 description = ''
82 Screensaver settings, see `man 1 xset` for possible options.
83 '';
84 };
85
86 pointerButtonMap = mkOption {
87 type = types.str;
88 default = "1 0 0 4 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0";
89 description = ''
90 Disable right and middle pointer device click in browser sessions
91 while keeping scrolling wheels' functionality intact. See pointer
92 subcommand on `man xmodmap` for details.
93 '';
94 };
95
96 hideIdlePointer = mkOption {
97 type = types.str;
98 default = "yes";
99 example = "no";
100 description = "Hide idle mouse pointer.";
101 };
102
103 extraConfig = mkOption {
104 type = types.lines;
105 default = "";
106 example = ''
107 # Enforce fixed resolution for all displays (default: not set):
108 DEFAULT_RESOLUTION="1920x1080"
109
110 # HTTP proxy URL, if needed (default: not set).
111 HTTP_PROXY_URL="http://webcache:3128"
112
113 # Configure individual display screens with host specific parameters:
114 DISPLAYS['display-host-0']="www_uri=https://www.displayserver.comany.net/display-1/index.html"
115 DISPLAYS['display-host-1']="www_uri=https://www.displayserver.comany.net/display-2/index.html"
116 DISPLAYS['display-host-2']="www_uri=https://www.displayserver.comany.net/display-3/index.html|res=1920x1280"
117 DISPLAYS['display-host-3']="www_uri=https://www.displayserver.comany.net/display-4/index.html"|res=1280x1024"
118 DISPLAYS['display-host-local-file']="www_uri=file:///usr/share/doc/surf-display/empty-page.html"
119 '';
120 description = ''
121 Extra configuration options to append to `/etc/default/surf-display`.
122 '';
123 };
124 };
125 };
126
127 config = mkIf cfg.enable {
128 services.displayManager.sessionPackages = [
129 pkgs.surf-display
130 ];
131
132 environment.etc."default/surf-display".text = surfDisplayConf;
133 };
134}