move xdg directories to the default location.

a lot of applications seem to hardcode this location, so it's better to
have something default, or default-adjasoned.
This commit is contained in:
2025-11-19 09:37:29 +01:00
parent ad02049329
commit 9ece4e28de
61 changed files with 6 additions and 6 deletions

2
.local/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/share/*
!/share/cpusetcores

29
.local/bin/buildconfig Executable file
View File

@@ -0,0 +1,29 @@
#!/usr/bin/bash
BUILD_CONFIG=
# try to find a valid build config path
if [ -n "${1+x}" ] && [ -f "$1" ] && [[ "$(basename "$1")" == ".buildconfig" ]]; then BUILD_CONFIG="$1" # first check if a build config has been specified, and whether it's a valid path
elif [ -n "${1+x}" ]; then echo "E: the specified path '$1' is not a valid path!"; exit 1
elif [[ -f "$PWD/.buildconfig" ]]; then BUILD_CONFIG="$PWD/.buildconfig" # then check if there is a build config in the current working directory
elif [[ -f "$HOME/.buildconfig" ]]; then BUILD_CONFIG="$HOME/.buildconfig" # then check if there is a build config in the home directory
else $EDITOR .buildconfig
#else echo "E: could not find a .buildconfig file and none was specified!"; exit 1
fi
source "$BUILD_CONFIG"
[ -z "${cmd+x}" ] && { echo "E: cmd was not set! '$BUILD_CONFIG'"; exit 1; }
[ -z "${arg+x}" ] && { echo "E: arg was not set! '$BUILD_CONFIG'"; exit 1; }
# export the environment variables if they've been set
if [[ -n ${env+x} ]]; then
for var in "${!env[@]}"; do
export "$var=${env[$var]}"
done
fi
# execute the command with the arguments
# don't mind if the user made arguments separate out, that would likely be the user's intention
$cmd "$arg"
exit $?

BIN
.local/bin/coinflip Executable file

Binary file not shown.

2
.local/bin/cpusetcores Executable file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/sh
sudo "$XDG_DATA_HOME/cpusetcores" "$@" -v

2
.local/bin/emcc Executable file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/sh
"$HOME/.local/share/emsdk/upstream/emscripten/emcc" "$@"

2
.local/bin/emsdk Executable file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/sh
"$HOME/.local/share/emsdk/emsdk" "$@"

11
.local/bin/git-leaderboard Executable file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/sh
if [ -z ${1+x} ]; then
printf "\033[91mdidn't include a file exstension. (eg. \".cs\")\n"
exit 1
fi
# get all the files with the file extension
git ls-files | grep -E ".*\\$1" |
xargs -n 1 git blame --line-porcelain | # run git blame on each file, which shows the commit for each line
grep "^author " | sort | # aquire the authors of this output and sort it
uniq -c | sort -nr # count all the unique authors and sort by number

5
.local/bin/java-prime Executable file
View File

@@ -0,0 +1,5 @@
#!/usr/bin/sh
export __NV_PRIME_RENDER_OFFLOAD=1
export __VK_LAYER_NV_optimus=NVIDIA_only
export __GLX_VENDOR_LIBRARY_NAME=nvidia
exec java "$@" --no-window

2
.local/bin/prime-run Executable file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/sh
__NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only __GLX_VENDOR_LIBRARY_NAME=nvidia "$@"

66
.local/bin/prime-run-conf Executable file
View File

@@ -0,0 +1,66 @@
#!/bin/python
import os
from sys import stderr
def error(msg: str):
print(f"\033[91m{msg}\033[0m", file=stderr)
def validate_path(path: str, outdir: str, outpath: str) -> bool:
if (os.path.isdir(outdir) == False):
error(f"'{outdir}' does not exist! can't write .desktop file!")
return False
if (os.path.exists(outpath)):
error(f"'{outpath}' already exists!")
return False
if (os.path.isfile(path) == False):
error(f"file does not exist: '{path}'")
return False
return True
def create_desktop_file(path: str) -> int:
outdir = os.environ['HOME'] + "/.local/share/applications"
outpath = outdir + "/" + os.path.basename(path)
if (validate_path(path, outdir, outpath) == False):
return 1
f_in = open(path, "r")
f_out = open(outpath, "w")
while (True):
ln = f_in.readline();
if (len(ln) == 0):
break
if (ln.startswith("Exec=")):
lns = ln.split('=', 1)
ln = f"{lns[0]}=prime-run {lns[1]}"
f_out.write(ln)
f_in.close()
f_out.close()
return 0
def main(argc: int, argv: list[str]) -> int:
if (argc <= 1):
error("incorrect amount of arguments! expected: 'desktop file path'")
return 1
err = 0
i = 1
while (i < argc):
err |= create_desktop_file(argv[i])
i += 1
return err
if __name__ == "__main__":
import sys
exit(main(len(sys.argv), sys.argv));

62
.local/bin/satallite-wp-update Executable file
View File

@@ -0,0 +1,62 @@
#!/usr/bin/bash
# shellcheck disable=SC1090,SC1091
# set -xv
EUMETSAT_KEY="jdBM1PsDQUm0tCZfk9VXD6IaJoUa"
EUMETSAT_SECRET="SumkiqFMU3MAGpt_azb1KXKgjdMa"
OUTDIR="$HOME/photos/eumetsat"
# full screen coverage
# PRJ=AUTO:42004,52,5,0
# BBOX=(-6400000 -100000 6400000 7700000)
# full disk
PRJ=AUTO:42003,0,0,0
BBOX=(-12800000 -7200000 12800000 7200000)
# europe
# PRJ=AUTO:42004,0,0,0
# BBOX=(22.5 -45 90 67.5)
# BBOX=(-45 -90 180 135)
# BBOX=(-4500000 2250000 6750000 9000000)
WIDTH=1920
HEIGHT=1080
error() {
printf "\033[31m%s\033[0m\n" "$1"
. "$HOME/.fehbg"
exit 1
}
# verify internet
ping -c1 1.1.1.1 >>/dev/null || error "couldn't establish an internet connection!"
# acquire the API key
key=$(
curl -k -d "grant_type=client_credentials" \
-H "Authorization: Basic $(printf "%s:%s" "$EUMETSAT_KEY" "$EUMETSAT_SECRET" | base64)" \
https://api.eumetsat.int/token | jq -r '.["access_token"]'
)
# set url
url="https://view.eumetsat.int/geoserver/wms?"
url+="&service=WMS"
url+="&request=GetMap"
url+="&version=1.3.0"
url+="&layers=mtg_fd:rgb_geocolour"
url+="&width=$WIDTH&height=$HEIGHT"
url+="&bbox=${BBOX[0]},${BBOX[1]},${BBOX[2]},${BBOX[3]}"
url+="&crs=$PRJ"
url+="&styles="
url+="&transparent=true"
url+="&format=image/png"
url+="&access_token=$key"
# process incoming data
[ ! -d "$OUTDIR" ] && { mkdir -p "$OUTDIR" || error "failed to access '$OUTDIR'!"; }
curl "$url" -o "$OUTDIR/tmp.png" || error "failed to download from url='$url'!"
mv -f "$OUTDIR/tmp.png" "$OUTDIR/curr.png"
# update the feh background
. "$HOME/.fehbg"

14
.local/bin/unzip-all Executable file
View File

@@ -0,0 +1,14 @@
#!/usr/bin/sh
if [ -z ${var+2} ]; then
printf "\033[91mno parameters were given!\033[0m\n"
fi
for i in $2; do
readonly fname
fname="$(basename "$i" .*)"
mkdir "$fname"
cd "$fname" || return 1
unzip "../$i"
cd - || return 1
done

6
.local/bin/uwu Executable file
View File

@@ -0,0 +1,6 @@
#!/usr/bin/sh
while true; do
printf "owo "
sleep 0.25
done

4
.local/bin/x-brightness-down Executable file
View File

@@ -0,0 +1,4 @@
#!/usr/bin/sh
br=$(brightnessctl set 5%- |
grep '%' | awk '{print $4}' | sed 's/[^0-9]//g')
notify-send -u low -i display-brightness-symbolic -h int:value:"$br" -h string:x-dunst-stack-tag:'brightnessctl' -a 'brightnessctl' "brightness: $br%"

4
.local/bin/x-brightness-up Executable file
View File

@@ -0,0 +1,4 @@
#!/usr/bin/sh
br=$(brightnessctl set 5%+ |
grep '%' | awk '{print $4}' | sed 's/[^0-9]//g')
notify-send -i display-brightness-symbolic -u low -h int:value:"$br" -h string:x-dunst-stack-tag:'brightnessctl' -a 'brightnessctl' "brightness: $br%"

5
.local/bin/x-mic-mute Executable file
View File

@@ -0,0 +1,5 @@
#!/usr/bin/sh
vol_str=$(wpctl get-volume @DEFAULT_AUDIO_SOURCE@)
vol_int="$(echo "$vol_str" | sed 's/[^0-9]*//g')"
notify-send -i microphone-sensitivity-muted -u low -h int:value:"$vol_int" -h string:x-dunst-stack-tag:'audioctl' -a 'audioctl' "$vol_str"

