Compare commits

...

2 Commits

Author SHA1 Message Date
a127be5d2e
flake.lock: Update
Flake lock file updates:

• Updated input 'home-manager':
    'github:nix-community/home-manager/9d3d080aec2a35e05a15cedd281c2384767c2cfe?narHash=sha256-Gs076ot1YuAAsYVcyidLKUMIc4ooOaRGO0PqTY7sBzA%3D' (2025-02-17)
  → 'github:nix-community/home-manager/0948aeedc296f964140d9429223c7e4a0702a1ff?narHash=sha256-jbqlw4sPArFtNtA1s3kLg7/A4fzP4GLk9bGbtUJg0JQ%3D' (2025-03-22)
• Updated input 'home-manager-unstable':
    'github:nix-community/home-manager/c630dfa8abcc65984cc1e47fb25d4552c81dd37e?narHash=sha256-gBlb8R9gnjUAT5XabJeel3C2iEUiBHx3%2B91651y3Sqo%3D' (2025-03-11)
  → 'github:nix-community/home-manager/9172a6f956f7e0f7810861b9b1146f1c43d9abcb?narHash=sha256-bJIFFa6/4vBGoNmCwjO5TCIbiveV2BRxVLqHcxk5jXw%3D' (2025-03-23)
• Updated input 'jovian-nixos':
    'github:Jovian-Experiments/Jovian-NixOS/8c44f7f637f85a60cec8affb5ce1a75549c010f4?narHash=sha256-GsiWbJqN87Y%2B8BQl55O/Tlr5syhLzt8kUAPJ7kWMgSA%3D' (2025-03-11)
  → 'github:Jovian-Experiments/Jovian-NixOS/a95606cae5c9e1f5b84debe7865ef171d4deb287?narHash=sha256-gpjtkoeq5Ye9J8GoR%2BrWg3NL4bbEtcLvvF4nN6MtxdU%3D' (2025-03-20)
• Updated input 'microvm':
    'github:astro/microvm.nix/5e1b3dba5b52405dab79412392b9c799d49bd8c0?narHash=sha256-VMeqnLv2O6Lg3/pka1tUzzbOjSmEb6RQOp9OuJRcx0A%3D' (2025-03-06)
  → 'github:astro/microvm.nix/7f15bac13b41d2e3d33b008195692bdcdc20ec8d?narHash=sha256-Btl6pf5Uv/9HaMqcjrG9rgSkCnBEUpWcfgEYe/frIws%3D' (2025-03-22)
• Updated input 'nixos-hardware':
    'github:NixOS/nixos-hardware/b48cc4dab0f9711af296fc367b6108cf7b8ccb16?narHash=sha256-RUAdT8dZ6k/486vnu3tiNRrNW6%2BQ8uSD2Mq7gTX4jlo%3D' (2025-03-07)
  → 'github:NixOS/nixos-hardware/380ed15bcd6440606c6856db44a99140d422b46f?narHash=sha256-yJ3OOAmsGAxSl0bTmKUp3%2BcEYtSS%2BV6hUPK2rYhIPr8%3D' (2025-03-22)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/ebe2788eafd539477f83775ef93c3c7e244421d3?narHash=sha256-yfDy6chHcM7pXpMF4wycuuV%2BILSTG486Z/vLx/Bdi6Y%3D' (2025-03-10)
  → 'github:NixOS/nixpkgs/7105ae3957700a9646cc4b766f5815b23ed0c682?narHash=sha256-8XfURTDxOm6%2B33swQJu/hx6xw1Tznl8vJJN5HwVqckg%3D' (2025-03-20)
• Updated input 'nixpkgs-unstable':
    'github:nixos/nixpkgs/e3e32b642a31e6714ec1b712de8c91a3352ce7e1?narHash=sha256-7rTAMNTY1xoBwz0h7ZMtEcd8LELk9R5TzBPoHuhNSCk%3D' (2025-03-09)
  → 'github:nixos/nixpkgs/a84ebe20c6bc2ecbcfb000a50776219f48d134cc?narHash=sha256-mNqIplmEohk5jRkqYqG19GA8MbQ/D4gQSK0Mu4LvfRQ%3D' (2025-03-19)
2025-03-23 11:19:15 +01:00
af13b31ce3
add autoaspm and rotate screen button 2025-03-23 11:19:13 +01:00
3 changed files with 147 additions and 23 deletions

42
flake.lock generated
View File

