Merge pull request #127157 from nh2/xserver-readable-config-indentation
xserver: Generate readable config indentation
This commit is contained in:
commit
e85693afde
@ -188,27 +188,27 @@ let cfg = config.services.xserver.libinput;
|
||||
};
|
||||
|
||||
mkX11ConfigForDevice = deviceType: matchIs: ''
|
||||
Identifier "libinput ${deviceType} configuration"
|
||||
MatchDriver "libinput"
|
||||
MatchIs${matchIs} "${xorgBool true}"
|
||||
${optionalString (cfg.${deviceType}.dev != null) ''MatchDevicePath "${cfg.${deviceType}.dev}"''}
|
||||
Option "AccelProfile" "${cfg.${deviceType}.accelProfile}"
|
||||
${optionalString (cfg.${deviceType}.accelSpeed != null) ''Option "AccelSpeed" "${cfg.${deviceType}.accelSpeed}"''}
|
||||
${optionalString (cfg.${deviceType}.buttonMapping != null) ''Option "ButtonMapping" "${cfg.${deviceType}.buttonMapping}"''}
|
||||
${optionalString (cfg.${deviceType}.calibrationMatrix != null) ''Option "CalibrationMatrix" "${cfg.${deviceType}.calibrationMatrix}"''}
|
||||
${optionalString (cfg.${deviceType}.clickMethod != null) ''Option "ClickMethod" "${cfg.${deviceType}.clickMethod}"''}
|
||||
Option "LeftHanded" "${xorgBool cfg.${deviceType}.leftHanded}"
|
||||
Option "MiddleEmulation" "${xorgBool cfg.${deviceType}.middleEmulation}"
|
||||
Option "NaturalScrolling" "${xorgBool cfg.${deviceType}.naturalScrolling}"
|
||||
${optionalString (cfg.${deviceType}.scrollButton != null) ''Option "ScrollButton" "${toString cfg.${deviceType}.scrollButton}"''}
|
||||
Option "ScrollMethod" "${cfg.${deviceType}.scrollMethod}"
|
||||
Option "HorizontalScrolling" "${xorgBool cfg.${deviceType}.horizontalScrolling}"
|
||||
Option "SendEventsMode" "${cfg.${deviceType}.sendEventsMode}"
|
||||
Option "Tapping" "${xorgBool cfg.${deviceType}.tapping}"
|
||||
Option "TappingDragLock" "${xorgBool cfg.${deviceType}.tappingDragLock}"
|
||||
Option "DisableWhileTyping" "${xorgBool cfg.${deviceType}.disableWhileTyping}"
|
||||
${cfg.${deviceType}.additionalOptions}
|
||||
'';
|
||||
Identifier "libinput ${deviceType} configuration"
|
||||
MatchDriver "libinput"
|
||||
MatchIs${matchIs} "${xorgBool true}"
|
||||
${optionalString (cfg.${deviceType}.dev != null) ''MatchDevicePath "${cfg.${deviceType}.dev}"''}
|
||||
Option "AccelProfile" "${cfg.${deviceType}.accelProfile}"
|
||||
${optionalString (cfg.${deviceType}.accelSpeed != null) ''Option "AccelSpeed" "${cfg.${deviceType}.accelSpeed}"''}
|
||||
${optionalString (cfg.${deviceType}.buttonMapping != null) ''Option "ButtonMapping" "${cfg.${deviceType}.buttonMapping}"''}
|
||||
${optionalString (cfg.${deviceType}.calibrationMatrix != null) ''Option "CalibrationMatrix" "${cfg.${deviceType}.calibrationMatrix}"''}
|
||||
${optionalString (cfg.${deviceType}.clickMethod != null) ''Option "ClickMethod" "${cfg.${deviceType}.clickMethod}"''}
|
||||
Option "LeftHanded" "${xorgBool cfg.${deviceType}.leftHanded}"
|
||||
Option "MiddleEmulation" "${xorgBool cfg.${deviceType}.middleEmulation}"
|
||||
Option "NaturalScrolling" "${xorgBool cfg.${deviceType}.naturalScrolling}"
|
||||
${optionalString (cfg.${deviceType}.scrollButton != null) ''Option "ScrollButton" "${toString cfg.${deviceType}.scrollButton}"''}
|
||||
Option "ScrollMethod" "${cfg.${deviceType}.scrollMethod}"
|
||||
Option "HorizontalScrolling" "${xorgBool cfg.${deviceType}.horizontalScrolling}"
|
||||
Option "SendEventsMode" "${cfg.${deviceType}.sendEventsMode}"
|
||||
Option "Tapping" "${xorgBool cfg.${deviceType}.tapping}"
|
||||
Option "TappingDragLock" "${xorgBool cfg.${deviceType}.tappingDragLock}"
|
||||
Option "DisableWhileTyping" "${xorgBool cfg.${deviceType}.disableWhileTyping}"
|
||||
${cfg.${deviceType}.additionalOptions}
|
||||
'';
|
||||
in {
|
||||
|
||||
imports =
|
||||
|
@ -81,13 +81,7 @@ let
|
||||
monitors = forEach xrandrHeads (h: ''
|
||||
Option "monitor-${h.config.output}" "${h.name}"
|
||||
'');
|
||||
# First option is indented through the space in the config but any
|
||||
# subsequent options aren't so we need to apply indentation to
|
||||
# them here
|
||||
monitorsIndented = if length monitors > 1
|
||||
then singleton (head monitors) ++ map (m: " " + m) (tail monitors)
|
||||
else monitors;
|
||||
in concatStrings monitorsIndented;
|
||||
in concatStrings monitors;
|
||||
|
||||
# Here we chain every monitor from the left to right, so we have:
|
||||
# m4 right of m3 right of m2 right of m1 .----.----.----.----.
|
||||
@ -138,10 +132,15 @@ let
|
||||
|
||||
echo '${cfg.filesSection}' >> $out
|
||||
echo 'EndSection' >> $out
|
||||
echo >> $out
|
||||
|
||||
echo "$config" >> $out
|
||||
''; # */
|
||||
|
||||
prefixStringLines = prefix: str:
|
||||
concatMapStringsSep "\n" (line: prefix + line) (splitString "\n" str);
|
||||
|
||||
indent = prefixStringLines " ";
|
||||
in
|
||||
|
||||
{
|
||||
@ -736,29 +735,29 @@ in
|
||||
Section "ServerFlags"
|
||||
Option "AllowMouseOpenFail" "on"
|
||||
Option "DontZap" "${if cfg.enableCtrlAltBackspace then "off" else "on"}"
|
||||
${cfg.serverFlagsSection}
|
||||
${indent cfg.serverFlagsSection}
|
||||
EndSection
|
||||
|
||||
Section "Module"
|
||||
${cfg.moduleSection}
|
||||
${indent cfg.moduleSection}
|
||||
EndSection
|
||||
|
||||
Section "Monitor"
|
||||
Identifier "Monitor[0]"
|
||||
${cfg.monitorSection}
|
||||
${indent cfg.monitorSection}
|
||||
EndSection
|
||||
|
||||
# Additional "InputClass" sections
|
||||
${flip concatMapStrings cfg.inputClassSections (inputClassSection: ''
|
||||
Section "InputClass"
|
||||
${inputClassSection}
|
||||
EndSection
|
||||
${flip (concatMapStringsSep "\n") cfg.inputClassSections (inputClassSection: ''
|
||||
Section "InputClass"
|
||||
${indent inputClassSection}
|
||||
EndSection
|
||||
'')}
|
||||
|
||||
|
||||
Section "ServerLayout"
|
||||
Identifier "Layout[all]"
|
||||
${cfg.serverLayoutSection}
|
||||
${indent cfg.serverLayoutSection}
|
||||
# Reference the Screen sections for each driver. This will
|
||||
# cause the X server to try each in turn.
|
||||
${flip concatMapStrings (filter (d: d.display) cfg.drivers) (d: ''
|
||||
@ -781,9 +780,9 @@ in
|
||||
Identifier "Device-${driver.name}[0]"
|
||||
Driver "${driver.driverName or driver.name}"
|
||||
${if cfg.useGlamor then ''Option "AccelMethod" "glamor"'' else ""}
|
||||
${cfg.deviceSection}
|
||||
${driver.deviceSection or ""}
|
||||
${xrandrDeviceSection}
|
||||
${indent cfg.deviceSection}
|
||||
${indent (driver.deviceSection or "")}
|
||||
${indent xrandrDeviceSection}
|
||||
EndSection
|
||||
${optionalString driver.display ''
|
||||
|
||||
@ -794,18 +793,22 @@ in
|
||||
Monitor "Monitor[0]"
|
||||
''}
|
||||
|
||||
${cfg.screenSection}
|
||||
${driver.screenSection or ""}
|
||||
${indent cfg.screenSection}
|
||||
${indent (driver.screenSection or "")}
|
||||
|
||||
${optionalString (cfg.defaultDepth != 0) ''
|
||||
DefaultDepth ${toString cfg.defaultDepth}
|
||||
''}
|
||||
|
||||
${optionalString
|
||||
(driver.name != "virtualbox" &&
|
||||
(
|
||||
driver.name != "virtualbox"
|
||||
&&
|
||||
(cfg.resolutions != [] ||
|
||||
cfg.extraDisplaySettings != "" ||
|
||||
cfg.virtualScreen != null))
|
||||
cfg.virtualScreen != null
|
||||
)
|
||||
)
|
||||
(let
|
||||
f = depth:
|
||||
''
|
||||
@ -813,7 +816,7 @@ in
|
||||
Depth ${toString depth}
|
||||
${optionalString (cfg.resolutions != [])
|
||||
"Modes ${concatMapStrings (res: ''"${toString res.x}x${toString res.y}"'') cfg.resolutions}"}
|
||||
${cfg.extraDisplaySettings}
|
||||
${indent cfg.extraDisplaySettings}
|
||||
${optionalString (cfg.virtualScreen != null)
|
||||
"Virtual ${toString cfg.virtualScreen.x} ${toString cfg.virtualScreen.y}"}
|
||||
EndSubSection
|
||||
|
@ -87,9 +87,9 @@ with lib;
|
||||
})
|
||||
|
||||
(mkIf (cfg.emulateWheel) {
|
||||
services.xserver.inputClassSections =
|
||||
[''
|
||||
Identifier "Trackpoint Wheel Emulation"
|
||||
services.xserver.inputClassSections = [
|
||||
''
|
||||
Identifier "Trackpoint Wheel Emulation"
|
||||
MatchProduct "${if cfg.fakeButtons then "PS/2 Generic Mouse" else "ETPS/2 Elantech TrackPoint|Elantech PS/2 TrackPoint|TPPS/2 IBM TrackPoint|DualPoint Stick|Synaptics Inc. Composite TouchPad / TrackPoint|ThinkPad USB Keyboard with TrackPoint|USB Trackpoint pointing device|Composite TouchPad / TrackPoint|${cfg.device}"}"
|
||||
MatchDevicePath "/dev/input/event*"
|
||||
Option "EmulateWheel" "true"
|
||||
@ -97,7 +97,8 @@ with lib;
|
||||
Option "Emulate3Buttons" "false"
|
||||
Option "XAxisMapping" "6 7"
|
||||
Option "YAxisMapping" "4 5"
|
||||
''];
|
||||
''
|
||||
];
|
||||
})
|
||||
|
||||
(mkIf cfg.fakeButtons {
|
||||
|
Loading…
Reference in New Issue
Block a user