reorganize directory structure again

This commit is contained in:
David Todd
2021-01-12 18:33:49 -06:00
parent 74ba4615d1
commit 158ccfcea0
63 changed files with 32 additions and 30 deletions

16
home/bin/build-i3-config Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
DF_PATH=${HOME}/dotfiles/.config/i3
CONFIG_PATH=${DF_PATH}/conf.d
DST_FILE=${DF_PATH}/config
echo "# This file is generated with the \`build-i3-config\` command" > ${DST_FILE}
echo "# Configuration has been broken up into the \`conf.d\` directory" >> ${DST_FILE}
cat ${CONFIG_PATH}/base.conf >> ${DST_FILE}
cat ${CONFIG_PATH}/gaps.conf >> ${DST_FILE}
cat ${CONFIG_PATH}/workspace.conf >> ${DST_FILE}
cat ${CONFIG_PATH}/i3bar.conf >> ${DST_FILE}
cat ${CONFIG_PATH}/window-classes.conf >> ${DST_FILE}
cat ${CONFIG_PATH}/layout-keybinds.conf >> ${DST_FILE}
cat ${CONFIG_PATH}/keybinds.conf >> ${DST_FILE}
cat ${CONFIG_PATH}/autostart.conf >> ${DST_FILE}

15
home/bin/cert_expiry Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
# Prints the expiration dates of all TLS Certificates in a directory
# This is usually pem, but can also be crt
if [[ -z $1 ]]; then
echo "certificate type not set, defaulting to pem"
filetype="pem"
else
filetype=$1
fi
for filename in ./*.${filetype}; do
echo -n "${filename} expires on: "
openssl x509 -noout -dates -in "${filename}" | sed -n '/notAfter/p' | sed 's/^.\{9\}//'
done

151
home/bin/git-freeze Executable file
View File

@@ -0,0 +1,151 @@
#!/bin/sh
#
# Copyright (c) 2011 Scott Moynes
#
# 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 copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
OPTIONS_SPEC="\
git freeze -l [-r] [<remote-name>]
git freeze -t <frozen-name>
git freeze -p [-d] [<remote-name>] <frozen-name>
git freeze -f [<remote-name>] <branch-name>
Archive refs to freezer.
--
h show help
Global options
r,remote operate on remotes
d,delete delete frozen branch from remotes
Command options
l,list list frozen refs
t,thaw thaw frozen ref into a branch
p,push push frozen ref to remote
f,fetch fetch frozen ref from remote
"""
SUBDIRECTORY_OK=1
. "$(git --exec-path)/git-sh-setup"
for arg; do
case "$arg" in
# Global options
-r) REMOTE_OPT=1 ; shift ;;
-a) ALL_OPT=1 ; shift ;;
-d) DELETE_OPT=1; shift ;;
# Command options
-l) LIST_COMMAND=1 ; shift ;;
-t) THAW_COMMAND=1 ; shift ;;
-p) PUSH_COMMAND=1 ; shift ;;
-f) FETCH_COMMAND=1 ; shift ;;
--) shift; break ;;
esac
done
list() {
if [ -z "$REMOTE_OPT" ]; then
git show-ref --abbrev=8 | \
sane_grep 'refs/freezer/' | \
LANG=C LC_ALL=C sed -e 's|\([0-9a-f]*\) refs/freezer/\(.*\)|\2 (\1)|'
else
git ls-remote | sane_grep 'refs/freezer/' | \
LANG=C LC_ALL=C sed -e 's|\([0-9a-f]\{8\}\).*refs/freezer/\(.*\)|\2 (\1)|'
fi
}
thaw() {
BRANCH="$1"
if [ -z "$BRANCH" ]; then
die "Frozen branch name argument required"
fi
FREEZER_REF=$(git show-ref --hash refs/freezer/$BRANCH)
echo Thawing branch: $BRANCH
git update-ref refs/heads/$BRANCH $FREEZER_REF || \
die "Error: unable to thaw ref refs/heads/$BRANCH $FREEZER_REF"
git update-ref -d refs/freezer/$BRANCH $FREEZER_REF
}
push() {
if [ -z "$2" ]; then
REMOTE=origin
BRANCH=$1
else
REMOTE=$1
BRANCH=$2
fi
if [ -z "$BRANCH" ]; then
die "Frozen branch name argument required"
fi
if [ -z "$DELETE_OPT" ]; then
git push "$REMOTE" "refs/freezer/$BRANCH:refs/freezer/$BRANCH"
else
git push "$REMOTE" ":refs/freezer/$BRANCH"
fi
}
freeze() {
BRANCH="$1"
if [ -z "$BRANCH" ]; then
die "Branch name argument is required"
fi
BRANCH_REF=$(git show-ref --hash --heads "$BRANCH")
if [ $? -ne 0 ]; then
die "Branch does not exist: $BRANCH"
fi
echo Freezing branch: $BRANCH
git update-ref refs/freezer/$BRANCH $BRANCH_REF || \
die "Error: unable to update ref refs/freezer/$BRANCH $BRANCH_REF"
git branch -D $BRANCH 2>&1 > /dev/null || die "Unable to delete branch $BRANCH"
}
fetch() {
if [ -z "$2" ]; then
REMOTE=origin
BRANCH=$1
else
REMOTE=$1
BRANCH=$2
fi
: ${BRANCH:="*"} ${REMOTE:=origin}
echo Fetching frozen branches
git fetch $REMOTE "refs/freezer/${BRANCH}:refs/freezer/${BRANCH}"
}
if [ $LIST_COMMAND ]; then
list
elif [ $THAW_COMMAND ]; then
thaw "$1"
elif [ $PUSH_COMMAND ]; then
push "$1" "$2"
elif [ $FETCH_COMMAND ]; then
fetch "$1" "$2"
else
freeze "$1"
fi

104
home/bin/i3blocks/bandwidth Executable file
View File

@@ -0,0 +1,104 @@
#!/usr/bin/env bash
#
# Copyright (C) 2015 James Murphy
# Licensed under the terms of the GNU GPL v2 only.
#
# i3blocks blocklet script to monitor bandwidth usage
iface="${BLOCK_INSTANCE}"
iface="${IFACE:-$iface}"
dt="${DT:-3}"
unit="${UNIT:-Mb}"
LABEL="${LABEL:- }" # down arrow up arrow
printf_command="${PRINTF_COMMAND:-"printf \"${LABEL}%-5.1f/%5.1f %s/s\\n\", rx, wx, unit;"}"
function default_interface {
ip route | awk '/^default via/ {print $5; exit}'
}
function check_proc_net_dev {
if [ ! -f "/proc/net/dev" ]; then
echo "/proc/net/dev not found"
exit 1
fi
}
function list_interfaces {
check_proc_net_dev
echo "Interfaces in /proc/net/dev:"
grep -o "^[^:]\\+:" /proc/net/dev | tr -d " :"
}
while getopts i:t:u:p:lh opt; do
case "$opt" in
i) iface="$OPTARG" ;;
t) dt="$OPTARG" ;;
u) unit="$OPTARG" ;;
p) printf_command="$OPTARG" ;;
l) list_interfaces && exit 0 ;;
h) printf \
"Usage: bandwidth3 [-i interface] [-t time] [-u unit] [-p printf_command] [-l] [-h]
Options:
-i\tNetwork interface to measure. Default determined using \`ip route\`.
-t\tTime interval in seconds between measurements. Default: 3
-u\tUnits to measure bytes in. Default: Mb
\tAllowed units: Kb, KB, Mb, MB, Gb, GB, Tb, TB
\tUnits may have optional it/its/yte/ytes on the end, e.g. Mbits, KByte
-p\tAwk command to be called after a measurement is made.
\tDefault: printf \"<span font='FontAwesome'> </span>%%-5.1f/%%5.1f %%s/s\\\\n\", rx, wx, unit;
\tExposed variables: rx, wx, tx, unit, iface
-l\tList available interfaces in /proc/net/dev
-h\tShow this help text
" && exit 0;;
esac
done
check_proc_net_dev
iface="${iface:-$(default_interface)}"
while [ -z "$iface" ]; do
echo No default interface
sleep "$dt"
iface=$(default_interface)
done
case "$unit" in
Kb|Kbit|Kbits) bytes_per_unit=$((1024 / 8));;
KB|KByte|KBytes) bytes_per_unit=$((1024));;
Mb|Mbit|Mbits) bytes_per_unit=$((1024 * 1024 / 8));;
MB|MByte|MBytes) bytes_per_unit=$((1024 * 1024));;
Gb|Gbit|Gbits) bytes_per_unit=$((1024 * 1024 * 1024 / 8));;
GB|GByte|GBytes) bytes_per_unit=$((1024 * 1024 * 1024));;
Tb|Tbit|Tbits) bytes_per_unit=$((1024 * 1024 * 1024 * 1024 / 8));;
TB|TByte|TBytes) bytes_per_unit=$((1024 * 1024 * 1024 * 1024));;
*) echo Bad unit "$unit" && exit 1;;
esac
scalar=$((bytes_per_unit * dt))
init_line=$(cat /proc/net/dev | grep "^[ ]*$iface:")
if [ -z "$init_line" ]; then
echo Interface not found in /proc/net/dev: "$iface"
exit 1
fi
init_received=$(awk '{print $2}' <<< $init_line)
init_sent=$(awk '{print $10}' <<< $init_line)
(while true; do cat /proc/net/dev; sleep "$dt"; done) |\
stdbuf -oL grep "^[ ]*$iface:" |\
awk -v scalar="$scalar" -v unit="$unit" -v iface="$iface" '
BEGIN{old_received='"$init_received"';old_sent='"$init_sent"'}
{
received=$2
sent=$10
rx=(received-old_received)/scalar;
wx=(sent-old_sent)/scalar;
tx=rx+wr;
old_received=received;
old_sent=sent;
if(rx >= 0 && wx >= 0){
'"$printf_command"';
fflush(stdout);
}
}
'

11
home/bin/i3blocks/clock Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/sh
date '+%b %d (%a) %I:%M%p'
case $BLOCK_BUTTON in
1) pgrep -x dunst >/dev/null && notify-send "$(cal --color=always | sed "s/..7m/<b><span color=\"red\">/;s/..27m/<\/span><\/b>/")" && notify-send "$(calcurse -d3)" ;;
2) "$TERMINAL" -e calcurse ;;
3) pgrep -x dunst >/dev/null && notify-send "<b>📅 Time/date module:</b>
- Left click to show upcoming appointments for the next three days via \`calcurse -d3\` and show the month via \`cal\`
- Middle click opens calcurse if installed" ;;
esac

12
home/bin/i3blocks/cpu Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/sh
case $BLOCK_BUTTON in
1) notify-send "<b>🖥 CPU hogs</b>:
$(ps axch -o cmd:15,%cpu --sort=-%cpu | head)" ;;
3) notify-send "<b>🖥 CPU module:</b>
- Shows CPU temperature.
- Click to show intensive processes.
- % is of single core." ;;
esac
sensors | awk '/temp1/ {print $2}'

BIN
home/bin/i3blocks/cpu_usage Executable file

Binary file not shown.

20
home/bin/i3blocks/disk Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/sh
# Status bar module for disk space
# $1 should be drive mountpoint
# $2 is optional icon, otherwise mountpoint will displayed
[ -z "$1" ] && exit
icon="$2"
[ -z "$2" ] && icon="$1"
case $BLOCK_BUTTON in
1) pgrep -x dunst >/dev/null && notify-send "<b>💽 Disk space:</b>
$(df -h --output=target,used,size)" ;;
3) pgrep -x dunst >/dev/null && notify-send "<b>💽 Hard drive space remaining:</b>
- Shows used hard drive space.
- Click to show all disk info." ;;
esac
printf "%s: %s" "$icon" "$(df -h "$1" | awk ' /[0-9]/ {print $3 "/" $2}')"

67
home/bin/i3blocks/gpu-load Executable file
View File

@@ -0,0 +1,67 @@
#! /usr/bin/perl
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
use strict;
use warnings;
use utf8;
use Getopt::Long;
# default values
my $t_warn = $ENV{T_WARN} || 70;
my $t_crit = $ENV{T_CRIT} || 90;
my $gpu_usage = -1;
my $gpu_mem = -1;
my $gpu_video = -1;
my $gpu_pcie = -1;
sub help {
print "Usage: gpu-load [-w <warning>] [-c <critical>]\n";
print "-w <percent>: warning threshold to become amber\n";
print "-c <percent>: critical threshold to become red\n";
exit 0;
}
GetOptions("help|h" => \&help,
"w=i" => \$t_warn,
"c=i" => \$t_crit);
# Get GPU usage from nvidia-settings
open (NVS, 'nvidia-settings -q GPUUtilization -t |') or die;
while (<NVS>) {
if (/^[a-zA-Z]*=(\d+), [a-zA-Z]*=(\d+), [a-zA-Z]*=(\d+), [a-zA-Z]*=(\d+)$/) {
$gpu_usage = $1;
$gpu_mem = $2;
$gpu_video = $3;
$gpu_pcie = $4;
last;
}
}
close(NVS);
$gpu_usage eq -1 and die 'Can\'t find GPU information';
# Print full_text, short_text
printf "%.0f%% %.0f%% %.0f%% %.0f%%\n", $gpu_usage, $gpu_mem, $gpu_video, $gpu_pcie;
printf "%.0f%%\n", $gpu_usage;
# Print color, if needed
if ($gpu_usage >= $t_crit || $gpu_mem >= $t_crit || $gpu_video >= $t_crit || $gpu_pcie >= $t_crit) {
print "#FF0000\n";
exit 33;
} elsif ($gpu_usage >= $t_warn || $gpu_mem >= $t_warn || $gpu_video >= $t_warn || $gpu_pcie >= $t_warn) {
print "#FFBF00\n";
}
exit 0;

9
home/bin/i3blocks/internet Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
if ping -c 1 1.1.1.1 > /dev/null 2>&1; then
echo "😛"
else
echo "🤬"
echo "$(date)" >> /tmp/internet-outages
nfty send "Internet Outage"
fi

34
home/bin/i3blocks/load_average Executable file
View File

@@ -0,0 +1,34 @@
#!/bin/sh
# Copyright (C) 2014 Julien Bonjean <julien@bonjean.info>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
load="$(cut -d ' ' -f1 /proc/loadavg)"
cpus="$(nproc)"
# full text
echo "$load"
# short text
echo "$load"
# color if load is too high
awk -v cpus=$cpus -v cpuload=$load '
BEGIN {
if (cpus <= cpuload) {
print "#FF0000";
exit 33;
}
}
'

11
home/bin/i3blocks/memory Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/sh
case $BLOCK_BUTTON in
1) notify-send "<b>🧠 Memory hogs:</b>
$(ps axch -o cmd:15,%mem --sort=-%mem | head)" ;;
3) notify-send "<b>🧠 Memory module:</b>
- Shows Memory Used/Total.
- Click to show memory hogs." ;;
esac
free -h | awk '/^Mem:/ {print $3 "/" $2}'

3
home/bin/i3blocks/scratchpad Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
~/bin/i3-dstatus scratchpad

35
home/bin/i3blocks/spotify Executable file
View File

@@ -0,0 +1,35 @@
#!/usr/bin/env python
# Created by: https://github.com/firatakandere/i3blocks-spotify
import dbus
import os
import sys
try:
bus = dbus.SessionBus()
spotify = bus.get_object("org.mpris.MediaPlayer2.spotify", "/org/mpris/MediaPlayer2")
if os.environ.get('BLOCK_BUTTON'):
control_iface = dbus.Interface(spotify, 'org.mpris.MediaPlayer2.Player')
if (os.environ['BLOCK_BUTTON'] == '1'):
control_iface.Previous()
elif (os.environ['BLOCK_BUTTON'] == '2'):
control_iface.PlayPause()
elif (os.environ['BLOCK_BUTTON'] == '3'):
control_iface.Next()
spotify_iface = dbus.Interface(spotify, 'org.freedesktop.DBus.Properties')
props = spotify_iface.Get('org.mpris.MediaPlayer2.Player', 'Metadata')
if (sys.version_info > (3, 0)):
print(str(props['xesam:artist'][0]) + " - " + str(props['xesam:title']))
else:
print(props['xesam:artist'][0] + " - " + props['xesam:title']).encode('utf-8')
exit
except dbus.exceptions.DBusException:
exit

8
home/bin/i3blocks/window Executable file
View File

@@ -0,0 +1,8 @@
#!/bin/bash
ACTIVE_WINDOW=$(xprop -id $(xprop -root _NET_ACTIVE_WINDOW | cut -d ' ' -f 5) WM_NAME | cut -d '"' -f 2)
if [[ "${ACTIVE_WINDOW}" != "" ]]; then
echo "${ACTIVE_WINDOW}"
echo ""
fi

7
home/bin/music_player Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
cd ~/Music || exit
selected_song=$(ls | rofi -i -dmenu -p "Select a song to play") || exit
notify-send "Playing ${selected_song}"
mplayer "${selected_song}"

18
home/bin/screenshotter.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
# Simple screenshot uploader
# The web server is nginx and configured with h5ai to be a file manager
# Copyright (c) 2019 David Todd (c0de) c0de@c0defox.es
DATE=$(date +%Y-%m-%d-%s).png
FILENAME=~/Pictures/$DATE
maim -s $FILENAME&
wait $!
notify-send "Uploading Screenshot"
scp $FILENAME web.foxnet.space:/var/www/c0de.link/pics&
wait $!
echo https://i.c0de.link/$DATE | xclip -selection clipboard
notify-send "Link copied to Clipboard"

27
home/bin/wallpaper.sh Executable file
View File

@@ -0,0 +1,27 @@
#!/bin/bash
shopt -s nullglob
#===change these config start===
#wallpapers directory path
path=~/Pictures/Wallpapers
#time interval
interval=5m
#===change these config end===
cd $path
while true; do
files=()
for i in *.jpg *.png; do
[[ -f $i ]] && files+=("$i")
done
range=${#files[@]}
((range)) && feh --bg-scale "${files[RANDOM % range]}"
sleep $interval
done