summaryrefslogtreecommitdiff
path: root/.local
diff options
context:
space:
mode:
authorEvgeny Sorokin <me@ch1p.io>2024-01-06 03:41:49 +0000
committerEvgeny Sorokin <me@ch1p.io>2024-01-06 03:41:49 +0000
commit6e5d672ea04fb8c89ce9e91cf4c9a53fbb8c2f81 (patch)
treed9f9200cf572385cf25f41442231675d5eeabcb8 /.local
add somethingHEADmaster
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/awesome-trace-logs.sh10
-rwxr-xr-x.local/bin/intel-turbo.sh30
-rwxr-xr-x.local/bin/mikrotik-bootp-flash.sh24
-rwxr-xr-x.local/bin/mount-luks-partition-dump.sh30
-rwxr-xr-x.local/bin/ps-pull51
-rwxr-xr-x.local/bin/trackpoint-setup.sh15
6 files changed, 160 insertions, 0 deletions
diff --git a/.local/bin/awesome-trace-logs.sh b/.local/bin/awesome-trace-logs.sh
new file mode 100755
index 0000000..f76f253
--- /dev/null
+++ b/.local/bin/awesome-trace-logs.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+pid=$(ps -ef | awk '$8=="awesome" {print $2}')
+max_str_length=8192
+
+strace -e trace=write -s${max_str_length} -p${pid} 2>&1 \
+ | grep --line-buffered --color=no "write([12], " \
+ | sed -u 's/write([12], "\(.*\)", [0-9]\+) \+= [0-9]\+$/\1/g' \
+ | sed -u 's/\\n/\n/g' \
+ | sed -u 's/\\t/\t/g'
diff --git a/.local/bin/intel-turbo.sh b/.local/bin/intel-turbo.sh
new file mode 100755
index 0000000..57836e0
--- /dev/null
+++ b/.local/bin/intel-turbo.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+bold=$(tput bold)
+red=$(tput setaf 1)
+green=$(tput setaf 2)
+reset=$(tput sgr0)
+syspath="/sys/devices/system/cpu/intel_pstate/no_turbo"
+
+case "$1" in
+ on)
+ echo 0 > $syspath
+ ;;
+
+ off)
+ echo 1 > $syspath
+ ;;
+
+ *)
+ echo "Usage: $0 on|off"
+ echo
+ echo -n "Current turbo status: "
+
+ status=$(cat $syspath)
+ if [ "$status" = "0" ]; then
+ echo "${bold}${green}enabled${reset}"
+ else
+ echo "${bold}${red}disabled${reset}"
+ fi
+ ;;
+esac
diff --git a/.local/bin/mikrotik-bootp-flash.sh b/.local/bin/mikrotik-bootp-flash.sh
new file mode 100755
index 0000000..48360a9
--- /dev/null
+++ b/.local/bin/mikrotik-bootp-flash.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+IFNAME=enp0s25
+
+iptables -P INPUT ACCEPT
+
+ip addr replace 192.168.1.10/24 dev $IFNAME
+ip link set dev $IFNAME up
+
+/usr/sbin/dnsmasq \
+ --no-daemon \
+ --listen-address 192.168.1.10 \
+ --bind-interfaces \
+ -p0 \
+ --dhcp-authoritative \
+ --dhcp-range=192.168.1.100,192.168.1.200 \
+ --bootp-dynamic \
+ --dhcp-boot=openwrt-23.05.2-ipq40xx-mikrotik-mikrotik_hap-ac2-initramfs-kernel.bin \
+ --log-dhcp --log-debug \
+ --enable-tftp \
+ --tftp-root=$(pwd)
+
+iptables -P INPUT DROP
+
diff --git a/.local/bin/mount-luks-partition-dump.sh b/.local/bin/mount-luks-partition-dump.sh
new file mode 100755
index 0000000..2382d15
--- /dev/null
+++ b/.local/bin/mount-luks-partition-dump.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+error() {
+ echo "error: $@"
+ exit 1
+}
+
+set -e
+
+DUMP="$1"
+MOUNTPOINT=/media/luks-dump
+
+[ -d "$MOUNTPOINT" ] && error "$MOUNTPOINT already exists, you must delete it first"
+[ $EUID -ne 0 ] && error "must be run as root"
+[ -f "$DUMP" ] || error "'$DUMP' is not a file or is not readable"
+
+DEVICE=$(losetup -f)
+losetup $DEVICE "$DUMP"
+
+cryptsetup luksOpen $DEVICE luks-dump
+mkdir $MOUNTPOINT
+mount /dev/mapper/luks-dump $MOUNTPOINT
+
+echo "press enter when done..."
+read
+
+umount $MOUNTPOINT
+rmdir $MOUNTPOINT
+cryptsetup luksClose luks-dump
+losetup -d $DEVICE
diff --git a/.local/bin/ps-pull b/.local/bin/ps-pull
new file mode 100755
index 0000000..f25ba48
--- /dev/null
+++ b/.local/bin/ps-pull
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+set -e
+
+git_branch() {
+ git rev-parse --symbolic-full-name --abbrev-ref HEAD
+}
+
+[ -d .git ] || {
+ echo "error: not a git repository"
+ exit 1
+}
+
+[ -d .idea ] || {
+ echo "error: not a jetbrains repository"
+ exit 1
+}
+
+PREFETCH_HOOK=.git/hooks/prefetch
+CUR_BRANCH=$(git_branch)
+TARGET_BRANCH="$CUR_BRANCH"
+
+while getopts b: option
+do
+ case "${option}"
+ in
+ b)
+ TARGET_BRANCH=${OPTARG}
+ ;;
+
+ *)
+ :
+ ;;
+ esac
+done
+
+if [ "$CUR_BRANCH" != "$TARGET_BRANCH" ]; then
+ echo "new target branch: $TARGET_BRANCH"
+fi
+
+git add .
+git reset --hard
+[ -x "$PREFETCH_HOOK" ] && "./$PREFETCH_HOOK"
+git fetch -a dev
+if [ "$CUR_BRANCH" != "$TARGET_BRANCH" ]; then
+ git checkout "$TARGET_BRANCH" --
+fi
+git reset --hard dev/$TARGET_BRANCH
+#git pull dev $TARGET_BRANCH
+
+echo "current branch: $(git_branch)"
diff --git a/.local/bin/trackpoint-setup.sh b/.local/bin/trackpoint-setup.sh
new file mode 100755
index 0000000..e06c529
--- /dev/null
+++ b/.local/bin/trackpoint-setup.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+TP="TPPS/2 IBM TrackPoint"
+
+xinput set-prop "$TP" "Evdev Wheel Emulation" 1
+xinput set-prop "$TP" "Evdev Wheel Emulation Button" 2
+xinput set-prop "$TP" "Evdev Wheel Emulation Timeout" 200
+xinput set-prop "$TP" "Evdev Wheel Emulation Axes" 6 7 4 5
+
+xinput set-prop "$TP" "Device Accel Profile" 2
+xinput set-prop "$TP" "Device Accel Constant Deceleration" 0.8
+xinput set-prop "$TP" "Device Accel Adaptive Deceleration" 2.0
+
+xinput set-ptr-feedback "$TP" 0 20 15 # acceleration factor = 20/10
+