56
.local/bin/x-volume Executable file
View File

@@ -0,0 +1,56 @@
#!/usr/bin/env sh
# the amount to increase / decrease each time
[ -z "$AMOUNT" ] && AMOUNT=5
# utility for sending notifications easily
notify() {
notify-send "$@" -h string:x-dunst-stack-tag:'audioctl' -a 'audioctl'
}
# get current volume information
vol_str="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
# Remove leading non-numeric or zero characters, then remove remaining non-numeric characters.
# NOTE: if zero (0.00), the string will be empty. This is fine for arithmetic operations.
vol_int="$(echo "$vol_str" | sed 's/^[^1-9]*//; s/[^0-9]//g')"
# if the string contains MUTED, set the variable accordion
case "$vol_str" in
*MUTED*) vol_off=1 ;;
*) vol_off=0 ;;
esac
# handle what action to perform from the argument
echo $vol_off
case $1 in
up) vol_int=$((vol_int + AMOUNT)) ;;
down) vol_int=$((vol_int - AMOUNT)) ;;
mute) vol_off=$((!vol_off)) ;;
*)
echo 'E: could not decide what audio action to perform!' >&2
notify 'could not decide what audio action to perform!' -u critical -t 5000
exit 1
;;
esac
vol_int=$((vol_int - (vol_int % AMOUNT)))
vol_pcnt=$(echo "scale = 2; $vol_int / 100;" | bc)
echo $vol_off
wpctl set-volume @DEFAULT_AUDIO_SINK@ "$vol_pcnt"
wpctl set-mute @DEFAULT_AUDIO_SINK@ "$vol_off"
play -n synth 0.005 sine 1000 vol 0.2 2>/dev/null
if [ "$vol_int" -eq 0 ] || [ "$vol_off" -eq 1 ]; then
ico=audio-volume-muted
elif [ "$vol_int" -lt 33 ]; then
ico=audio-volume-low
elif [ "$vol_int" -lt 66 ]; then
ico=audio-volume-medium
else
ico=audio-volume-high
fi
str="volume: $vol_int% $([ $vol_off -eq 1 ] && printf '(MUTE)')"
notify -i "$ico" -u low -h "int:value:$vol_int" "$str"

14
.local/bin/xfullscreen-toggle Executable file
View File

@@ -0,0 +1,14 @@
#!/usr/bin/sh
WIN=$(xdotool getwindowfocus)
STATE=$(xprop -id "$WIN" _NET_WM_STATE)
# check if fullscreen is present in the state
if echo "$STATE" | grep -q '_NET_WM_STATE_FULLSCREEN'; then
wmctrl -ir "$WIN" -b remove,fullscreen
exit $?
else
# If not fullscreen, add it
wmctrl -ir "$WIN" -b add,fullscreen
exit $?
fi

BIN
.local/share/cpusetcores Executable file

Binary file not shown.