Skip to content

Instantly share code, notes, and snippets.

View koonix's full-sized avatar
🦆
honk

koonix

🦆
honk
View GitHub Profile
@koonix
koonix / bashism-check.sh
Created September 10, 2022 20:57
check #!/bin/sh-shebanged scripts in /usr/bin for dash-incompatible syntax using shellcheck.
#!/bin/sh
# check #!/bin/sh-shebanged scripts in /usr/bin for
# dash-incompatible syntax using shellcheck.
# config
outdir=~/bashisms
searchdir=/usr/bin
mkdir -p "$outdir" || exit 1
#!/bin/bash
# winetricks, but for Bottles (https://github.com/bottlesdevs/Bottles).
# config
d=~/.local/share/bottles
set -e
cd ${d:?}/bottles
b=$(printf '%s\n' * | fzf)
r=$(grep '^Runner:' $b/bottle.yml | cut -d' ' -f2)
@koonix
koonix / burn-cd-dvd.sh
Created September 10, 2022 20:38
burn a file or an iso to a cd or dvd.
#!/bin/sh
# burn a file or an iso to a dvd.
# requires the cdrtools package.
# usage: $ burn FILE [TITLE]
# config
speed=1 # leave blank for default speed
dev=/dev/sr0
tmp=~/.cache/burn
@koonix
koonix / awol.sh
Created September 10, 2022 20:34
detect and show IP Address, MAC Address and OS of all computers on local network.
#!/bin/sh
# detect and show IP Address, MAC Address and OS of local network computers.
# requires nmap and ip(iproute2).
gateway=$(ip route); gateway=${gateway#*via }; gateway=${gateway%% *}
localip=$(ip route get 1); localip=${localip#*src }; localip=${localip%% *}
scan=$(sudo nmap -sT -n -O --host-timeout 1m "${gateway:?}"/24) || exit 1
printf '%s\n' "${scan:?}" | while IFS= read -r line; do case $line in 'Nmap scan report for '*)
@koonix
koonix / android-notif.sh
Last active December 17, 2022 10:30
A proof-of-concept script that shows android notifications on linux.
#!/bin/bash
# show android notifications on linux.
# it updates duckdns ddns and portforwards via upnp.
# requires a duckdns account, NetworkManager, miniupnpc and an2linux.
# config
duckdns_token= # put your duckdns token here
local_ddns= # local ddns name
public_ddns= # public ddns name
@koonix
koonix / obs-pulse-remap-sink.lua
Last active December 17, 2022 10:31
load/unload a pulseaudio module-remap-sink on OBS start/exit.
function script_description()
return [[
<h2>obs-pulse-remap v1</h2>
<p>Load a module-remap-sink on pulseaudio when OBS starts, and unload it when OBS exits.</p>
<p>Useful for when you want OBS to capture the audio of only one program.</p>
<p>Author: ghesy <ehsan at disroot dot org></p>
]]
end
local modules = {}
@koonix
koonix / fence.sh
Created September 10, 2022 20:10
run commands on cursor leaving or entering your machine when using barrier.
#!/bin/sh
# this script accompanies barrier (https://github.com/debauchee/barrier).
# it runs commands upon your mouse leaving or entering your machine.
# config
interval=2
check_count=10
# this hook runs when mouse enters this machine.
@koonix
koonix / ssh-config
Last active March 9, 2023 22:05
example ssh config (~/.ssh/config)
AddKeysToAgent yes
Host github.com
IdentityFile ~/.ssh/keys/github
Host aur.archlinux.org
IdentityFile ~/.ssh/keys/aur
User aur
Host desktop.local
@koonix
koonix / is-X-ptr-on-root-win.sh
Last active December 17, 2022 10:33
Detect if the pointer is on the root window (background) on Linux.
#!/bin/sh
# this script return true if the pointer is on the root window.
# requires xorg-xwininfo and xdotool.
rootwin=$(xwininfo -root | grep -Po 'Window id: \K\S+')
currentwin=$(printf '0x%x\n' "$(xdotool getmouselocation | cut -d: -f5)")
[ -n "$currentwin" ] && [ "$currentwin" = "$rootwin" ]
@koonix
koonix / sysact
Created July 11, 2022 09:52
a dmenu wrapper script for system functions.
#!/bin/bash
# a dmenu wrapper script for system functions.
actions=(
'鈴 Sleep'
'鈴 Hibernate'
'⏻ Poweroff'
' Reboot'
' Logout'
)