Compare commits

..

No commits in common. "d2b803818d78b1ba64914a08c5f0dbbef91b35f8" and "7c52d0c6f42a9c56107b07c8e836821193cde0c9" have entirely different histories.

8 changed files with 53 additions and 153 deletions

View file

@ -29,7 +29,3 @@ background_path = "~/.local/share/backgrounds/adventurer/t.jpg"
match = "Pioneer Electronic Corporation AV Receiver Unknown"
mode = "3840x2160@60Hz"
scale = 2
[niri]
# 1/3 proportion is better for the ultrawide
default_column_width = 0.33333

View file

@ -1,12 +1,11 @@
wireless = ["wlp170s0"]
auto_ethernet = true
#ethernet = ["enp2s0"]
temperature_path = "/sys/class/hwmon/hwmon4/temp1_input"
has_battery = true
[[outputs]]
match = "eDP-1"
background_path = "~/.local/share/backgrounds/liberation.jpg"
scale = 1
background_path = "~/.local/share/backgrounds/sway-dark-1920x1080.png"
scale = 1.25
[[inputs]]
match = "2362:628:PIXA3854:00_093A:0274_Touchpad"

View file

@ -90,7 +90,7 @@ class OutputConfig:
scale: float | None = None
background_path: str | None = None
background_mode: BackgroundMode = BackgroundMode.Fill
port: str | None = None
device: str | None = None
@property
def sway_lines(self) -> str:
@ -108,12 +108,12 @@ class OutputConfig:
@property
def swaylock_image_line(self) -> str | None:
if (self.match != "*" and self.port is None) or self.background_path is None:
if (self.match != "*" and self.device is None) or self.background_path is None:
return None
if self.match == "*":
return f"image={self.background_path}"
return f"image={self.port}:{self.background_path}"
return f"image={self.device}:{self.background_path}"
@property
def niri_lines(self) -> str:
@ -132,9 +132,8 @@ class OutputConfig:
if self.background_path is None:
return {}
# TODO: match by serial number instead of by port
key = self.port
if self.match == "*":
key = self.match
if key == "*":
key = "any"
return {
@ -145,11 +144,6 @@ class OutputConfig:
}
@define
class NiriConfig:
default_column_width: float = 0.5
@define
class HostConfig:
name: str
@ -157,9 +151,7 @@ class HostConfig:
base16_scheme: str = "seti"
wireless: list[str] = field(factory=list)
ethernet: list[str] = field(factory=list)
auto_ethernet: bool = True
disks: list[str] = field(factory=lambda: ["/"])
has_battery: bool = False
system_font: str = "Fira Sans"
system_mono_font: str = "Fira Mono"
temperature_path: str | None = None
@ -170,7 +162,6 @@ class HostConfig:
use_jump_host: bool = False
inputs: list[InputConfig] = field(factory=list)
outputs: list[OutputConfig] = field(factory=list)
niri: NiriConfig = field(factory=NiriConfig)
@property
def swaylock_images(self) -> str:
@ -222,11 +213,10 @@ def main():
)
args = parser.parse_args()
dotfiles_dir: Path = args.dotfiles
raw_dir = dotfiles_dir / "raw"
templates_dir = dotfiles_dir / "templates"
include_dir = dotfiles_dir / "include"
host_filename = dotfiles_dir / "hosts" / "{}.toml".format(args.hostname)
raw_dir = args.dotfiles / "raw"
templates_dir = args.dotfiles / "templates"
include_dir = args.dotfiles / "include"
host_filename = args.dotfiles / "hosts" / "{}.toml".format(args.hostname)
host_toml = {
"name": args.hostname,
@ -238,7 +228,7 @@ def main():
host_config = cattrs.structure(host_toml, HostConfig)
for output in host_config.outputs:
# Attempt to resolve port names for swaylock template
# 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
@ -252,9 +242,9 @@ def main():
["swaymsg", "-t", "get_outputs", "-p"],
).decode("utf-8")
for line in get_outputs.splitlines():
# Line format: Output <port> '<match identifier>'
# Line format: Output <device> '<match identifier>'
if line.startswith("Output") and output.match in line:
output.port = line.split()[1]
output.device = line.split()[1]
break
elif "NIRI_SOCKET" in os.environ:
@ -262,9 +252,9 @@ def main():
["niri", "msg", "outputs"],
).decode("utf-8")
for line in get_outputs.splitlines():
# Line format: Output "<match identifier>" (<port>)
# Line format: Output "<match identifier>" (<device>)
if line.startswith("Output") and output.match in line:
output.port = (
output.device = (
line.split()[-1].removeprefix("(").removesuffix(")")
)
break
@ -272,7 +262,9 @@ def main():
print(
"Could not find SWAYSOCK or NIRI_SOCKET, cannot retrieve output names."
)
print("Please re-run in sway or niri to finish configuring swaylock.")
print(
"Please re-run in sway or niri to finish configuring swaylock."
)
except subprocess.CalledProcessError:
print("Could not contact sway or niri to retrieve output names.")
@ -285,8 +277,6 @@ def main():
],
)
changed_paths = set()
for raw_path in raw_dir.glob("**/*"):
if not raw_path.is_file():
continue
@ -297,7 +287,6 @@ def main():
print(rel_path)
output_path.parent.mkdir(parents=True, exist_ok=True)
shutil.copy(raw_path, output_path)
changed_paths.update(map(str, rel_path.parents))
for template_path in templates_dir.glob("**/*"):
if not template_path.is_file():
@ -323,11 +312,6 @@ def main():
# Copy permissions from original file
output_path.chmod(template_path.stat().st_mode & 0o777)
changed_paths.update(map(str, rel_path.parents))
# Post-install hooks
if ".config/waybar" in changed_paths:
subprocess.call(["killall", "-USR2", "waybar"])
if __name__ == "__main__":

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

