feat: Wallpaper changer and socs

This commit is contained in:
2024-08-26 22:10:44 +03:00
parent 99ce0248f3
commit 16828e7daa
9 changed files with 163 additions and 12 deletions
+1
View File
@@ -5,6 +5,7 @@
./htop.nix
./alacritty.nix
./qt.nix
./sops.nix
./wms/hyprland.nix
./wms/waybar.nix
+8
View File
@@ -0,0 +1,8 @@
{ config, ... }: {
sops = {
defaultSopsFile = ../secrets.yaml;
age.keyFile = "/home/sweetbread/.config/sops/age/keys.txt";
secrets."tokens/apis/wallhaven" = {};
};
}
+59 -10
View File
@@ -1,5 +1,52 @@
{
wayland.windowManager.hyprland = {
{ pkgs, lib, config, ... }: {
wayland.windowManager.hyprland =
let
wallpaper_changer = pkgs.writers.writePython3Bin "wallpaper_changer" {
flakeIgnore = [ "E501" "E111" "E701" "E241" "E731" ];
} /*py*/ ''
import requests as requests
from random import choice
from os import system, mkdir, listdir
from os.path import exists
notify = lambda s: system(f"notify-desktop Wallpaper '{s}'")
folder = "/home/sweetbread/Wallpapers"
url = "https://wallhaven.cc/api/v1/collections/sweetbread/1764377"
with open("${config.sops.secrets."tokens/apis/wallhaven".path}") as f:
token = f.read()
notify("Updating wallpaper!")
try:
json = requests.get(url, params={'apikey': token}).json()
wallpaper = choice(json['data'])
link = wallpaper['path']
format = wallpaper['file_type']
id = wallpaper['id']
if format == "image/jpeg": ext = "jpg"
else: ext = "png"
filename = f"{id}.{ext}"
if not exists(f"{folder}/{filename}"):
if not exists(folder):
mkdir(f"{folder}")
notify("Downloading...")
with open(f"{folder}/{filename}", 'wb') as f:
r = requests.get(link)
f.write(r.content)
except requests.exceptions.ConnectionError:
notify("Offline mode")
filename = choice(listdir(folder))
finally:
system(f"swww img {folder}/{filename} --transition-type center")
'';
in {
enable = true;
xwayland.enable = true;
@@ -117,13 +164,13 @@
];
exec-once = [
"systemctl --user start plasma-polkit-agent"
"swww init"
"swww img ~/Downloads/nixos-chan.png"
"waybar"
"wl-paste --type text --watch cliphist store"
"wl-paste --type image --watch cliphist store"
];
"systemctl --user start plasma-polkit-agent"
"swww init"
"python3 ${lib.getExe wallpaper_changer}"
"waybar"
"wl-paste --type text --watch cliphist store"
"wl-paste --type image --watch cliphist store"
];
bind = [
"$mainMod, V, exec, cliphist list | wofi --dmenu | cliphist decode | wl-copy"
@@ -208,7 +255,9 @@
# Waybar
"$mainMod, B, exec, pkill -SIGUSR1 waybar"
"$mainMod, W, exec, pkill -SIGUSR2 waybar"
#"$mainMod, W, exec, pkill -SIGUSR2 waybar"
"$mainMod, W, exec, python3 ${lib.getExe wallpaper_changer}"
# Disable all effects
"$mainMod Shift, G, exec, ~/.config/hypr/gamemode.sh "
+23
View File
@@ -0,0 +1,23 @@
tokens:
apis:
wallhaven: ENC[AES256_GCM,data:mawmbX0FQkhQHruABPc34mm+QtyEv6SulAXOGL6tMoQ=,iv:P+LtVoGzhc9kv4XUXOIJCosg52JXBAyWTQ+os9clibg=,tag:TQ0dLVKDkAo20p4w9HKn2g==,type:str]
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
age:
- recipient: age1j3uuyax673fvl5x4dveupq3dylngnrq0e5uy7fmclsexkfd25vysk646wk
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBnbDl6ZWZpc2U2SnNYQVpJ
cmtBRzVOZTdOaXd6MFFnTGFLbzBhNldlN25RCisyNnAwY21udlZCWEc4U2hPa2di
WXN5cEduMXUwNXpmU0hBQzdkamtSd28KLS0tIHUzd3RTbUM4VnFYZkRYbXJCUDZl
UkZPZUlLQVNUZ1ZGV3BZM3hib3JHMXcKqyQUcRMhoVHK78lAYl2vSJUCxBL6atLb
VXT5DV67KKnUKyKUAQ+gjEP9EpvR16PBCZ+EcSFfx/azHONCtV3mZg==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2024-08-26T18:55:20Z"
mac: ENC[AES256_GCM,data:x9TX4OfDmw8qySadz/l5BUTyQLsOnROKASMn34Ps5Sb0LzYKrlQoHPQhiJ6YVNfYE+7WtNMqoQvUEjg9FQfEVcH5PFeXZjAaeLKDvEhgXjklhrSfbWCn7a+1yIbwutKb63cIuMh9ZcDUCmtAZlt+FssI/TjB0k5QqV4a358hjQE=,iv:GJWGCINdJr3HLX33YFEqTE+TlmfCpZBCLBUUHGSvvG8=,tag:6sKlM2/3r3os1h0U5ToqiA==,type:str]
pgp: []
unencrypted_suffix: _unencrypted
version: 3.9.0