@ -165,11 +165,11 @@
]
},
"locked": {
"lastModified": 1741701235,
"narHash": "sha256-gBlb8R9gnjUAT5XabJeel3C2iEUiBHx3+91651y3Sqo=",
"lastModified": 1742701794,
"narHash": "sha256-bJIFFa6/4vBGoNmCwjO5TCIbiveV2BRxVLqHcxk5jXw=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "c630dfa8abcc65984cc1e47fb25d4552c81dd37e",
"rev": "9172a6f956f7e0f7810861b9b1146f1c43d9abcb",
"type": "github"
},
"original": {
@ -185,11 +185,11 @@
]
},
"locked": {
"lastModified": 1739757849,
"narHash": "sha256-Gs076ot1YuAAsYVcyidLKUMIc4ooOaRGO0PqTY7sBzA=",
"lastModified": 1742655702,
"narHash": "sha256-jbqlw4sPArFtNtA1s3kLg7/A4fzP4GLk9bGbtUJg0JQ=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "9d3d080aec2a35e05a15cedd281c2384767c2cfe",
"rev": "0948aeedc296f964140d9429223c7e4a0702a1ff",
"type": "github"
},
"original": {
@ -222,11 +222,11 @@
]
},
"locked": {
"lastModified": 1741673443,
"narHash": "sha256-GsiWbJqN87Y+8BQl55O/Tlr5syhLzt8kUAPJ7kWMgSA=",
"lastModified": 1742465245,
"narHash": "sha256-gpjtkoeq5Ye9J8GoR+rWg3NL4bbEtcLvvF4nN6MtxdU=",
"owner": "Jovian-Experiments",
"repo": "Jovian-NixOS",
"rev": "8c44f7f637f85a60cec8affb5ce1a75549c010f4",
"rev": "a95606cae5c9e1f5b84debe7865ef171d4deb287",
"type": "github"
},
"original": {
@ -270,11 +270,11 @@
"spectrum": "spectrum"
},
"locked": {
"lastModified": 1741275356,
"narHash": "sha256-VMeqnLv2O6Lg3/pka1tUzzbOjSmEb6RQOp9OuJRcx0A=",
"lastModified": 1742612353,
"narHash": "sha256-Btl6pf5Uv/9HaMqcjrG9rgSkCnBEUpWcfgEYe/frIws=",
"owner": "astro",
"repo": "microvm.nix",
"rev": "5e1b3dba5b52405dab79412392b9c799d49bd8c0",
"rev": "7f15bac13b41d2e3d33b008195692bdcdc20ec8d",
"type": "github"
},
"original": {
@ -307,11 +307,11 @@
},
"nixos-hardware": {
"locked": {
"lastModified": 1741325094,
"narHash": "sha256-RUAdT8dZ6k/486vnu3tiNRrNW6+Q8uSD2Mq7gTX4jlo=",
"lastModified": 1742631601,
"narHash": "sha256-yJ3OOAmsGAxSl0bTmKUp3+cEYtSS+V6hUPK2rYhIPr8=",
"owner": "NixOS",
"repo": "nixos-hardware",
"rev": "b48cc4dab0f9711af296fc367b6108cf7b8ccb16",
"rev": "380ed15bcd6440606c6856db44a99140d422b46f",
"type": "github"
},
"original": {
@ -323,11 +323,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1741600792,
"narHash": "sha256-yfDy6chHcM7pXpMF4wycuuV+ILSTG486Z/vLx/Bdi6Y=",
"lastModified": 1742512142,
"narHash": "sha256-8XfURTDxOm6+33swQJu/hx6xw1Tznl8vJJN5HwVqckg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ebe2788eafd539477f83775ef93c3c7e244421d3",
"rev": "7105ae3957700a9646cc4b766f5815b23ed0c682",
"type": "github"
},
"original": {
@ -339,11 +339,11 @@
},
"nixpkgs-unstable": {
"locked": {
"lastModified": 1741513245,
"narHash": "sha256-7rTAMNTY1xoBwz0h7ZMtEcd8LELk9R5TzBPoHuhNSCk=",
"lastModified": 1742422364,
"narHash": "sha256-mNqIplmEohk5jRkqYqG19GA8MbQ/D4gQSK0Mu4LvfRQ=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "e3e32b642a31e6714ec1b712de8c91a3352ce7e1",
"rev": "a84ebe20c6bc2ecbcfb000a50776219f48d134cc",
"type": "github"
},
"original": {

114
modules/hardware/autoaspm.py Executable file
View File

@ -0,0 +1,114 @@
#!/usr/bin/env python3
# Original bash script by Luis R. Rodriguez
# Re-written in Python by z8
# Re-re-written to patch supported devices automatically by notthebee
import re
import subprocess
import os
import platform
from enum import Enum
class ASPM(Enum):
DISABLED = 0b00
L0s = 0b01
L1 = 0b10
L0sL1 = 0b11
def run_prerequisites():
if platform.system() != "Linux":
raise OSError("This script only runs on Linux-based systems")
if not os.environ.get("SUDO_UID") and os.geteuid() != 0:
raise PermissionError("This script needs root privileges to run")
lspci_detected = subprocess.run(["which", "lspci"], stdout = subprocess.DEVNULL, stderr = subprocess.DEVNULL)
if lspci_detected.returncode > 0:
raise Exception("lspci not detected. Please install pciutils")
lspci_detected = subprocess.run(["which", "setpci"], stdout = subprocess.DEVNULL, stderr = subprocess.DEVNULL)
if lspci_detected.returncode > 0:
raise Exception("setpci not detected. Please install pciutils")
def get_device_name(addr):
p = subprocess.Popen([
"lspci",
"-s",
addr,
], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return p.communicate()[0].splitlines()[0].decode()
def read_all_bytes(device):
all_bytes = bytearray()
device_name = get_device_name(device)
p = subprocess.Popen([
"lspci",
"-s",
device,
"-xxx"
], stdout= subprocess.PIPE, stderr=subprocess.PIPE)
ret = p.communicate()
ret = ret[0].decode()
for line in ret.splitlines():
if not device_name in line and ": " in line:
all_bytes.extend(bytearray.fromhex(line.split(": ")[1]))
if len(all_bytes) < 256:
exit()
return all_bytes
def find_byte_to_patch(bytes, pos):
pos = bytes[pos]
if bytes[pos] != 0x10:
pos += 0x1
return find_byte_to_patch(bytes, pos)
else:
pos += 0x10
return pos
def patch_byte(device, position, value):
subprocess.Popen([
"setpci",
"-s",
device,
f"{hex(position)}.B={hex(value)}"
]).communicate()
def patch_device(addr, aspm_value):
endpoint_bytes = read_all_bytes(addr)
byte_position_to_patch = find_byte_to_patch(endpoint_bytes, 0x34)
if int(endpoint_bytes[byte_position_to_patch]) & 0b11 != aspm_value.value:
patched_byte = int(endpoint_bytes[byte_position_to_patch])
patched_byte = patched_byte >> 2
patched_byte = patched_byte << 2
patched_byte = patched_byte | aspm_value.value
patch_byte(addr, byte_position_to_patch, patched_byte)
print(f"{addr}: Enabled ASPM {aspm_value.name}")
else:
print(f"{addr}: Already has ASPM {aspm_value.name} enabled")
def list_supported_devices():
pcie_addr_regex = r"([0-9a-f]{2}:[0-9a-f]{2}.[0-9a-f])"
lspci = subprocess.run("lspci -vv", shell=True, capture_output=True).stdout
lspci_arr = re.split(pcie_addr_regex, str(lspci))[1:]
lspci_arr = [ x+y for x,y in zip(lspci_arr[0::2], lspci_arr[1::2]) ]
aspm_devices = {}
for dev in lspci_arr:
device_addr = re.findall(pcie_addr_regex, dev)[0]
if "ASPM" not in dev or "ASPM not supported" in dev:
continue
aspm_support = re.findall(r"ASPM (L[L0-1s ]*),", dev)
if aspm_support:
aspm_devices.update({device_addr: ASPM[aspm_support[0].replace(" ", "")]})
return aspm_devices
def main():
run_prerequisites()
for device, aspm_mode in list_supported_devices().items():
patch_device(device, aspm_mode)
if __name__ == "__main__":
main()

View File

@ -54,7 +54,7 @@
margin: 0 5px;
}
#custom-vkeyboard, #custom-appkill {
#custom-vkeyboard, #custom-appkill, #custom-rotate {
padding: 0px 50px;
margin: 0px 0px;
font-size: 20px;
@ -135,13 +135,17 @@
color: red;
background-color: black;
}
#custom-rotate {
color: white;
background-color: black;
}
'';
settings = [{
layer = "bottom";
position = "top";
height = 22;
tray = { spacing = 10; };
modules-center = [ "clock" "custom/appkill" ];
modules-center = [ "custom/rotate" "clock" "custom/appkill" ];
modules-left = [ "sway/mode" "sway/workspaces" "sway/window" ];
#modules-left = [ "wlr/workspaces" ];
modules-right = [ "idle_inhibitor" "pulseaudio" "network" "cpu" "memory" "backlight" "temperature" "battery" "tray" ];
@ -269,6 +273,12 @@
on-click = "${pkgs.sway}/bin/swaymsg kill";
tooltip = false;
};
"custom/rotate" = {
format = " ";
icon-size = 20;
on-click = "${pkgs.sway}/bin/swaymsg output eDP-1 transform 180 clockwise";
tooltip = false;
};
}];
};
};