View file

@ -1 +0,0 @@
chase-baker-NPiv36bUc4I-unsplash.jpg

View file

@ -56,9 +56,6 @@ input {
// Focus windows and outputs automatically when moving the mouse into them.
// Setting max-scroll-amount="0%" makes it work only on windows already fully on screen.
// focus-follows-mouse max-scroll-amount="0%"
// https://github.com/YaLTeR/niri/wiki/Configuration:-Input#disable-power-key-handling
disable-power-key-handling
}
% for output in host.outputs:
@ -100,7 +97,7 @@ layout {
// preset-window-heights { }
// You can change the default width of the new windows.
default-column-width { proportion ${host.niri.default_column_width}; }
default-column-width { proportion 0.33333; }
// If you leave the brackets empty, the windows themselves will decide their initial width.
// default-column-width {}
@ -193,11 +190,6 @@ environment {
DISPLAY ":12"
}
cursor {
xcursor-theme "breeze_cursors"
xcursor-size 24
}
// Uncomment this line to ask the clients to omit their client-side decorations if possible.
// If the client will specifically ask for CSD, the request will be honored.
// Additionally, clients will be informed that they are tiled, removing some client-side rounded corners.
@ -314,14 +306,14 @@ binds {
Mod+K { focus-window-up; }
Mod+L { focus-column-right; }
Mod+Shift+Left { move-column-left; }
Mod+Shift+Down { move-window-down; }
Mod+Shift+Up { move-window-up; }
Mod+Shift+Right { move-column-right; }
Mod+Shift+H { move-column-left; }
Mod+Shift+J { move-window-down; }
Mod+Shift+K { move-window-up; }
Mod+Shift+L { move-column-right; }
Mod+Ctrl+Left { move-column-left; }
Mod+Ctrl+Down { move-window-down; }
Mod+Ctrl+Up { move-window-up; }
Mod+Ctrl+Right { move-column-right; }
Mod+Ctrl+H { move-column-left; }
Mod+Ctrl+J { move-window-down; }
Mod+Ctrl+K { move-window-up; }
Mod+Ctrl+L { move-column-right; }
// Alternative commands that move across workspaces when reaching
// the first or last window in a column.
@ -335,23 +327,31 @@ binds {
Mod+Ctrl+Home { move-column-to-first; }
Mod+Ctrl+End { move-column-to-last; }
Mod+Ctrl+Left { focus-monitor-left; }
Mod+Ctrl+Down { focus-monitor-down; }
Mod+Ctrl+Up { focus-monitor-up; }
Mod+Ctrl+Right { focus-monitor-right; }
Mod+Ctrl+H { focus-monitor-left; }
Mod+Ctrl+J { focus-monitor-down; }
Mod+Ctrl+K { focus-monitor-up; }
Mod+Ctrl+L { focus-monitor-right; }
Mod+Shift+Left { focus-monitor-left; }
Mod+Shift+Down { focus-monitor-down; }
Mod+Shift+Up { focus-monitor-up; }
Mod+Shift+Right { focus-monitor-right; }
Mod+Shift+H { focus-monitor-left; }
Mod+Shift+J { focus-monitor-down; }
Mod+Shift+K { focus-monitor-up; }
Mod+Shift+L { focus-monitor-right; }
Mod+Shift+Ctrl+Left { move-workspace-to-monitor-left; }
Mod+Shift+Ctrl+Down { move-workspace-to-monitor-down; }
Mod+Shift+Ctrl+Up { move-workspace-to-monitor-up; }
Mod+Shift+Ctrl+Right { move-workspace-to-monitor-right; }
Mod+Shift+Ctrl+H { move-workspace-to-monitor-left; }
Mod+Shift+Ctrl+J { move-workspace-to-monitor-down; }
Mod+Shift+Ctrl+K { move-workspace-to-monitor-up; }
Mod+Shift+Ctrl+L { move-workspace-to-monitor-right; }
Mod+Shift+Ctrl+Left { move-column-to-monitor-left; }
Mod+Shift+Ctrl+Down { move-column-to-monitor-down; }
Mod+Shift+Ctrl+Up { move-column-to-monitor-up; }
Mod+Shift+Ctrl+Right { move-column-to-monitor-right; }
Mod+Shift+Ctrl+H { move-column-to-monitor-left; }
Mod+Shift+Ctrl+J { move-column-to-monitor-down; }
Mod+Shift+Ctrl+K { move-column-to-monitor-up; }
Mod+Shift+Ctrl+L { move-column-to-monitor-right; }
// Alternatively, there are commands to move just a single window:
// Mod+Shift+Ctrl+Left { move-window-to-monitor-left; }
// ...
// And you can also move a whole workspace to another monitor:
// Mod+Shift+Ctrl+Left { move-workspace-to-monitor-left; }
// ...
Mod+Page_Down { focus-workspace-down; }
Mod+Page_Up { focus-workspace-up; }

View file

@ -16,12 +16,7 @@
"network#${iface}",
% endfor
% if not host.ethernet and host.auto_ethernet:
"network#auto_ethernet",
% endif
"wireplumber",
"battery",
"group/disks",
"cpu",
"memory",
@ -54,39 +49,12 @@
},
% endfor
% if not host.ethernet and host.auto_ethernet:
"network#auto_ethernet": {
"interface": "en*",
"format": "\uf6ff \uf058",
"format-disconnected": "\uf6ff \uf057",
"tooltip-format": "${iface} {ipaddr}",
"tooltip-format-disconnected": "${iface} down"
},
% endif
"wireplumber": {
"format": "{icon} {volume}%",
"format-muted": "\uf6a9 {volume}%",
"format-icons": ["\uf026", "\uf027", "\uf028"]
},
% if host.has_battery:
"battery": {
"design-capacity": true,
"format": "{icon} {capacity}% {time}",
"format-time": "{H}:{m}",
"format-icons": [
"\uf244",
"\uf243",
"\uf242",
"\uf241",
"\uf240",
],
"format-charging": "\ue55b {capacity}% {time}",
"format-full": "\ue55c {capacity}%",
},
% endif
"group/disks": {
// TODO: make drawer that expands orthogonally, outside of the bar
"orientation": "inherit",

View file

@ -1,46 +0,0 @@
#!/usr/bin/env python
import argparse
from io import StringIO
import subprocess
import urllib.parse
def main():
parser = argparse.ArgumentParser(
description="""
Fetch the wifi password and generate a QR code.
This program assumes that the network PSK is stored
in the password-store, and will look for it
at the path `wifi/<essid>`.
""",
)
parser.add_argument(
"-H",
"--hidden",
action="store_true",
help="Indicate that this network's SSID is hidden.",
)
parser.add_argument("essid", help="ESSID for this network")
args = parser.parse_args()
psk = subprocess.check_output(["pass", f"wifi/{args.essid}"], text=True).strip()
hidden_data = "H:true;" if args.hidden else ""
qr_data = f"WIFI:T:WPA;S:{quote(args.essid)};{hidden_data}P:{quote(psk)};;"
proc = subprocess.Popen(["qrencode", "-tANSI"], stdin=subprocess.PIPE, text=True)
proc.communicate(qr_data)
PRINTABLE = [*range(0x20, 0x3B), *range(0x3C, 0x7F)]
def quote(s: str) -> str:
return urllib.parse.quote(s, safe=PRINTABLE)
if __name__ == "__main__":
main()