Lots of bin changes
This commit is contained in:
parent
2c617a5b49
commit
121798e075
12 changed files with 258 additions and 44 deletions
|
@ -7,6 +7,6 @@ base="${file%.*}"
|
||||||
cd "$dir" || exit
|
cd "$dir" || exit
|
||||||
|
|
||||||
case "$file" in
|
case "$file" in
|
||||||
*\.doc|*\.docx) libreoffice --convert-to pdf "$file" ;;
|
*\.doc|*\.docx|*\.pptx) libreoffice --convert-to pdf "$file" ;;
|
||||||
*) echo "Don't know how to convert $file"
|
*) echo "Don't know how to convert $file"
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -5,15 +5,27 @@ PASSWORDS="$HOME/.password-store"
|
||||||
|
|
||||||
function copy_password(){
|
function copy_password(){
|
||||||
local password="$1"
|
local password="$1"
|
||||||
|
local part="${2:-0}"
|
||||||
local sleep_argv0="jh password store sleep on display $DISPLAY"
|
local sleep_argv0="jh password store sleep on display $DISPLAY"
|
||||||
local before="$(xclip -o -selection clipboard 2>/dev/null | base64)"
|
local before="$(xclip -o -selection clipboard 2>/dev/null | base64)"
|
||||||
pkill -f "^$sleep_argv0" 2>/dev/null && sleep 0.5
|
pkill -f "^$sleep_argv0" 2>/dev/null && sleep 0.5
|
||||||
local pw=$(pass "$selection" | head -n 1)
|
local pw=""
|
||||||
|
case "$part" in
|
||||||
|
"10"|"otp")
|
||||||
|
local pw=$(pass otp "$password" | head -n 1)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
local pw=$(pass "$password" | head -n 1)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
if [ -z "$pw" ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
echo "$pw" | xclip -selection "primary"
|
echo "$pw" | xclip -selection "primary"
|
||||||
echo "$pw" | xclip -selection "clipboard"
|
echo "$pw" | xclip -selection "clipboard"
|
||||||
notify-send "Password put on clipboard" "Will be removed in 10 seconds"
|
notify-send -t 3000 "Password put on clipboard" "Will be removed in 3 seconds"
|
||||||
(
|
(
|
||||||
( exec -a "$sleep_argv0" bash <<<"trap 'kill %1' TERM; sleep '10' & wait" )
|
( exec -a "$sleep_argv0" bash <<<"trap 'kill %1' TERM; sleep '3' & wait" )
|
||||||
|
|
||||||
echo "$before" | base64 -d | xclip -selection "primary"
|
echo "$before" | base64 -d | xclip -selection "primary"
|
||||||
echo "$before" | base64 -d | xclip -selection "clipboard"
|
echo "$before" | base64 -d | xclip -selection "clipboard"
|
||||||
|
@ -25,7 +37,12 @@ function copy_password(){
|
||||||
|
|
||||||
if [ -d "$PASSWORDS" ]; then
|
if [ -d "$PASSWORDS" ]; then
|
||||||
cd "$PASSWORDS"
|
cd "$PASSWORDS"
|
||||||
selection=$((echo "NEW";find . -type f -name '*.gpg' | sed 's/.gpg$//' | sed 's/^.\///') | rofi -dmenu -i -l 20)
|
selection="$1"
|
||||||
|
ret="${2:-0}"
|
||||||
|
if [ -z "$selection" ]; then
|
||||||
|
selection=$((find . -type f -name '*.gpg' | sed 's/.gpg$//' | sed 's/^.\///') | rofi -dmenu -kb-custom-1 "Ctrl-o" -i -l 20)
|
||||||
|
ret="$?"
|
||||||
|
fi
|
||||||
if [ -n "$selection" ]; then
|
if [ -n "$selection" ]; then
|
||||||
if [[ "$selection" == "NEW" ]]; then
|
if [[ "$selection" == "NEW" ]]; then
|
||||||
dir="$(find . -type d -not -path \*.git\* |rofi -dmenu -p Directory | sed 's/^.\/?//')"
|
dir="$(find . -type d -not -path \*.git\* |rofi -dmenu -p Directory | sed 's/^.\/?//')"
|
||||||
|
@ -35,9 +52,9 @@ if [ -d "$PASSWORDS" ]; then
|
||||||
name="$(rofi -dmenu -p Name -lines 0)"
|
name="$(rofi -dmenu -p Name -lines 0)"
|
||||||
# Todo - create new passwords
|
# Todo - create new passwords
|
||||||
else
|
else
|
||||||
copy_password "$selection"
|
copy_password "$selection" "$ret"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
notify-send "$BOOKMARKS doesn't exist"
|
notify-send "\$PASSWORDS doesn't exist"
|
||||||
fi
|
fi
|
||||||
|
|
3
bin/.bin/emails/evolution-editor
Executable file
3
bin/.bin/emails/evolution-editor
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
source $HOME/.dotfiles/shells/zsh/current-color-scheme
|
||||||
|
vim "$@"
|
|
@ -1,7 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
lock() {
|
lock() {
|
||||||
|
killall -SIGUSR1 dunst # Pause dunst
|
||||||
~/.bin/i3/fadeLockScreen
|
~/.bin/i3/fadeLockScreen
|
||||||
#i3lock
|
killall -SIGUSR2 dunst # Resume dunst
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
|
71
bin/.bin/merrychristmas
Executable file
71
bin/.bin/merrychristmas
Executable file
|
@ -0,0 +1,71 @@
|
||||||
|
#!/bin/bash
|
||||||
|
trap "tput reset; tput cnorm; exit" 2
|
||||||
|
clear
|
||||||
|
tput civis
|
||||||
|
lin=2
|
||||||
|
col=$(($(tput cols) / 2))
|
||||||
|
c=$((col-1))
|
||||||
|
est=$((c-2))
|
||||||
|
color=0
|
||||||
|
tput setaf 2; tput bold
|
||||||
|
|
||||||
|
# Tree
|
||||||
|
for ((i=1; i<20; i+=2))
|
||||||
|
{
|
||||||
|
tput cup $lin $col
|
||||||
|
for ((j=1; j<=i; j++))
|
||||||
|
{
|
||||||
|
echo -n \*
|
||||||
|
}
|
||||||
|
let lin++
|
||||||
|
let col--
|
||||||
|
}
|
||||||
|
|
||||||
|
tput sgr0; tput setaf 3
|
||||||
|
|
||||||
|
# Trunk
|
||||||
|
for ((i=1; i<=2; i++))
|
||||||
|
{
|
||||||
|
tput cup $((lin++)) $c
|
||||||
|
echo 'mWm'
|
||||||
|
}
|
||||||
|
new_year=$(date +'%Y')
|
||||||
|
let new_year++
|
||||||
|
tput setaf 1; tput bold
|
||||||
|
tput cup $lin $((c - 8)); echo MERRY CHRISTMAS IRM
|
||||||
|
tput cup $((lin + 1)) $((c - 12)); echo And lots of HACKING in $new_year
|
||||||
|
let c++
|
||||||
|
k=1
|
||||||
|
|
||||||
|
# Lights and decorations
|
||||||
|
while true; do
|
||||||
|
for ((i=1; i<=35; i++)) {
|
||||||
|
# Turn off the lights
|
||||||
|
[ $k -gt 1 ] && {
|
||||||
|
tput setaf 2; tput bold
|
||||||
|
tput cup ${line[$[k-1]$i]} ${column[$[k-1]$i]}; echo \*
|
||||||
|
unset line[$[k-1]$i]; unset column[$[k-1]$i] # Array cleanup
|
||||||
|
}
|
||||||
|
|
||||||
|
li=$((RANDOM % 9 + 3))
|
||||||
|
start=$((c-li+2))
|
||||||
|
co=$((RANDOM % (li-2) * 2 + 1 + start))
|
||||||
|
tput setaf $color; tput bold # Switch colors
|
||||||
|
tput cup $li $co
|
||||||
|
echo o
|
||||||
|
line[$k$i]=$li
|
||||||
|
column[$k$i]=$co
|
||||||
|
color=$(((color+1)%8))
|
||||||
|
# Flashing text
|
||||||
|
sh=-1
|
||||||
|
for l in H A C K I N G
|
||||||
|
do
|
||||||
|
tput cup $((lin+1)) $((c+sh))
|
||||||
|
echo $l
|
||||||
|
let sh++
|
||||||
|
sleep 0.01
|
||||||
|
done
|
||||||
|
}
|
||||||
|
k=$((k % 2 + 1))
|
||||||
|
done
|
||||||
|
reset
|
|
@ -1,3 +1,52 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
notify-send "$(date '+%T')" "$(date '+%A %d %B %Y')"
|
function round() {
|
||||||
|
echo $(printf %.$2f $(echo "scale=$2;(((10^$2)*$1)+0.5)/(10^$2)" | bc))
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawBar(){
|
||||||
|
local percent=$1;
|
||||||
|
|
||||||
|
for i in {1..10}; do
|
||||||
|
local boxPercent=$(($i*10))
|
||||||
|
if [ "$boxPercent" -lt "$percent" ]; then
|
||||||
|
echo -n "■"
|
||||||
|
elif [ "$boxPercent" -eq "$percent" ]; then
|
||||||
|
echo -n "■"
|
||||||
|
elif [ "$(($boxPercent-10))" -lt "$percent" ]; then
|
||||||
|
echo -n "▣"
|
||||||
|
else
|
||||||
|
echo -n "□"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTimer(){
|
||||||
|
if [ -e "$HOME/timer" ]; then
|
||||||
|
local humanDuration=$(head -n 1 "$HOME/timer")
|
||||||
|
# All these dates are in seconds since the epoch
|
||||||
|
local duration=$(( $(date -d "now + $humanDuration" '+%s') - $(date '+%s') ))
|
||||||
|
local startTime=$(stat --format="%Y" "$HOME/timer")
|
||||||
|
local endTime=$(( $startTime + $duration ))
|
||||||
|
local currentTime=$(date '+%s')
|
||||||
|
|
||||||
|
if [ $endTime -gt $currentTime ]; then
|
||||||
|
|
||||||
|
local percentage=$(echo " ( ( $currentTime - $startTime ) * 100 ) / ( $endTime - $startTime ) " | bc )
|
||||||
|
|
||||||
|
echo -n "$percentage% "
|
||||||
|
echo $(drawBar $percentage)
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
time=$(date '+%T')
|
||||||
|
date=$(date '+%A %d %B %Y')
|
||||||
|
timer="$(getTimer)"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
notify-send "$time" "$date\n$timer$1"
|
||||||
|
|
32
bin/.bin/printfunction
Executable file
32
bin/.bin/printfunction
Executable file
|
@ -0,0 +1,32 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
import pyclbr
|
||||||
|
import sys
|
||||||
|
import operator
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
modname = sys.argv[2]
|
||||||
|
methname = sys.argv[1]
|
||||||
|
|
||||||
|
mod = pyclbr.readmodule(modname)
|
||||||
|
for clsname, cls in mod.items():
|
||||||
|
if methname in cls.methods:
|
||||||
|
print("Method: {} in Class: {}".format(methname, clsname))
|
||||||
|
methods = sorted(cls.methods.items(), key=operator.itemgetter(1))
|
||||||
|
clsfile = open(cls.file, 'r')
|
||||||
|
break
|
||||||
|
|
||||||
|
for pair in methods:
|
||||||
|
name, lineno = pair
|
||||||
|
if name == methname:
|
||||||
|
startline = lineno
|
||||||
|
if methods.index(pair) == methods.index(methods[-1]):
|
||||||
|
endline = None
|
||||||
|
else:
|
||||||
|
endline = methods[methods.index(pair) + 1][1]
|
||||||
|
break
|
||||||
|
|
||||||
|
src = clsfile.readlines()[startline-1:endline-1 if endline is not None else -1]
|
||||||
|
for srcline in src:
|
||||||
|
print(srcline, end='')
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
function print_help(){
|
function print_help(){
|
||||||
echo -e "hosts\t\tManages hosts in the yaml file"
|
echo -e "hosts\t\tManages hosts in the yaml file"
|
||||||
|
echo -e "\tlist\tLists hosts in the project"
|
||||||
|
echo -e "\thosts_file\tUpdates the hosts file to reflect the hosts on this project"
|
||||||
|
echo -e "\tip\tUses fzf to select an IP from the project"
|
||||||
|
echo -e "\tadd\tAdd an IP address"
|
||||||
}
|
}
|
||||||
|
|
||||||
function listhosts(){
|
function listhosts(){
|
||||||
|
@ -12,7 +16,11 @@ function listhosts(){
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [ $(yq -r '.hosts | length ' "$index" ) -gt 0 ]; then
|
if [ $(yq -r '.hosts | length ' "$index" ) -gt 0 ]; then
|
||||||
yq -r '.hosts[] | [.name, .ip, .domain, .description] | join(",")' "$index"
|
yq -r '.hosts[] | [
|
||||||
|
.ip,
|
||||||
|
(if ( .domain | type == "array") then .domain | join(",") else .domain end),
|
||||||
|
.description
|
||||||
|
] | join(",")' "$index"
|
||||||
else
|
else
|
||||||
echo "No hosts in index file"
|
echo "No hosts in index file"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -27,7 +35,10 @@ function get_hosts(){
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
if [ $(yq -r '.hosts | length ' "$index" ) -gt 0 ]; then
|
if [ $(yq -r '.hosts | length ' "$index" ) -gt 0 ]; then
|
||||||
yq -r '.hosts[]| select(.domain) | [.ip, .domain ] | join(",,")' "$index" | tr ',' '\t'
|
yq -r '.hosts[]| select(.domain) | [
|
||||||
|
.ip,
|
||||||
|
(if ( .domain | type == "array") then .domain | join(",") else .domain end)
|
||||||
|
] | join(",,")' "$index" | tr ',' '\t'
|
||||||
else
|
else
|
||||||
echo ""
|
echo ""
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -35,7 +46,6 @@ function get_hosts(){
|
||||||
}
|
}
|
||||||
|
|
||||||
function host_file(){
|
function host_file(){
|
||||||
|
|
||||||
sed '/# Project specific hosts/,$ d' /etc/hosts > /tmp/newhosts
|
sed '/# Project specific hosts/,$ d' /etc/hosts > /tmp/newhosts
|
||||||
cat /tmp/newhosts > /etc/hosts
|
cat /tmp/newhosts > /etc/hosts
|
||||||
rm /tmp/newhosts
|
rm /tmp/newhosts
|
||||||
|
@ -54,20 +64,20 @@ function getip(){
|
||||||
index="$current/index.yaml"
|
index="$current/index.yaml"
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--fzf)
|
--fzf)
|
||||||
ip=$( listhosts | fzf --no-preview | cut -d',' -f2)
|
ip=$( listhosts | fzf --no-preview | cut -d',' -f1)
|
||||||
;;
|
;;
|
||||||
--dmenu)
|
--dmenu)
|
||||||
ip=$( listhosts | dmenu | cut -d',' -f2)
|
ip=$( listhosts | dmenu | cut -d',' -f1)
|
||||||
echo "$ip" | xclip -selection primary
|
echo "$ip" | xclip -selection primary
|
||||||
echo "$ip" | xclip -selection clipboard
|
echo "$ip" | xclip -selection clipboard
|
||||||
;;
|
;;
|
||||||
--rofi)
|
--rofi)
|
||||||
ip=$( listhosts | rofi -dmenu | cut -d',' -f2)
|
ip=$( listhosts | rofi -dmenu | cut -d',' -f1)
|
||||||
echo "$ip" | xclip -selection primary
|
echo "$ip" | xclip -selection primary
|
||||||
echo "$ip" | xclip -selection clipboard
|
echo "$ip" | xclip -selection clipboard
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
ip=$( listhosts | fzf --no-preview | cut -d',' -f2)
|
ip=$( listhosts | fzf --no-preview | cut -d',' -f1)
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
echo $ip
|
echo $ip
|
||||||
|
@ -76,8 +86,6 @@ function getip(){
|
||||||
function addip(){
|
function addip(){
|
||||||
local current="$(project current --path)"
|
local current="$(project current --path)"
|
||||||
index="$current/index.yaml"
|
index="$current/index.yaml"
|
||||||
echo -n "Name: "
|
|
||||||
read name < /dev/tty
|
|
||||||
echo -n "Domain: "
|
echo -n "Domain: "
|
||||||
read domain < /dev/tty
|
read domain < /dev/tty
|
||||||
echo -n "IP: "
|
echo -n "IP: "
|
||||||
|
@ -85,9 +93,6 @@ function addip(){
|
||||||
echo -n "Description: "
|
echo -n "Description: "
|
||||||
read description < /dev/tty
|
read description < /dev/tty
|
||||||
local host='{}'
|
local host='{}'
|
||||||
if [ -n "$name" ]; then
|
|
||||||
host="$(echo $host | jq ".name=\"$name\"" )"
|
|
||||||
fi
|
|
||||||
if [ -n "$domain" ]; then
|
if [ -n "$domain" ]; then
|
||||||
host="$(echo $host | jq ".domain=\"$domain\"" )"
|
host="$(echo $host | jq ".domain=\"$domain\"" )"
|
||||||
fi
|
fi
|
||||||
|
|
2
bin/.bin/screenlayouts/docked-laptop-left.sh
Executable file
2
bin/.bin/screenlayouts/docked-laptop-left.sh
Executable file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/sh
|
||||||
|
xrandr --output eDP-1 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output DP-1 --off --output HDMI-1 --off --output DP-2 --off --output HDMI-2 --mode 1920x1080 --pos 1920x0 --rotate normal
|
24
bin/.bin/settimer
Executable file
24
bin/.bin/settimer
Executable file
|
@ -0,0 +1,24 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
echo "$@" > "$HOME/timer"
|
||||||
|
|
||||||
|
|
||||||
|
humanDuration=$(head -n 1 "$HOME/timer")
|
||||||
|
# All these dates are in seconds since the epoch
|
||||||
|
duration=$(( $(date -d "now + $humanDuration" '+%s') - $(date '+%s') ))
|
||||||
|
|
||||||
|
# Display date time notification when half way
|
||||||
|
( sleep $(( duration / 2 ))
|
||||||
|
datetime
|
||||||
|
) & disown
|
||||||
|
|
||||||
|
# Display date time notification when 90% done
|
||||||
|
( sleep $(( (duration * 9) / 10 ))
|
||||||
|
datetime
|
||||||
|
) & disown
|
||||||
|
|
||||||
|
# Display date time notification when half way
|
||||||
|
( sleep $duration
|
||||||
|
datetime "Finished"
|
||||||
|
) & disown
|
||||||
|
|
9
bin/.bin/webtest/webtest
Executable file
9
bin/.bin/webtest/webtest
Executable file
|
@ -0,0 +1,9 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
domain="$1"
|
||||||
|
|
||||||
|
if [ -z "$domain" ];
|
||||||
|
echo "You need to give a domain or ip address"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if
|
|
@ -10,4 +10,5 @@ else
|
||||||
json=$(curl https://xkcd.com/$comic/info.0.json 2> /dev/null)
|
json=$(curl https://xkcd.com/$comic/info.0.json 2> /dev/null)
|
||||||
fi
|
fi
|
||||||
echo $json | /usr/bin/jq -C
|
echo $json | /usr/bin/jq -C
|
||||||
echo $json | /usr/bin/jq ".img" | xargs sxiv
|
echo $json | /usr/bin/jq ".img" | xargs curl -s -o /tmp/xkcd
|
||||||
|
sxiv /tmp/xkcd
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue