Skip to content

Instantly share code, notes, and snippets.

View elundmark's full-sized avatar
💭
I may be slow to respond.

elundmark

💭
I may be slow to respond.
View GitHub Profile
@elundmark
elundmark / mpv_remote.sh
Last active September 12, 2020 09:21
Remote control for MPV (mpv_remote.sh [play|pause|...] [all])
#!/bin/sh
# License: CC0 <https://creativecommons.org/choose/zero/>
# Author: elundmark@posteo.se
# Link: https://gist.github.com/elundmark/a7e491a1a3b26834972adeeb4962a955
# Using dbus and the mpv-mpris script:
# Targets either the frontmost player,
# or every instance of mpv (all),
# or one or more specific mpv processes by PID,
@elundmark
elundmark / change_mullvad_server.sh
Created September 20, 2019 16:16
Change Mullvad (VPN) Server in a terminal menu
#!/usr/bin/env bash
my_vpn_is() {
if /sbin/ethtool tun0 2>/dev/null | grep -qiP "link\s+detected"; then
echo up
else
echo down
fi
return 0
}
@elundmark
elundmark / LICENSE
Last active July 28, 2019 14:14
Modified vimv for subl (removed: git mv added: error checking - all files are protected from being overwritten , i3wm stuff)
Copyright 2017 Thameera Senanayaka
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
@elundmark
elundmark / print.css
Last active July 28, 2019 11:37
Print CSS for ostechnix.com
*:after, *:before { content: none !important; }
* {
-moz-box-shadow: none !important;
-webkit-box-shadow: none !important;
box-shadow: none !important; }
.archive .post, .blog .post, .search .grid-item, .search .page, .search .post, .single .post, .post-tags {
margin: 0 !important; }
.content {
float: none !important;
width: 100% !important; }
@elundmark
elundmark / example.sh
Last active July 27, 2019 13:55
Spin! (I use it in scripts to indicate work is in progress)
#!/bin/bash
spin.js &
declare PID=$!
sleep 5s
kill -INT "$PID"
@elundmark
elundmark / rain.sh
Created July 27, 2019 12:18
Rainbows!
#!/usr/bin/env bash
set -e
repeat_char () {
printf '%0*d' "$2" 0 | sed 's/0/'"$1"'/g'
return 0
}
if ! command -v lolcat; then
@elundmark
elundmark / ffp.sh
Last active July 19, 2019 14:33
View html attachment in neomutt with one keypress
#!/usr/bin/env bash
declare tmp_file="/tmp/neomutt_ffp_piped_html"
if [[ -p /dev/stdout ]] ; then exit 0; fi
# Privacy - remove tmp file after 20 seconds
( sleep 20s && rm -f "$tmp_file" )&
# Disable fullscreen-mode if any
@elundmark
elundmark / args_to_lines.sh
Created July 17, 2019 11:09
Print arguments on sepearate lines
#!/usr/bin/env bash
f() {
local -a args=("${@}") valid_args=()
local -i i=0 len=${#args[@]}
for (( ; i < len; i++ )); do
if [[ "${args[i]}" != '' ]] ; then
valid_args+=("${args[i]}")
else
echo "Removed empty string [$((i+1))]" 1>&2
@elundmark
elundmark / 00_reconnect_mullvad.sh
Last active July 16, 2019 08:44
Re-connect mullvad vpn on (my) wifi/ethernet up/down
#!/bin/sh
# https://wiki.archlinux.org/index.php/NetworkManager#Network_services_with_NetworkManager_dispatcher
# cat /etc/NetworkManager/dispatcher.d/00_reconnect_mullvad.sh
#
# sudo cp -f -v -t /etc/NetworkManager/dispatcher.d/ ~/bin/00_reconnect_mullvad.sh
# sudo chmod a+x /etc/NetworkManager/dispatcher.d/00_reconnect_mullvad.sh
# create lockfile
if ! mkdir /tmp/.reconnecting_mullvad_vpn ; then
@elundmark
elundmark / ddg.sh
Last active July 16, 2019 08:36
Anonymous POST Search on DuckDuckGo
#!/usr/bin/env bash
declare tmp_folder="$HOME/.ramdisk/.ddg" tmp_file
mkdir -p "$tmp_folder" || exit 1
declare URL='https://duckduckgo.com/'
declare -i image_search=0 swedish_only=0 from_console=0
declare -a args=()
while getopts ":isc" options ; do
case "$options" in