Skip to content

Instantly share code, notes, and snippets.

View m-rey's full-sized avatar
🏳️‍⚧️
Hack the planet!

Mæve Rey m-rey

🏳️‍⚧️
Hack the planet!
  • Nuremberg, Germany
View GitHub Profile
@m-rey
m-rey / garmin_update_maps.sh
Created July 7, 2021 15:56
download OpenStreetMap based maps for Garmin devices
#!/bin/sh
# USAGE
# garmin_update_maps FILE_WITH_URLS_TO_IMG.ZIP_MAP_FILES
# download map updates if available using URL list file (freizeitkarte-osm.de has some direct links available)
aria2c --conditional-get true --allow-overwrite --optimize-concurrent-downloads --file-allocation=none --enable-http-pipelining -i "$1"
# extract and rename map image files
for zip in *.zip; do
@m-rey
m-rey / parse_local_mimetype.zsh
Created June 18, 2021 13:53
parse local .desktop files for MIME types and output thom ordered by frecuency. You may have to adjust your shell config or the code to either enable globbing or rewrite the oneliner.
#!/bin/zsh
grep -hoP '(?<=MimeType=).*(?=(;|\n))' ~/.local/share/applications/**/*.desktop /usr/share/applications/**/*.desktop | tr ';' '\n' | tr -d "[:blank:]" | sort | uniq -c | sort -n
@m-rey
m-rey / merge_kdbx.sh
Last active June 18, 2021 16:04
function to bulk merge KeepassXC DBs (*.kdbx)
#!/bin/sh
# DESCRIPTION
# Merge one or more KeepassXc DBs into another KeepassXC DB.
#
# PURPOSE
# Syncthing can't natively merge/rebase KeepassXC DB files (yet?), thus it sometimes
# falls back to saving all differing DB versions as file sync conflicts.
# Luckily, `keepassxc-cli` *can* merge one DB into another, but only one at a time.
# As Syncthing often creates many conflict files, it would take ages to manually merge
#!/bin/bash
fonts_dir="${HOME}/.local/share/fonts"
if [ ! -d "${fonts_dir}" ]; then
echo "mkdir -p $fonts_dir"
mkdir -p "${fonts_dir}"
else
echo "Found fonts dir $fonts_dir"
fi
@m-rey
m-rey / waybar_minecraft.json
Created April 14, 2021 21:02
waybar minecraft module
"custom/minecraft": {
"format": "⬢ {}",
"interval": 10,
"exec": "printf '\\x06\\x00\\x00\\x00\\x00\\x00\\x01\\x01\\x00' | nc -N $SERVER_IP $SERVER_PORT | tr -cd '[:print:]' | jq -r '.players.online, .players.max'| xargs printf '%d/%d'",
"on-click": "printf '\\x06\\x00\\x00\\x00\\x00\\x00\\x01\\x01\\x00' | nc -N $SERVER_IP $SERVER_PORT | tr -cd '[:print:]' | jq -r '.players.sample[] | .name' | xargs -0 notify-send 'online users'",
"on-click-right": "flatpak run org.tlauncher.TLauncher"
}
@m-rey
m-rey / fix_url.sh
Last active March 28, 2021 04:28
script to remove inaccessible urls. In cases of a permanent redirect it replaces the url with the one it redirects to. I recommend using it on a file like this way: `parallel --ungroup --jobs 0 --arg-file "INPUT_FILE" "./fix_url.sh" >> OUTPUT_FILE`
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
# set -o xtrace
# USAGE
# ./fix_url.sh URL
# parallel --ungroup --jobs 0 --arg-file URL_LIST_FILE './fix_url.sh' >> FILTERED_URL_LIST_FILE
#!/bin/bash
# Copyright 2021 Martin Rey
# REQUIREMENTS
# bash, xargs, gpg2, ffmpeg, jq
#
# USAGE
# cryptocam_decrypt.sh INPUT_DIR OUTPUT_DIR
#
@m-rey
m-rey / fix_virt-manager_no_polkit_agent.sh
Created November 13, 2020 17:05
virt-manager: authentication unavailable: no polkit agent available to authenticate action 'org.libvirt.unix.manage'
#!/bin/sh
# source: https://bugzilla.redhat.com/show_bug.cgi?id=1437933#c2
# add current user to libvirt group
sudo usermod --append --groups libvirt `whoami`
@m-rey
m-rey / add_ovpn_conf_to_nm.sh
Created October 21, 2020 13:06
Add OpenVPN config to NetworkManager
#!/bin/sh
sudo nmcli connection import type openvpn file $OPENVPN_CONF