From f692df29073e94528461001fc3a3546933db3bd4 Mon Sep 17 00:00:00 2001 From: ranomier Date: Sat, 29 Mar 2025 19:09:21 +0100 Subject: [PATCH 1/3] added todo --- nswitch | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nswitch b/nswitch index c66dda1..09d3138 100755 --- a/nswitch +++ b/nswitch @@ -5,6 +5,8 @@ set -E -o pipefail shopt -s failglob export LC_ALL=C.UTF8 +# TODO: implement step by step update with diff in between (first build then switch) + INITIAL_PWD="$(pwd)" PROJECT="$HOME/Projects/NixOS" GIT_PATTERN="." # "*.nix" From c4f2d15e75c7fd190247e9f64457b267dbe18127 Mon Sep 17 00:00:00 2001 From: ranomier Date: Sat, 29 Mar 2025 19:10:07 +0100 Subject: [PATCH 2/3] little alias helper --- s | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 s diff --git a/s b/s new file mode 100755 index 0000000..b8c7d9a --- /dev/null +++ b/s @@ -0,0 +1,64 @@ +#!/usr/bin/env python + +import subprocess as sp +import argparse + +parser = argparse.ArgumentParser() +parser.add_argument("alias", nargs="?", + help="the replacement for the command") +parser.add_argument("arguments", nargs="*", default=[], + help="arguments that will be added to the argument") + +parser.add_argument("-l", "--list", dest="list", action="store_true", + help="list mappings") +ag = parser.parse_args() + +CFG = { + "offset": 10, + "mapping": { + "document": {"cmd": "sioyek", "pre_args": []}, + "pdf": {"alias": "document", "pre_args": []}, + + "image": {"cmd": "nomacs", "pre_args": []}, + + "audio": {"cmd": "amberol", "pre_args": []}, + "music": {"alias": "audio", "pre_args": []}, + + "video": {"cmd": "mpv", "pre_args": []} + } +} + +def run(command, pre_args): + cmd_list = [command] + cmd_list.extend(pre_args) + cmd_list.extend(ag.arguments) + return sp.run(cmd_list) + +def offset(element, offset=CFG["offset"]): + """ + calculates the amount of spaces until `offset` is reached for `element` length + """ + element_length = len(element.strip("")) + if element_length >= offset: + return "" + else: + return " " * (offset - element_length) + + + +if ag.list: + for key, value in CFG["mapping"].items(): + value_str = "" + for e_key, e_value in value.items(): + value_str += e_key + ": " + str(e_value) + ", " + print(key, end="") + print(offset(key), value_str.rstrip(", ")) +else: + for key, value in CFG["mapping"].items(): + if ag.alias in key: # matching + if "alias" in value.keys(): + cmd = CFG["mapping"][value["alias"]]["cmd"] + else: + cmd = value["cmd"] + + run(cmd, value["pre_args"]) From af4aff8ef2b0310ded320af641d0c0a5a470f540 Mon Sep 17 00:00:00 2001 From: ranomier Date: Fri, 20 Jun 2025 23:02:24 +0200 Subject: [PATCH 3/3] feat: try following xdg spec --- screenshot | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/screenshot b/screenshot index cb04e68..0573cb1 100755 --- a/screenshot +++ b/screenshot @@ -4,9 +4,16 @@ set -E -o pipefail shopt -s failglob export LC_ALL=C.UTF8 +PICTURES="$HOME" + +source /etc/xdg/user-dirs.defaults +source "$XDG_CONFIG_HOME/user-dirs.dirs" + +mkdir -p "$PICTURES" + grim -g "$(slurp -o -r -c '#ff0000ff')" - \ | satty \ --filename - \ --fullscreen \ --initial-tool "crop" \ - --output-filename "$HOME/Media/Pictures/Screenshots/satty-$(date '+%Y%m%d-%H:%M:%S').png" + --output-filename "$PICTURES/Screenshots/satty-$(date '+%Y%m%d-%H:%M:%S').png"