update: actual budget server

This commit is contained in:
danny 2025-09-14 15:54:42 +08:00
parent ebc7481553
commit 85feeb7b3f
15 changed files with 709 additions and 496 deletions

View file

@ -1,66 +1,70 @@
{ pkgs, ... }:
pkgs.writers.writePython3Bin "memeSelector" { libraries = with pkgs.python3Packages; [ requests ]; }
''
import requests
import xml.etree.ElementTree as ET
import urllib.parse
import sys
import os
import tempfile
import subprocess
{
pkgs,
url,
...
}:
pkgs.writers.writePython3Bin "memeSelector" {libraries = with pkgs.python3Packages; [requests];}
''
import requests
import xml.etree.ElementTree as ET
import urllib.parse
import sys
import os
import tempfile
import subprocess
BASE_URL = "https://nextcloud.net.dn/public.php/dav/files/pygHoPB5LxDZbeY/"
headers = {"Depth": "1"}
resp = requests.request(
"PROPFIND",
BASE_URL,
headers=headers,
verify="${"" + ../../system/extra/ca.crt}"
)
BASE_URL = "${url}"
headers = {"Depth": "1"}
resp = requests.request(
"PROPFIND",
BASE_URL,
headers=headers,
verify="${"" + ../../system/extra/ca.crt}"
)
if resp.status_code not in (200, 207):
print(f"Error: Http {resp.status_code}")
sys.exit(1)
if resp.status_code not in (200, 207):
print(f"Error: Http {resp.status_code}")
sys.exit(1)
root = ET.fromstring(resp.text)
ns = {"d": "DAV:"}
root = ET.fromstring(resp.text)
ns = {"d": "DAV:"}
files = []
for href in root.findall(".//d:href", ns):
path = href.text
if not path:
continue
filename = urllib.parse.unquote(path.split("/")[-1])
files = []
for href in root.findall(".//d:href", ns):
path = href.text
if not path:
continue
filename = urllib.parse.unquote(path.split("/")[-1])
if filename and not filename.endswith("/"):
files.append(filename)
if filename and not filename.endswith("/"):
files.append(filename)
if not files:
print("No files found")
sys.exit(0)
if not files:
print("No files found")
sys.exit(0)
rofi = subprocess.run(
["rofi", "-dmenu", "-p", "Meme"],
input="\n".join(files).encode(),
stdout=subprocess.PIPE
)
rofi = subprocess.run(
["rofi", "-i", "-dmenu", "-p", "Meme"],
input="\n".join(files).encode(),
stdout=subprocess.PIPE
)
selected = rofi.stdout.decode().strip()
if not selected:
sys.exit(0)
selected = rofi.stdout.decode().strip()
if not selected:
sys.exit(0)
url = BASE_URL + urllib.parse.quote(selected)
tmpfile = os.path.join(tempfile.gettempdir(), selected)
url = BASE_URL + urllib.parse.quote(selected)
tmpfile = os.path.join(tempfile.gettempdir(), selected)
subprocess.run(["wget", "-q", "-O", tmpfile, url], check=True)
subprocess.run(["wget", "-q", "-O", tmpfile, url], check=True)
with open(tmpfile, "rb") as f:
subprocess.run("wl-copy", stdin=f)
with open(tmpfile, "rb") as f:
subprocess.run("wl-copy", stdin=f)
subprocess.run([
"notify-send",
"-i", tmpfile,
"Meme Copied: ",
f"{selected}"
])
''
subprocess.run([
"notify-send",
"-i", tmpfile,
"Meme Copied: ",
f"{selected}"
])
''

View file

@ -1,6 +1,7 @@
{
pkgs,
lib,
osConfig,
...
}: let
inherit (lib.generators) mkLuaInline;
@ -232,25 +233,37 @@ in {
}
{
key = "<C-j>";
mode = ["n" "t"];
mode = [
"n"
"t"
];
action = "<C-\\><C-n><C-w>j";
nowait = true;
}
{
key = "<C-k>";
mode = ["n" "t"];
mode = [
"n"
"t"
];
action = "<C-\\><C-n><C-w>k";
nowait = true;
}
{
key = "<C-l>";
mode = ["n" "t"];
mode = [
"n"
"t"
];
action = "<C-\\><C-n><C-w>l";
nowait = true;
}
{
key = "<C-h>";
mode = ["n" "t"];
mode = [
"n"
"t"
];
action = "<C-\\><C-n><C-w>h";
nowait = true;
}
@ -414,14 +427,28 @@ in {
};
nix = {
enable = true;
format.type = "nixfmt";
lsp = {
enable = true;
server = "nixd";
options = {
nixos.expr =
# nix
''(builtins.getFlake (builtins.toString ./.)).nixosConfigurations.${osConfig.networking.hostName}.options'';
home_manager.expr =
# nix
''(builtins.getFlake (builtins.toString ./.)).nixosConfigurations.${osConfig.networking.hostName}.options.home-manager.users.type.getSubOptions []'';
};
};
};
sql.enable = true;
clang.enable = true;
ts.enable = true;
ts = {
enable = true;
format.type = "prettierd";
extensions = {
ts-error-translator.enable = true;
};
};
python.enable = true;
markdown.enable = true;
html.enable = true;
@ -627,7 +654,15 @@ in {
autopairs.nvim-autopairs.enable = true;
autocomplete = {
blink-cmp.enable = true;
blink-cmp = {
enable = true;
setupOpts = {
completion = {
menu.border = "rounded";
documentation.window.border = "rounded";
};
};
};
};
snippets.luasnip = {
@ -705,6 +740,10 @@ in {
multicursors.enable = true;
undotree.enable = true;
yazi-nvim = {
enable = true;
};
images = {
img-clip.enable = true;
};
@ -753,7 +792,9 @@ in {
event = "msg_show";
kind = "bufwrite";
};
opts = {skip = true;};
opts = {
skip = true;
};
}
{
filter = {

View file

@ -15,13 +15,14 @@ let
inherit (lib) optionalString;
gamemodeToggle = mkToggleScript {
service = "gamemoded";
service = "gamemodedr";
start = "on";
stop = "off";
icon = "";
notify-icon = "preferences-desktop-gaming";
extra = {
text = "$(pgrep -c gamemode)";
tooltip = "Running: $(pgrep -c gamemode)";
tooltip = "Running: $(systemctl --user is-active gamemodedr)";
};
};
@ -87,6 +88,14 @@ in
"d /tmp/wall_cache 700 ${username} -"
];
# === gamemoded -r === #
systemd.user.services.gamemodedr = lib.mkIf osConfig.programs.gamemode.enable {
Service = {
Type = "simple";
ExecStart = "${pkgs.gamemode}/bin/gamemoded -r";
};
};
# === waybar === #
systemd.user.services.waybar = lib.mkIf config.programs.waybar.enable {
Unit = {