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