Skip to content

Instantly share code, notes, and snippets.

View bakkeby's full-sized avatar
๐Ÿ”ง
Taking the fun out of patching

Stein Gunnar Bakkeby bakkeby

๐Ÿ”ง
Taking the fun out of patching
View GitHub Profile
@bakkeby
bakkeby / client_decoration_menu.sh
Last active March 11, 2025 09:26
A menu that embeds straight into the currently focused window
#!/bin/bash
WID=$(xdotool getactivewindow)
# If we do not have a window then bail early
test -z "$WID" && exit
TITLE=$(xdotool getactivewindow getwindowname)
IPCMD="duskc run_command"
@bakkeby
bakkeby / otp.sh
Last active March 12, 2025 08:22
A dmenu script to handle OTP secret keys and generate one-time passwords rather than using a mobile application. Depends on oathtool.
#!/bin/bash
DAT=$(dirname "${BASH_SOURCE[0]}")/otp.dat
MENU="dmenu"
NOTIFY=notify-send
TOPIC="oathtool"
KEYDESC="OTP"
if [ ! -f "$DAT" ]; then
touch "$DAT"
@bakkeby
bakkeby / bookmarks_menu.sh
Last active March 14, 2025 17:38
A dmenu script to store and open bookmarks.
#!/bin/bash
DAT=$(dirname "${BASH_SOURCE[0]}")/bookmarks.dat
MENU="dmenu -c -w 50% -bw 20"
NOTIFY=notify-send
TOPIC=${TOPIC:-Bookmark}
KEYDESC=${KEYDESC:-Bookmark}
ALLOW_EDIT_URLS=${ALLOW_EDIT_URLS:-1}
notify() {
@bakkeby
bakkeby / clipboard_menu.sh
Created March 3, 2025 10:45
A dmenu script to cache commands and one-liners in a long term clipboard using a flat file as storage medium.
#!/bin/bash
DAT=$(dirname "${BASH_SOURCE[0]}")/clipboard.dat
MENU="dmenu -c -w 50% -bw 20"
NOTIFY=notify-send
TOPIC="Clipboard"
KEYDESC="Cached key"
if [ ! -f "$DAT" ]; then
touch "$DAT"
@bakkeby
bakkeby / list_keycodes.c
Created April 14, 2024 20:44
Tool to list all key codes that map to a symbolic key.
#if 0
gcc -o list_keycodes list_keycodes.c -lX11
exit
#endif
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
#include <stdio.h>
int
@bakkeby
bakkeby / mouse_battery.sh
Created November 30, 2021 13:43
status2d mouse battery status script on the form of (when battery is low): ๐Ÿ–ฑ Low
#!/bin/bash
COLOR=^c#FF0000^
BATTERY_ICON=๐Ÿ–ฑ
FILE=$(ls /sys/class/power_supply/hidpp_battery_*/capacity_level 2>/dev/null | head -n 1)
if [ ! -z "$FILE" ]; then
CAPACITY=$(cat $FILE)
if [ $CAPACITY = "Low" ]; then
echo "${COLOR}${BATTERY_ICON} ${CAPACITY}^d^"
fi
fi
@bakkeby
bakkeby / relabel.sh
Created November 25, 2021 20:34
Quick script to change the window class of the currently active window. Depends on dmenu and xdotool.
#!/bin/sh
# Sets the class of a window, depends on dmenu and xdotool
LABEL=$(echo | dmenu)
if [ ! -z "$LABEL" ]; then
xdotool getactivewindow set_window --class "$LABEL"
fi
@bakkeby
bakkeby / mem.sh
Created October 21, 2021 17:29
status2d memory status script on the form of: <moon symbol> 5178/15998 MB
#!/bin/sh
COLOR_SYMBOL=^c#FFB14A^
# COLOR_HL=^c#FFF7D4^
# COLOR_NORM=^c#C6BDBD^
COLOR_HL=
COLOR_NORM=
symb='๎•๎–๎—๎˜๎™๎š๎›๎œ๎๎ž๎Ÿ๎ ๎ก๎ข๎ฃ๎ฃ'
mem=($(free | awk '/Mem/ {printf "%d %d", $3 / 1024.0, $2 / 1024.0 }'))
NOM=${mem[0]}
DEN=${mem[1]}
@bakkeby
bakkeby / volume.sh
Created October 21, 2021 17:23
status2d volume status script
#!/bin/sh
#COLOR=^c#FFF7D4^
COLOR=
if [[ $(pacmd list-sinks | grep -c "muted: yes") > 0 ]]; then
echo "๐Ÿ”‡"
exit
fi
VOLUME=$(pacmd list-sinks | awk '
BEGIN {
FOUND=0
@bakkeby
bakkeby / clock.sh
Created October 21, 2021 17:17
status2d clock status with output like: October 21st, 19:17:08
#!/bin/sh
#COLOR=^c#FFF7D4^
TIME="$(date '+%B %dXX' | sed -r -e 's/(1[123])XX/\1th/;s/1XX/1st/;s/2XX/2nd/;s/3XX/3rd/;s/XX/th/;s/ 0/ /'), $(date +'%H:%M:%S')"
echo "${COLOR}${TIME}^d^"