diff --git a/hosts/adventurer.toml b/hosts/adventurer.toml index 6335841..3ab89f0 100644 --- a/hosts/adventurer.toml +++ b/hosts/adventurer.toml @@ -1,15 +1,31 @@ -is-virtual = false -base16-scheme = "seti" wireless = ["wlp5s0"] ethernet = ["enp6s0"] -disks = ["/"] # hwmon2 = k10temp, temp1 = Tctl temperature-path = "/sys/class/hwmon/hwmon2/temp1_input" -outputs = [ - "\"ASUSTek COMPUTER INC VG258 M1LMQS004947\" position 0 1080 mode 1920x1080@165Hz bg ~/.local/share/backgrounds/adventurer/l.jpg fill", - "\"BNQ BenQ GL2580 46J02196SL0\" position 1920 1080 mode 1920x1080@60Hz bg ~/.local/share/backgrounds/adventurer/r.jpg fill", - "\"BNQ BenQ GL2580 46J02151SL0\" position 960 0 mode 1920x1080@60Hz bg ~/.local/share/backgrounds/adventurer/t.jpg fill ", - "\"Pioneer Electronic Corporation AV Receiver Unknown\" mode 3840x2160@60Hz scale 2.0 bg ~/.local/share/backgrounds/adventurer/full.jpg fill", -] -default-background = false +[[outputs]] +match = "*" +background = ["~/.local/share/backgrounds/adventurer/full.jpg", "fill"] + +[[outputs]] +match = "ASUSTek COMPUTER INC VG258 M1LMQS004947" +position = [0, 1080] +mode = "1920x1080@165Hz" +background = ["~/.local/share/backgrounds/adventurer/l.jpg", "fill"] + +[[outputs]] +match = "BNQ BenQ GL2580 46J02196SL0" +position = [1920, 1080] +mode = "1920x1080@60Hz" +background = ["~/.local/share/backgrounds/adventurer/r.jpg", "fill"] + +[[outputs]] +match = "BNQ BenQ GL2580 46J02151SL0" +position = [960, 0] +mode = "1920x1080@60Hz" +background = ["~/.local/share/backgrounds/adventurer/t.jpg", "fill"] + +[[outputs]] +match = "Pioneer Electronic Corporation AV Receiver Unknown" +mode = "3840x2160@60Hz" +scale = 2 diff --git a/hosts/concord.toml b/hosts/concord.toml index b33040f..c46811e 100644 --- a/hosts/concord.toml +++ b/hosts/concord.toml @@ -1,11 +1,11 @@ -is-virtual = false -base16-scheme = "seti" wireless = ["wlp0s20f3"] ethernet = ["eno1"] -disks = ["/"] -outputs = [ - "* bg ~/.local/share/backgrounds/concord/full.jpg fill", - "\"Pioneer Electronic Corporation AV Receiver Unknown\" mode 3840x2160@60Hz scale 2.0", -] -default-background = false +[[outputs]] +match = "*" +background = ["~/.local/share/backgrounds/concord/full.jpg", "fill"] + +[[outputs]] +match = "Pioneer Electronic Corporation AV Receiver Unknown" +mode = "3840x2160@60Hz" +scale = 2 diff --git a/hosts/default.toml b/hosts/default.toml new file mode 100644 index 0000000..e5ec4e8 --- /dev/null +++ b/hosts/default.toml @@ -0,0 +1,10 @@ +is-virtual = false +base16-scheme = "seti" +disks = ["/"] +system-font = "Fira Sans" +system-mono-font = "Fira Mono" +#temperature-path = "" + +[[outputs]] +match = "*" +background = ["~/.local/share/backgrounds/sway-dark-1920x1080.png", "fill"] diff --git a/hosts/faithful.toml b/hosts/faithful.toml index b875ff0..4db7ae8 100644 --- a/hosts/faithful.toml +++ b/hosts/faithful.toml @@ -1,10 +1,7 @@ -base16-scheme = "seti" wireless = ["wlp4s0"] ethernet = ["enp2s0"] -disks = ["/"] temperature-path = "/sys/class/hwmon/hwmon5/temp1_input" -outputs = [ - "* bg ~/.local/share/backgrounds/faithful/full.jpg fill", -] -default-background = false +[[outputs]] +match = "*" +background = ["~/.local/share/backgrounds/faithful/full.jpg", "fill"] diff --git a/hosts/roost.toml b/hosts/roost.toml deleted file mode 100644 index 5ab4268..0000000 --- a/hosts/roost.toml +++ /dev/null @@ -1,10 +0,0 @@ -base16-scheme = "seti" -wireless = ["wlan0"] -ethernet = ["eth0"] -disks = ["/"] - -outputs = [ - "HDMI-A-1 mode 3840x2160@30Hz scale 2.0", - #TODO when HDMI cable arrives - #"name HDMI-A-1 mode 3840x2160@60Hz scale 2.0", -] diff --git a/install.py b/install.py index 5defa64..2a47d82 100755 --- a/install.py +++ b/install.py @@ -4,6 +4,7 @@ import argparse import os import shutil import socket +import subprocess import sys from functools import partial from pathlib import Path @@ -79,15 +80,48 @@ def main(): raw_dir = args.dotfiles / 'raw' templates_dir = args.dotfiles / 'templates' include_dir = args.dotfiles / 'include' + default_host_filename = args.dotfiles / 'hosts' / 'default.toml' host_filename = args.dotfiles / 'hosts' / '{}.toml'.format(args.hostname) + with open(default_host_filename) as host_file: + host_config = toml.load(host_file) + if host_filename.exists(): with open(host_filename) as host_file: - host_config = toml.load(host_file) - else: - host_config = {} + host_config.update(toml.load(host_file)) + host_config['name'] = args.hostname + # Preprocess output configs for sway + for output in host_config['outputs']: + # Generate config lines for sway template + lines = [] + for key in output: + if key == 'match': + continue + if isinstance(output[key], list): + val = ' '.join(repr(elem) for elem in output[key]) + else: + val = repr(output[key]) + lines.append(f'{key} {val}') + + output['sway-lines'] = lines + + # Attempt to resolve device names for swaylock template + # (Workaround https://github.com/swaywm/swaylock/issues/114) + # + # This will only work if this is run on the target host + # and if sway is running, but that is usually the case... + if output['match'] != '*': + get_outputs = subprocess.check_output( + ['swaymsg', '-t', 'get_outputs', '-p'], + ).decode('utf-8') + for line in get_outputs.splitlines(): + # Line format: Output '' + if line.startswith('Output') and output['match'] in line: + output['device'] = line.split()[1] + break + lookup = mako.lookup.TemplateLookup( directories=[ str(templates_dir), diff --git a/templates/.config/sway/config b/templates/.config/sway/config index 265a9d3..b717dec 100644 --- a/templates/.config/sway/config +++ b/templates/.config/sway/config @@ -38,12 +38,12 @@ client.placeholder $base01 $base01 $base05 $base01 $base01 client.background $base07 % for output in host.get('outputs', []): -output ${output} +output ${repr(output['match'])} { +% for line in output['sway-lines']: + ${line} +% endfor +} % endfor - -% if host.get('default-background', True): -output * bg ${home}/.local/share/backgrounds/sway-dark-1920x1080.png fill -% endif gaps inner 8 @@ -63,7 +63,7 @@ exec swayidle exec dunst exec udiskie -font pango:Fira Mono 8 +font pango:${host['system-mono-font']} 8 focus_follows_mouse no floating_modifier $mod @@ -155,7 +155,7 @@ bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle bar { tray_output none status_command i3status - font pango:Fira Mono 10 + font pango:${host['system-mono-font']} 10 ${get_base16('i3', 'bar-colors')} diff --git a/templates/.config/swaylock/config b/templates/.config/swaylock/config new file mode 100644 index 0000000..a52a915 --- /dev/null +++ b/templates/.config/swaylock/config @@ -0,0 +1,15 @@ +ignore-empty-password +indicator-idle-visible +color=000000 +scaling=fill +font=${host['system-font']} + +% for output in host['outputs']: +% if 'background' in output and (output['match'] == '*' or 'device' in output): +% if output['match'] == '*': +image=${output['background'][0]} +% else: +image=${output['device']}:${output['background'][0]} +% endif +% endif +% endfor