Add moar scripts
This commit is contained in:
parent
49430fb1a8
commit
3e17e5d4b2
|
@ -0,0 +1,2 @@
|
|||
#! /bin/sh -
|
||||
exec xrandr --output HDMI-1 --auto --output DP-1 --right-of HDMI-1 --auto
|
|
@ -0,0 +1,2 @@
|
|||
#! /bin/sh -
|
||||
exec xrandr --output eDP-1 --auto --output DP-1 --above eDP-1 --auto
|
|
@ -0,0 +1,10 @@
|
|||
#! /bin/sh -
|
||||
|
||||
if [ -t 0 ] && [ -n "${1}" ]; then
|
||||
while [ -n "${1}" ]; do
|
||||
printf '%s\n' "${1}" | sed 's/\\/\\\\/g; s/"/"'"'"'"'"'"'"/g; s/^/"/; s/$/"/'
|
||||
shift
|
||||
done
|
||||
else
|
||||
sed 's/\\/\\\\/g; s/"/"'"'"'"'"'"'"/g; s/^/"/; s/$/"/'
|
||||
fi
|
|
@ -0,0 +1,31 @@
|
|||
#! /bin/bash --
|
||||
|
||||
command -v lynx >/dev/null 2>&1 || { echo "Need lynx"; exit 1; }
|
||||
|
||||
urlencode () {
|
||||
local str="$*"
|
||||
local encoded=
|
||||
local i c x
|
||||
for (( i=0; i < ${#str}; ++i )); do
|
||||
c=${str:$i:1}
|
||||
case "$c" in
|
||||
[-_.~a-zA-Z0-9] ) x="$c" ;;
|
||||
* ) printf -v x '%%%02x' "'$c" ;;
|
||||
esac
|
||||
encoded+="$x"
|
||||
done
|
||||
printf %s "$encoded"
|
||||
}
|
||||
|
||||
if [ -t 0 ]; then
|
||||
query=$(urlencode "$*")
|
||||
dump=
|
||||
else
|
||||
query=$(urlencode "$(tr -d '\n')")
|
||||
dump="-dump"
|
||||
fi
|
||||
|
||||
base="https://duckduckgo.com/lite?q="
|
||||
[ "$0" = "ggl" ] && base="https://www.google.com/search?q="
|
||||
|
||||
exec lynx $dump "$base$query"
|
|
@ -0,0 +1,2 @@
|
|||
#! /bin/sh -
|
||||
exec xrandr --output eDP-1 --auto --output HDMI-1 --above eDP-1 --auto
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,78 @@
|
|||
#! /usr/bin/python3 --
|
||||
|
||||
import re
|
||||
import sys
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
def decode(bytes_):
|
||||
return bytes_.decode('utf-8').strip()
|
||||
|
||||
def debug(msg, color='red'):
|
||||
reset = '\033[m'
|
||||
if color == 'red':
|
||||
ansi_code = '\033[31m'
|
||||
elif color == 'green':
|
||||
ansi_code = '\033[32m'
|
||||
elif color == 'yellow':
|
||||
ansi_code = '\033[33m'
|
||||
else:
|
||||
print(f"Unknown color: '{color}'", file=sys.stderr, flush=True)
|
||||
ansi_code = reset
|
||||
print(ansi_code + msg + reset, file=sys.stderr, flush=True)
|
||||
|
||||
def run_bash(cmd):
|
||||
process = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE, close_fds=True)
|
||||
outb, errb = process.communicate()
|
||||
errcode = process.returncode
|
||||
if errcode != 0:
|
||||
debug("There was an error getting the MAC address")
|
||||
sys.exit(1)
|
||||
out = decode(outb).strip()
|
||||
return out
|
||||
|
||||
def get_permaddr():
|
||||
permaddr = run_bash("ip link show wlan0 | grep permaddr | awk '{ print $6 }'")
|
||||
return permaddr
|
||||
|
||||
def main():
|
||||
mac_address = run_bash("ip link show wlan0 | grep link/ether | awk '{ print $2 }'")
|
||||
as_int = int(mac_address.replace(':', ''), 16)
|
||||
set_directly = False
|
||||
if len(sys.argv) == 2:
|
||||
if sys.argv[1] == 'inc':
|
||||
debug("Incrementing MAC address by 1", 'green')
|
||||
as_int += 1
|
||||
elif sys.argv[1] == 'dec':
|
||||
debug("Decrementing MAC address by 1", 'green')
|
||||
as_int -= 1
|
||||
elif sys.argv[1] == 'reset':
|
||||
permaddr = get_permaddr()
|
||||
if not permaddr:
|
||||
debug("MAC address already matches real MAC address, nothing to change", 'yellow')
|
||||
return 0
|
||||
new_mac = permaddr
|
||||
debug(f"Resetting MAC address to {new_mac}", 'green')
|
||||
set_directly = True
|
||||
else:
|
||||
debug(f"Unknown argument: '{sys.argv[1]}'", 'red')
|
||||
debug(f"Must be one of: inc, dec, reset", 'red')
|
||||
sys.exit(2)
|
||||
else:
|
||||
debug("No argument provided. Doing default action", 'yellow')
|
||||
debug("Incrementing MAC address by 1", 'green')
|
||||
as_int += 1
|
||||
if not set_directly:
|
||||
as_hex = hex(as_int)[2:]
|
||||
split_as_hex = []
|
||||
for match in list(re.finditer('..', as_hex[::-1])):
|
||||
split_as_hex.insert(0, match.group()[::-1])
|
||||
new_mac = ':'.join(split_as_hex)
|
||||
commands = f'''
|
||||
sudo sh -c 'ip link set dev wlan0 down ; ip link set dev wlan0 address {new_mac} ; ip link set dev wlan0 up'
|
||||
'''.strip()
|
||||
commands = re.sub('\n\s*', '\n', commands)
|
||||
print(commands)
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
|
@ -0,0 +1,14 @@
|
|||
#! /bin/sh -
|
||||
|
||||
today="$(date +%Y-%m-%d)"
|
||||
note_filename="${HOME}/notes/note-${today}.md"
|
||||
|
||||
if [ ! -f "${note_filename}" ]; then
|
||||
echo "# Notes for ${today}" > "${note_filename}"
|
||||
fi
|
||||
|
||||
nvim -c "norm Go" \
|
||||
-c "norm Go## $(date +%H:%M)" \
|
||||
-c "norm G2o" \
|
||||
-c "norm zz" \
|
||||
-c "startinsert" "${note_filename}"
|
|
@ -0,0 +1,13 @@
|
|||
#! /bin/sh -
|
||||
|
||||
(
|
||||
|
||||
hdmi1_top
|
||||
dp1_right_hdmi1
|
||||
|
||||
sleep 5
|
||||
xwallpaper --output DP-1 --zoom /home/tosuman/Wallpapers/hor/Dune.jpg
|
||||
xwallpaper --output eDP-1 --zoom /home/tosuman/Wallpapers/favs/travellers.jpg
|
||||
xwallpaper --output HDMI-1 --zoom /home/tosuman/Wallpapers/hor/koi.png
|
||||
|
||||
) &
|
Loading…
Reference in New Issue