diff --git a/iphex b/base256.py similarity index 91% rename from iphex rename to base256.py index 1093aaa..7a3e860 100755 --- a/iphex +++ b/base256.py @@ -4,7 +4,7 @@ from sys import argv def from_base256(number): - num = int(number, 16) + num = int(number) addr = list() for e in range(3, -1, -1): multiplier = 256 ** e @@ -20,7 +20,7 @@ def to_base256(addr): for e in range(3, -1, -1): num += int(addr[3-e]) * 256 ** e - return '{0:08x}'.format(num) + return str(num) try: result = from_base256(argv[1]) diff --git a/gdk_scale b/gdk_scale deleted file mode 100755 index da2a457..0000000 --- a/gdk_scale +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env zsh - -export GDK_SCALE=$1 GDK_DPI_SCALE=$(printf '%.1f' $((1.0/$1))) -exec $2 diff --git a/is_private b/is_private deleted file mode 100755 index 5625119..0000000 --- a/is_private +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env zsh -typeset -ga PRIVATE_RANGES=( - 00001010 # 10.0.0.0/8 - 101011000001 # 172.16.0.0/12 - 1100000010101000 # 192.168.0.0/16 -) - -test_range() { - typeset net addr=$(printf '%.2x' ${(s:.:)1}) - for net in $PRIVATE_RANGES; do - ((16#$addr >> (32 - $#net) == 2#$net)) && return 0 - done -} - -report() { - typeset result='private' addr=$1 state=$2 - ((state)) && result='not private' - printf "%s is %s\n" $addr $result - exit $state -} - -main() { - test_range $1 && report $1 0 - report $1 1 -} - -main $1 diff --git a/post-autorandr b/post-autorandr deleted file mode 100755 index 9ec7c5d..0000000 --- a/post-autorandr +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env zsh -#------------------------------------------------------------------------------ -# xsettingsd systemd unit: -# -- -# [Unit] -# Description=xsettingsd magic -# -# [Service] -# ExecStart=/usr/bin/xsettingsd -# ExecReload=/bin/kill -HUP $MAINPID -# -# [Install] -# WantedBy=default.target -# -- -XSETTINGSD_TEMPLATE='Xft/Hinting 1\nXft/HintStyle "hintslight"\nXft/Antialias 1\nXft/RGBA "rgb"\nXft/DPI %s\n' -XSETTINGSD_CONFIG=/run/user/$UID/xsettingsd-config - -XKB_OPTS='grp:win_space_toggle,compose:menu' -XKB_LAYOUTS='us(altgr-intl),ru(typewriter)' - -WALLPAPER=$HOME/.wallpaper - -TOUCHPAD_DEV='SynPS/2 Synaptics TouchPad' - -DPI=${1:-96} -#------------------------------------------------------------------------------ - -# reset xkbmap, set xkbmap -setxkbmap us -option -setxkbmap $XKB_LAYOUTS -option $XKB_OPTS - -# configure touchpad -xinput set-prop $TOUCHPAD_DEV 'libinput Click Method Enabled' 0 1 -xinput set-prop $TOUCHPAD_DEV 'libinput Middle Emulation Enabled' 1 - -# background -feh --bg-fill $WALLPAPER - -# dpi - xsettignsd, has to be started here because config is absent on boot -printf $XSETTINGSD_TEMPLATE $(($DPI * 1024)) > $XSETTINGSD_CONFIG -systemctl --quiet --user is-active xsettingsd || systemctl --user start xsettingsd -systemctl --user reload xsettingsd.service - -# dpi - other -xrdb -merge <(echo "Xft.dpi: $DPI") -xrandr --dpi $DPI -i3-msg restart - -# report -current_config=$(autorandr --current) -notify-send "$current_config config applied" diff --git a/q3srv b/q3srv deleted file mode 100755 index 0b4f149..0000000 --- a/q3srv +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/env python3 -from argparse import ArgumentParser -from os import system -from random import shuffle -from sys import exit - -# TODO: move this shit to a yaml config somewhere in /etc -USER = 'quake3' # linux user, for sudo -u -BIN = '/usr/bin/q3ded' -CONF = '/srv/q3/.q3a/baseq3/autoexec.cfg' -PARAM = '+exec autoexec.cfg' - -MAPLISTS = { - 'ffa': [ - 'q3dm2', 'q3dm3', 'q3dm4', 'q3dm5', 'q3dm6', - 'q3dm7', 'q3dm8', 'q3dm9', 'q3dm10', 'q3dm11' - ], - 'duel': [ - 'q3dm1', 'q3dm2', 'pro-q3dm6', 'pro-q3dm13', - 'q3tourney1', 'q3tourney3', 'q3tourney5', 'q3tourney6', - 'pro-q3tourney2', 'pro-q3tourney4' - ], - 'ctf': list() -} -BOTS = { - 'level': '3', - 'names': [ - 'Anarki', 'Angel', 'Crash', 'Doom', 'Hunter', - 'Klesk', 'Major', 'Mynx', 'Orbb', 'Slash', 'Xaero' - ] -} - - -# these are saved to the q3config_server.cfg on the first run -# no point in keeping them here afterwards -BOOTSTRAP_OPTS = dict() -# BOOTSTRAP_OPTS = { -# 'sv_pure': '0', # enable client side mods, like better fonts or graphics -# 'sv_maxclients': '8', -# 'sv_hostname': 'myhost.tld' -# -# # this will let your server send maps to clients -# # the downloads are attempted from http://%sv_dlURL%/baseq3/mapname.pk3 -# # note the protocol - no support for https, -# # as well as the need to have baseq3 as a part of the path -# # note that clients have to seta cl_allowDownload 1 for that to work -# 'sv_dlURL': 'anyhost.tld/q3', -# 'sv_allowDownloads': '1' -# } - - -def parse_arguments(): - desc = 'host a q3 server' - parser = ArgumentParser(description=desc) - parser.add_argument('-m', '--gamemode', default='ffa') - parser.add_argument('-f', '--fraglimit', type=int, default=15) - parser.add_argument('-t', '--timelimit', type=int, default=10) - parser.add_argument('-b', '--bots', type=int, default=0) - return parser.parse_args() - - -def gen_confline(param, value): - return 'seta {} "{}"\n'.format(param, value) - - -def gen_maplist(maplist): - shuffle(maplist) - num = 1 - stmpl = 'set d{} "map {} ; set nextmap vstr d{}"\n' - script = str() - while maplist: - nextnum = 1 if len(maplist) == 1 else num + 1 - script += stmpl.format(num, maplist.pop(), nextnum) - num += 1 - script += 'vstr d1\n' - return script - - -def gen_addbots(count, level='3', names=list()): - shuffle(names) - btmpl = 'addbot {} {}\n' - script = str() - for bot in names[:count]: - script += btmpl.format(bot, level) - return script - - -def main(): - args = parse_arguments() - cfg_data = str() - try: - assert args.gamemode in MAPLISTS - except AssertionError: - exit('Wrong game mode specified!') - - for param in BOOTSTRAP_OPTS: - cfg_data += gen_confline(param, BOOTSTRAP_OPTS[param]) - cfg_data += gen_confline('fraglimit', args.fraglimit) - cfg_data += gen_confline('timelimit', args.timelimit) - # this should be last since it launches the actual maplist - cfg_data += gen_maplist(MAPLISTS[args.gamemode]) - if args.bots: - cfg_data += gen_addbots(args.bots, **BOTS) - - with open(CONF, 'w+') as config: - config.write(cfg_data) - system('sudo -u {} {} {}'.format(USER, BIN, PARAM)) - - -if __name__ == '__main__': - main() diff --git a/termcompat b/termcompat index 4598304..0681c66 100755 --- a/termcompat +++ b/termcompat @@ -1,14 +1,9 @@ -#!/usr/bin/env zsh +#!/usr/bin/env bash # run with more compatible TERM value -case $TERM in - (st-*) ;& - (alacritty*) ;& - (xterm-kitty) ;& - export TERM=xterm;; - (rxvt-unicode-*) - export TERM=rxvt-unicode;; - (tmux-*) - export TERM=screen.xterm-new;; -esac - -exec "$@" +typeset -A terms=( + [xterm-kitty]='xterm' + [rxvt-unicode-256color]='rxvt-unicode' + [st-256color]='xterm-256color' + [tmux-256color]='screen.xterm-new' +) +TERM="${terms[$TERM]:-$TERM}" exec "$@" diff --git a/truecolortest.awk b/truecolortest.awk index ce72813..20b8de0 100755 --- a/truecolortest.awk +++ b/truecolortest.awk @@ -2,7 +2,7 @@ # a simple script to test 24 bit compatibility in a terminal # source: https://gist.github.com/XVilka/8346728 BEGIN{ - s="=========="; s=s s s s s s s s; + s="▀▀▀▀▀▀▀▀▀▀"; s=s s s s s s s s; for (colnum = 0; colnum<77; colnum++) { r = 255-(colnum*255/76); g = (colnum*510/76); diff --git a/vcascadia-gen.sh b/vcascadia-gen.sh deleted file mode 100755 index a59bc37..0000000 --- a/vcascadia-gen.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env zsh -### -# https://github.com/microsoft/cascadia-code -# ss01 - handwritten italic -# ss02 - lua not equals ~= -# ss03 - serbian locale -# ss19 - slashed zero 0 -# ss20 - graphical control characters -### -# opentype-feature-freezer is necessary, install with pipx or pip -# pip install --upgrade opentype-feature-freezer -### - -name=VascadiaMod -arch=$name.tgz -ss=ss01,ss19,ss20 - -for font in CascadiaCodePL*.otf; do - src=$font - dst=${font/CascadiaCodePL/$name} - - pyftfeatfreeze -f $ss -R "Cascadia Code PL/$name" $src $dst -done - -eval tar -acvf $arch $name* diff --git a/xscreensaver-companion b/xscreensaver-companion index 3d23176..929f48a 100755 --- a/xscreensaver-companion +++ b/xscreensaver-companion @@ -35,13 +35,13 @@ function parse_actions case $action in (LOCK|BLANK) setxkbmap us -option - dunstctl set-paused true + notify-send DUNST_COMMAND_PAUSE ;; (UNBLANK) check_start gxkb $HOME/git/mine/vscripts/mykblayouts $HOME/.local/bin/touchpad-config - dunstctl set-paused false + notify-send DUNST_COMMAND_RESUME ;; esac done