From b39b82463b57499abd325252201ccfd5ef3024e5 Mon Sep 17 00:00:00 2001 From: ranomier Date: Mon, 11 Nov 2024 02:31:05 +0100 Subject: [PATCH] initial commit --- audio_mixer | 11 +++++++++ battery | 5 ++++ brght | 23 +++++++++++++++++++ dlp-trnsrpt | 10 ++++++++ hyprperf | 5 ++++ mserve | 15 ++++++++++++ mytools | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ nstore-find | 5 ++++ nswitch | 14 ++++++++++++ rustdesk_profile | 25 ++++++++++++++++++++ screenshot | 5 ++++ scrnl | 22 ++++++++++++++++++ webcam | 15 ++++++++++++ 13 files changed, 214 insertions(+) create mode 100755 audio_mixer create mode 100755 battery create mode 100755 brght create mode 100755 dlp-trnsrpt create mode 100755 hyprperf create mode 100755 mserve create mode 100755 mytools create mode 100755 nstore-find create mode 100755 nswitch create mode 100755 rustdesk_profile create mode 100755 screenshot create mode 100755 scrnl create mode 100755 webcam diff --git a/audio_mixer b/audio_mixer new file mode 100755 index 0000000..32fddb6 --- /dev/null +++ b/audio_mixer @@ -0,0 +1,11 @@ +#/usr/bin/env bash +# docstring=simple mixer gui app, for the desktop +set -E -o pipefail + +mixxc \ + --anchor right \ + --margin 22 \ + --anchor bottom \ + --margin 22 \ + --icon \ + --master diff --git a/battery b/battery new file mode 100755 index 0000000..736b359 --- /dev/null +++ b/battery @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# docstring=just shows the current capacity +set -E -o pipefail + +cat /sys/class/power_supply/BAT0/capacity diff --git a/brght b/brght new file mode 100755 index 0000000..cc735e3 --- /dev/null +++ b/brght @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# docstring=simplifies the brightnessctl command +set -E -o pipefail + +# when invoked without parameter will print current brightness in percent +# it accepts a parameter from 0 to 100 for brightness. Please ommit the % symbol. + +if [[ "$1" == "--toggle" ]]; then + if [[ "$(brightnessctl get)" == "0" ]]; then + brightnessctl --restore || brightnessctl set '50%' # just in case --restore fails + else + brightnessctl --save && brightnessctl set 0 + fi + exit 0 # if toggle is used don't continue +fi + +# default path +percentage(){ brightnessctl -m | cut -d',' -f4; } +printf "current: "; percentage +if [[ -n "$1" ]]; then + brightnessctl set "$1\%" > /dev/null + printf "now: "; percentage +fi diff --git a/dlp-trnsrpt b/dlp-trnsrpt new file mode 100755 index 0000000..cb6a015 --- /dev/null +++ b/dlp-trnsrpt @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# docstring=transcript of youtube videos +set -E -o pipefail + +TEMP_FOLDER='/tmp/dlp-trnsrpt' +mkdir -p "$TEMP_FOLDER" +cd "$TEMP_FOLDER" + +yt-dlp --write-auto-sub --sub-langs 'en.*,.*orig' --convert-subs=srt --skip-download "$*" +nvim "$TEMP_FOLDER"/*-orig* diff --git a/hyprperf b/hyprperf new file mode 100755 index 0000000..9d45779 --- /dev/null +++ b/hyprperf @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# docstring=disable hyprland blur for performance +set -E -o pipefail + +hyprctl keyword decoration:blur:enabled false diff --git a/mserve b/mserve new file mode 100755 index 0000000..07123d7 --- /dev/null +++ b/mserve @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# docstring=serve files with http. +set -E -o pipefail + +miniserve \ + --auth=guest:Super9000! \ + --color-scheme-dark=monokai \ + --qrcode \ + --dirs-first \ + --hide-version-footer \ + --show-wget-footer \ + --title="Rano's quick share" + + +# implement a switch for easy --upload-files=DIR diff --git a/mytools b/mytools new file mode 100755 index 0000000..fc44975 --- /dev/null +++ b/mytools @@ -0,0 +1,59 @@ +#!/usr/bin/env python3 +# docstring=lists all tools and their docstrings +import os +import os.path as path + +CFG = { + "max_lines": 20, + "offset": 20 +} + +def parse_docstring(file_path, max_lines=CFG["max_lines"]): + """ + in file `file_path` and from the top until `max_lines` is reached, + checks if `docstring=` is present. + """ + with open(file_path, "r") as file_fd: + count = 0 + while count <= max_lines: + count += 1 + + line = file_fd.readline() + if "docstring=" in line: + try: + return line.split("=")[1].strip("\n").strip(" ") + except IndexError: + return "" + return "" + + +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) + + +def main(): + """ + lists all tools and their docstring from the same directory this sits in + """ + script_path = os.path.dirname(os.path.realpath(__file__)) + list_dir = sorted(os.listdir(script_path)) + + for element in list_dir: + element_path = path.join(script_path, element) + if path.isfile(element_path): + print(element, end="") + docstring = parse_docstring(element_path) + if docstring: + print(f":{offset(element)}{docstring}", end="") + print() + + +if __name__ == "__main__": + main() diff --git a/nstore-find b/nstore-find new file mode 100755 index 0000000..27999e1 --- /dev/null +++ b/nstore-find @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# docstring=searches the nix store with find +set -E -o pipefail + +find /nix/store/ -maxdepth 1 -iname '*'"$@"'*' diff --git a/nswitch b/nswitch new file mode 100755 index 0000000..a437a8d --- /dev/null +++ b/nswitch @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# from https://github.com/0atman/noboilerplate/blob/main/scripts/38-nixos.md#dont-use-nix-env +# docstring=quick edit (or ling xD) for nixos config +set -E -o pipefail + +cd ~/Projects/NixOS/ +nvim +nix fmt . &>/dev/null +git diff -U0 *.nix +echo "NixOS Rebuilding..." +sudo nixos-rebuild switch &>nixos-switch.log || ( + cat nixos-switch.log | grep --color error && false) +gen=$(nixos-rebuild list-generations | grep current) +git commit -am "$gen" diff --git a/rustdesk_profile b/rustdesk_profile new file mode 100755 index 0000000..c2fbec3 --- /dev/null +++ b/rustdesk_profile @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# docstring=have and create multiple rustdesk profiles +set -E -o pipefail + +# define frist element in argument list as profile name +RUSTDESK_PROFILE="$1" + +# Check user input +if [[ $RUSTDESK_PROFILE == \-* ]] || [[ $RUSTDESK_PROFILE == \-\-* ]] || [[ -z "$RUSTDESK_PROFILE" ]]; +then + #printf "Please provide first a profile name and then optional options with - or --.\n" + printf "Please provide a profile name.\n" + exit 1 +fi + +# make sure profile folder for config exists. +export XDG_CONFIG_HOME="$HOME/.config/rustdesk_${RUSTDESK_PROFILE}" +mkdir -p "$XDG_CONFIG_HOME" +printf "Using profile: $XDG_CONFIG_HOME\n" +#exit 0 + +# As of rustdesk 1.1.9 giving rustdesk unknown arguments crashes it with an address boundary error. +# (At least on my machines) +# Thats why we are calling rustdesk without arguments, until thats solved +rustdesk #"${*:2}" diff --git a/screenshot b/screenshot new file mode 100755 index 0000000..c2c7ce2 --- /dev/null +++ b/screenshot @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# docstring=do a screenshots on wayland compositors +set -E -o pipefail + +grim -g "$(slurp -o -r -c '#ff0000ff')" - | satty --filename - --fullscreen --output-filename ~/Media/Pictures/Screenshots/satty-$(date '+%Y%m%d-%H:%M:%S').png diff --git a/scrnl b/scrnl new file mode 100755 index 0000000..66836dd --- /dev/null +++ b/scrnl @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +# docstring=wraps kanshictl and adds features +import os +import os.path as path + +HOME = os.environ["HOME"] +CFG = { + "config_path": path.join(HOME, ".config/kanshi/config") +} + +def extract_layouts(config_path=CFG["config_path"]): + with open(config_path, "r") as file_fd: + for line in file_fd: + print(line) + + +def main(): + extract_layouts() + + +if __name__ == "__main__": + main() diff --git a/webcam b/webcam new file mode 100755 index 0000000..10e75fb --- /dev/null +++ b/webcam @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# docstring=open the webcam or v4l2 /dev/video* device +set -E -o pipefail + +if [[ "-h" == "$1" ]]; then + echo "-l list devices" + exit 0 +elif [[ "-l" == "$1" ]]; then + ls -la /dev/video* + exit 0 +fi + +device="/dev/video""${1:-"0"}" +echo ">>> opening: $device" +mpv --panscan=1.0 --no-osc --profile=low-latency --untimed "av://v4l2:$device"