summaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
Diffstat (limited to 'manifests')
-rw-r--r--manifests/config.pp52
-rw-r--r--manifests/init.pp11
2 files changed, 63 insertions, 0 deletions
diff --git a/manifests/config.pp b/manifests/config.pp
new file mode 100644
index 0000000..3657a66
--- /dev/null
+++ b/manifests/config.pp
@@ -0,0 +1,52 @@
+# @summary Configures specific Xorg section
+# https://www.x.org/releases/current/doc/man/man5/xorg.conf.5.xhtml
+#
+# @param section
+# Which section, such as Montior, ...
+# @param identifier
+# Item used for the Identifier key in the section bolck
+# @param no_identifier
+# Set to true if the output shouldn't contain an identifier entry.
+# @param filename
+# What the output file should be called.
+# TODO validate that this is a local part of a filename. Mostly that
+# / is forbidden.
+# @param options
+# Option directives to xorg. A list of tuples instead of a hash
+# until I figure out if the same option can be given multiple times.
+# @param entries
+# Xorg entries.
+# @param priority
+# Priority of this file compared to all other configuration files.
+define xorg::config (
+ String $section,
+ String $identifier = $name,
+ Boolean $no_identifier = false,
+ String $filename = xorg::normalize_filename($name),
+ Array[Tuple[String, Xorg::Value]] $options = [],
+ Hash[String, Xorg::Value] $entries = {},
+ Variant[String[2, 2], Integer[0, 99]] $priority = '20',
+) {
+ include xorg
+
+ # Convert priority to 0-padded string of length 2
+ $priority_ = $priority ? {
+ String => $priority,
+ Integer => if $priority < 10 {
+ "0${priority}"
+ } else {
+ $priority
+ }
+ }
+
+ # TODO possibly allow multiple entries to share files.
+ # For example, all monitor settings could go in a single file
+ file { "${xorg::conf_dir}/${priority_}-${filename}.conf":
+ ensure => file,
+ content => epp("${module_name}/xorg.conf.epp", {
+ 'identifier' => if $no_identifier { undef } else { $identifier },
+ 'options' => $options,
+ 'entries' => $entries,
+ }),
+ }
+}
diff --git a/manifests/init.pp b/manifests/init.pp
new file mode 100644
index 0000000..281daa4
--- /dev/null
+++ b/manifests/init.pp
@@ -0,0 +1,11 @@
+# @summary Prepares for configuring xorg
+# @param conf_dir
+# Where puppet generated configuration files should be placed.
+class xorg (
+ String $conf_dir = '/etc/X11/xorg.conf.d'
+) {
+ file { $conf_dir:
+ ensure => directory,
+ recurse => false,
+ }
+}