Merge kubuntu and ubuntu-i3 configs

This commit is contained in:
2021-12-20 16:49:21 -05:00
parent 4d7aa521dc
commit 574cc7802a
214 changed files with 12317 additions and 517 deletions

View File

@@ -0,0 +1,18 @@
# i3-blocks-contrib
A collection of useful blocks for [i3blocks](https://github.com/vivien/i3blocks), for the amazing [i3](https://i3wm.org) window manager.
## Configuration
Some examples on how to configure these in your `i3blocks` config file:
- @rosshadden's [i3blocks.conf](https://github.com/rosshadden/dotfiles/blob/master/src/.config/i3/i3blocks.conf)
- @oppenlander's [i3blocks.conf](https://github.com/oppenlander/dotfiles/blob/master/i3/i3blocks.conf)
## Contributing
As hinted by the name, this is intended to be openly contributed to by the community.
There is no official contributing guide, but please try to fit in to the style and themes found in our existing blocks.
We use a somewhat ad-hock [YUIDoc](http://yui.github.io/yuidoc/) documentation syntax.

View File

@@ -0,0 +1,35 @@
#!/bin/bash
################################
# Shows bandwidth
#
# @param {String(tx|rx)} type: The bandwidth type to check
# @return {Number(kB/s)}: Speed of the interface
################################
dir=$(dirname $0)
source $dir/util.sh
type=$BLOCK_INSTANCE
file=/tmp/i3blocks_bandwidth_$type
touch $file
prev=$(cat $file)
cur=0
netdir=/sys/class/net
for iface in $(ls -1 $netdir); do
# Skip the loopback interface
if [ "$iface" == "lo" ]; then continue; fi
f=$netdir/$iface/statistics/${type}_bytes
n=$(cat $f)
cur=$(expr $cur + $n)
done
delta=$(calc "$cur - $prev")
echo "$(calc "$delta / 1000") kB/s"
# store result
echo $cur > $file

View File

@@ -0,0 +1,42 @@
#!/usr/bin/env bash
################################
# Shows info about connected batteries.
#
# Dependencies:
# - acpi
#
# @return {Number(%)}: Current battery charge
################################
dir=$(dirname $0)
source $dir/util.sh
full=""
short=""
status=0
# Exit if no battery was found
if [ "$(acpi)" == "" ]; then exit 0; fi
state=$(acpi | sed -n 's/Battery [0-9]: \([A-Z]\).*, .*/\1/p')
chg=$(acpi | sed -n 's/Battery [0-9]:.*, \([0-9]\{1,3\}\)%.*/\1/p')
# Charging or Unknown
if [ $state = "C" ] || [ $state = "U" ]; then
icon=""
else
if [ $chg -le 10 ]; then
icon=""
status=33
else
icon=""
fi
fi
full="$icon $chg%"
short="$chg%"
echo $full
echo $short
exit $status

View File

@@ -0,0 +1,44 @@
#!/usr/bin/env bash
################################
# Shows AUR packages that need updated.
#
# Dependencies:
# - checkupdates
# - bauerbill
# - [notify-send]
#
# @return {Number}: Outdated packages
################################
dir=$(dirname "$0")
source $dir/util.sh
full=""
short=""
status=0
archPackages=$(checkupdates)
allPackages=$(bauerbill -Quq --aur)
numArchPackages=$(numLines "$archPackages")
numAllPackages=$(numLines "$allPackages")
numAurPackages=$(calc "$numAllPackages - $numArchPackages")
if [ "$numAllPackages" -le "$numArchPackages" ]; then
numAurPackages=$numAllPackages
fi
full=$numAurPackages
short=$full
case $BLOCK_BUTTON in
# right click: show packages
3)
aurPackages=$(diff -y <(echo "$archPackages") <(echo "$allPackages") | awk -p '{ print $3 }')
notify-send "AUR packages" "$aurPackages"
;;
esac
echo $full
echo $short
exit $status

View File

@@ -0,0 +1,26 @@
#!/usr/bin/env bash
################################
# Shows current brightness
#
# dependencies:
# - xbacklight
#
# @return {Number}: Current brightness
################################
case $BLOCK_BUTTON in
# right click
# set to `20
3) xbacklight -set 20 ;;
# scroll up
# raise brightness
4) xbacklight -inc 10 ;;
# scroll down
# lower brightness
5) xbacklight -dec 10 ;;
esac
printf "%.0f" "$(xbacklight -get)"

View File

@@ -0,0 +1,47 @@
#!/usr/bin/env bash
################################
# Shows info about the CPU
#
# Dependencies:
# - [notify-send]
#
# @return {Number(%)}: CPU usage
################################
dir=$(dirname $0)
source $dir/util.sh
full=""
short=""
status=0
read cpu a b c previdle rest < /proc/stat
prevtotal=$(calc "$a + $b + $c + $previdle")
sleep 0.5
read cpu a b c idle rest < /proc/stat
total=$(calc "$a + $b + $c + $idle")
CPU=$(calc "100 * (($total - $prevtotal) - ($idle - $previdle)) / ($total - $prevtotal)")
full="$CPU%"
short=$full
if [ $CPU -ge 90 ]; then
status=33
fi
case $BLOCK_BUTTON in
# right click: show packages
3)
n=16
summary=$(ps -eo pcpu,pmem,pid,comm --sort=-pcpu | head -$n)
notify-send "Top $n CPU-eaters" "$summary"
;;
esac
echo $full
echo $short
exit $status

View File

@@ -0,0 +1,13 @@
#!/usr/bin/env bash
################################
# Shows current date
#
# @param {String} format: The format of the date
# @return {Date}: Current date
################################
format=${BLOCK_INSTANCE:-"%Y-%m-%d"}
date +"$format"
date +"%m-%d"

View File

@@ -0,0 +1,68 @@
#!/usr/bin/env bash
################################
# Shows info about a specified mount point
#
# Dependencies:
# - [notify-send]
#
# @param {String} disk: The mount point to check
# @return {Number(%)}: Space used on the disk
################################
dir=$(dirname $0)
source $dir/util.sh
full=""
short=""
status=0
disks=$(lsblk | tail -n +2 | awk '{ print $7 }' | sed '/^\s*$/d' | sort)
let numDisks=$(echo "$disks" | wc -l)
let diskNum=$(getCache 1)
getDisk() {
echo "$disks" | sed -n "$diskNum p"
}
disk=$(getDisk)
case $BLOCK_BUTTON in
# right click: show details
# TODO: fix
3)
local summary=$(du -h --max-depth=1 $disk)
notify-send "Disk usage" "$summary"
;;
# scroll up: cycle disks
4)
diskNum=$[$(getCache) - 1]
if (( diskNum <= 0 )); then
diskNum=$numDisks
fi
setCache $diskNum
disk=$(getDisk)
;;
5)
# scroll down: cycle disks
diskNum=$[$(getCache) + 1]
if (( diskNum >= numDisks + 1 )); then
diskNum=1
fi
setCache $diskNum
disk=$(getDisk)
;;
esac
usage=$(df -h $disk | sed -n '2 p')
usage=($usage)
if [ ${usage[4]%?} -ge 90 ]; then
status=33
fi
full="$disk ${usage[4]}"
short="$full"
echo $full
echo $short
exit $status

View File

@@ -0,0 +1,31 @@
#!/usr/bin/env bash
################################
# Shows current keyboard layout.
# Allows layout toggling.
#
# Dependencies:
# - [Ross' key script](https://github.com/rosshadden/dotfiles/blob/master/src/lib/keys.sh)
#
# @return {String}: Current keyboard layout
################################
keys=$HOME/bin/keys
full=""
short=""
status=0
case $BLOCK_BUTTON in
# right click: toggle key variant
3) $keys toggle ;;
esac
layout=$($keys get)
full=$layout
short=${layout:0:1}
echo $full
echo $short
exit $status

View File

@@ -0,0 +1,46 @@
#!/usr/bin/env bash
################################
# Shows info about the RAM
#
# Dependencies:
# - [notify-send]
#
# @return {Number(%)}: RAM usage
################################
dir=$(dirname $0)
source $dir/util.sh
full=""
short=""
status=0
exec 6< /proc/meminfo
read a total b <&6
read a free b <&6
read a b c <&6
read a buffer b <&6
read a cached b <&6
MEM=$(calc "100 * ($total - ($free + $buffer + $cached)) / $total")
full="$MEM%"
short=$full
if [ $MEM -ge 80 ]; then
status=33
fi
case $BLOCK_BUTTON in
# right click: show packages
3)
n=16
summary=$(ps -eo pmem,pcpu,pid,comm --sort=-pmem | head -$n)
notify-send "Top $n RAM-eaters" "$summary"
;;
esac
echo $full
echo $short
exit $status

View File

@@ -0,0 +1,38 @@
#!/usr/bin/env bash
################################
# Shows info from media players.
#
# Dependencies:
# - mpc
#
# @return {String}: Current media info
################################
full=""
short=""
status=0
format=${BLOCK_INSTANCE:-'[[%artist% - ]%title%[ \[%album%\]]]|[%file%]'}
current=$(mpc current)
currentLong=$(mpc current -f "$format")
state=playing
if [[ "$current" ]]; then
# Make icon mapping
declare -A icons
icons["playing"]=""
icons["paused"]=""
icons["stopped"]=""
# Determine which icon to use
icon=${icons[$state]}
full="$currentLong $icon"
short="$current $icon"
fi
echo "$full"
echo "$short"
exit "$status"

View File

@@ -0,0 +1,36 @@
#!/usr/bin/env bash
################################
# Shows IP address of a given interface
#
# @param {String} interface: The network interface to check
# @return {String(IP)}: IP address of the interface
################################
dir=$(dirname $0)
source "$dir/util.sh"
full=""
short=""
status=0
interface=${BLOCK_INSTANCE:-eth0}
netPath=/sys/class/net
interfacePath=$(echo $netPath/$interface)
# Expand wildcard interfaces
interface=${interfacePath#$netPath/}
state=$(cat $interfacePath/operstate)
if [ $state == "up" ]; then
ips=$(ip addr show $interface | perl -n -e'/inet (.+)\// && print $1')
ip=${ips:-0.0.0.0}
full=$ip
short=$full
fi
echo "$full"
echo "$short"
exit $status

View File

@@ -0,0 +1,34 @@
#!/usr/bin/env bash
################################
# Shows pacman packages that need updated.
#
# dependencies:
# - checkupdates
# - [notify-send]
#
# @return {Number}: Outdated packages
################################
dir=$(dirname "$0")
source $dir/util.sh
full=""
short=""
status=0
packages=$(checkupdates)
numPackages=$(numLines "$packages")
full=$numPackages
short=$full
echo "$full"
echo "$short"
case $BLOCK_BUTTON in
# right click: show packages
3) notify-send "Pacman packages" "$packages" ;;
esac
exit $status

View File

@@ -0,0 +1,50 @@
#!/usr/bin/env bash
################################
# Shows info from media players.
#
# TODO: make output format configurable
#
# Dependencies:
# - playerctl
#
# @return {String}: Current media info
################################
dir=$(dirname $0)
source $dir/util.sh
full=""
short=""
status=0
# Exit if no player found
players=$(playerctl -l)
if [[ ! $players ]]; then exit 0; fi
artist=$(playerctl metadata artist)
title=$(playerctl metadata title)
album=$(playerctl metadata album)
state=$(playerctl status)
if [[ "$title" ]]; then
# Make icon mapping
declare -A icons
icons["Playing"]=""
icons["Paused"]=""
icons["Stopped"]=""
# Determine which icon to use
icon=${icons[$state]}
full="$title"
if [[ "$artist" ]]; then full="$artist - $full"; fi
short="$full $icon"
if [[ "$album" ]]; then full="$full [$album]"; fi
full="$full $icon"
fi
echo $full
echo $short
exit $status

View File

@@ -0,0 +1,71 @@
#!/usr/bin/env bash
################################
# Shows info about sound/volume.
# Allows simple volume controls.
#
# Thanks to [@EliteTK](https://gist.github.com/EliteTK/36d061fa24372fb70312),
# for the big speed gain when switching to `ponymix`
#
# Dependencies:
# - ponymix
# - ttf-font-icons
#
# @return {Number}: Current volume
################################
dir=$(dirname $0)
source $dir/util.sh
full=""
short=""
status=0
step=${BLOCK_INSTANCE:-5}
getVolume() {
ponymix get-volume
}
isMuted() {
ponymix is-muted
}
case $BLOCK_BUTTON in
# right click
# mute/unmute
3) ponymix toggle >/dev/null ;;
# scroll up
# raise volume
4) ponymix increase $step >/dev/null ;;
# scroll down
# lower volume
5) ponymix decrease $step >/dev/null ;;
esac
vol=$(getVolume)
# level-based icon
if (( $vol == 0 )); then
icon=""
elif (( $vol < 34 )); then
icon=""
elif (( $vol < 67 )); then
icon=""
else
icon=""
fi
# determine mute status
if isMuted; then
status=33
fi
full="$icon $vol%"
short=$vol
echo $full
echo $short
exit $status

View File

@@ -0,0 +1,13 @@
#!/usr/bin/env bash
################################
# Shows current time
#
# @param {String} format: The format of the time
# @return {Time}: Current time
################################
format=${BLOCK_INSTANCE:-"%H:%M:%S"}
date +"$format"
date +"%H:%M"

View File

@@ -0,0 +1,41 @@
################################
# Calculates a given expression
#
# Dependencies:
# - bc
#
# @param {String} 1: The expression to calculate
# @return {Number}: The result of the expression
################################
calc() {
echo "$1" | bc
}
################################
# Counts lines in text, accounting for empty values
#
# @param {String} 1: The input text
# @return {Number}: The number of lines
################################
numLines() {
if [[ "$1" == "" ]]; then
echo 0
else
echo "$1" | wc -l
fi
}
cacheDir=".cache"
cacheFile="$cacheDir/i3-blocks-contrib-${BLOCK_NAME}"
if [[ -z $cacheDir ]]; then
mkdir $cacheDir
fi
getCache() {
cat $cacheFile || echo $1
}
setCache() {
echo "$1" > $cacheFile
}

View File

@@ -0,0 +1,49 @@
#!/usr/bin/env bash
################################
# Shows info about the weather (in Cincinnati) from accuweather.com
#
# TODO: completely rewrite, probably using openweather APIs
# TODO: make location configurable
# TODO: make temperature unit configurable
#
# @return {Number(degrees Fahrenheit)}: Current temperature in Cincinnati
################################
dir=$(dirname $0)
source $dir/util.sh
full=""
short=""
status=0
URL='http://www.accuweather.com/en/us/cincinnati-oh/45212/weather-forecast/350126'
SITE="$(curl -s "$URL")"
weather="$(echo "$SITE" | awk -F\' '/acm_RecentLocationsCarousel\.push/{print $13 }'| head -1)"
temp="$(echo "$SITE" | awk -F\' '/acm_RecentLocationsCarousel\.push/{print $10 }'| head -1)"
if [[ $weather == *thunder* || $weather == *Thunder* ]]; then
icon=""
else
if [[ $weather == *rain* || $weather == *Rain* ]]; then
icon=""
else
if [[ $weather == *snow* || $weather == *Snow* ]]; then
icon="❄"
else
if [[ $weather == *cloud* || $weather == *Cloud* ]]; then
icon=""
else
icon=""
fi
fi
fi
fi
full="$icon $temp°"
short="$temp°"
echo $full
echo $short
exit $status

View File

@@ -0,0 +1,44 @@
#!/usr/bin/env bash
################################
# Shows AUR packages that need updated.
#
# Dependencies:
# - checkupdates
# - yaourt
# - [notify-send]
#
# @return {Number}: Outdated packages
################################
dir=$(dirname $0)
source $dir/util.sh
full=""
short=""
status=0
archPackages=$(checkupdates)
allPackages=$(yaourt -Quaq)
numArchPackages=$(numLines "$archPackages")
numAllPackages=$(numLines "$allPackages")
numAurPackages=$(calc "$numAllPackages - $numArchPackages")
if [ $numAllPackages -le $numArchPackages ]; then
numAurPackages=$numAllPackages
fi
full=$numAurPackages
short=$full
case $BLOCK_BUTTON in
# right click: show packages
3)
aurPackages=$(diff -y <(echo "$archPackages") <(echo "$allPackages") | awk -p '{ print $3 }')
notify-send "AUR packages" "$aurPackages"
;;
esac
echo $full
echo $short
exit $status

21
.local/bin/i3scripts/cpusensor Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
## Author: Shaun Reed | Contact: shaunrd0@gmail.com | URL: www.shaunreed.com ##
## ##
## A script to find and return the CPU package temp sensor ##
###############################################################################
# bash.sh
for i in /sys/class/hwmon/hwmon*/temp*_input; do
sensors+=("$(<$(dirname $i)/name): $(cat ${i%_*}_label 2>/dev/null || echo $(basename ${i%_*})) $(readlink -f $i)");
done
for i in "${sensors[@]}"
do
if [[ $i =~ ^coretemp:.Package.* ]]
then
export CPU_SENSOR=${i#*0}
fi
done
echo "scale=2;((9/5) * $(cat $CPU_SENSOR)/1000) + 32"|bc

86
.local/bin/i3scripts/i3empty.py Executable file
View File

@@ -0,0 +1,86 @@
#!/bin/env python3
import sys
import re
import json
from subprocess import run, PIPE
import argparse
def get_ws():
return json.loads(run('i3-msg -t get_workspaces'.split(), stdout=PIPE).stdout)
def to_empty(current=None, strict=False, right=True, move=False, wrap=True, min_num=1):
"""Move to nearest empty numbered workspace"""
if current is None:
current = [w for w in get_ws() if w['focused']][0]
numbered = re.compile('^\d+$' if strict else '^\d+|(\d+:.*)$')
ns = {w['num'] for w in get_ws() if numbered.match(w['name']) != None and
(not strict or w['name'] == str(w['num']))}
if numbered.match(current['name']) is None:
# If current workspace is unnumbered, pick rightmost or leftmost
if len(ns) == 0:
new_ix = min_num
else:
new_ix = min(ns) - 1 if right else max(ns) + 1
else:
# Find numbered workspace nearest to current
new_ix = current['num']
while new_ix in ns:
new_ix += 1 if right else -1
# Wrap around
if new_ix < min_num:
if wrap:
new_ix = max(ns) + 1
else:
return
if move:
s = 'i3-msg move container to workspace {0}; workspace {0}'.format(new_ix)
else:
s = 'i3-msg workspace ' + str(new_ix)
print(s)
run(s.split())
def to_empty_near(num, relative=False, **kwargs):
"""Move to empty numbered workspace nearest to workspace 'num'"""
if relative:
if 0 <= num < len(get_ws()):
current = get_ws()[num]
else:
return
else:
ns = [w for w in get_ws() if w['num'] == num]
current = ns[0] if len(ns) > 0 else {'num': num, 'name': str(num)}
to_empty(current, **kwargs)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Switch to an empty numbered workspace.')
parser.add_argument('direction', type=str, nargs='?', default='next',
help='either next (default) or prev')
parser.add_argument('number', type=int, nargs='?',
help='workspace to start searching from (default: current)')
parser.add_argument('-r', '--relative', dest='rel', action='store_true',
help='use workspace indices, not numbers (default: no)')
parser.add_argument('-w', '--nowrap', dest='wrap', action='store_false',
help='if at edge, wrap around to other edge (default: yes)')
parser.add_argument('-s', '--nostrict', dest='strict', action='store_false',
help='numbered workspaces have a numeric name (default: yes)')
parser.add_argument('-m', '--move', dest='move', action='store_true',
help='move container to new workspace (default: no)')
args = parser.parse_args()
kwargs = {'right': args.direction.lower().strip() == 'next',
'wrap': args.wrap, 'strict': args.strict, 'move': args.move}
if type(args.number) is int:
to_empty_near(args.number, relative=args.rel, **kwargs)
else:
to_empty(**kwargs)

View File

@@ -0,0 +1,62 @@
#!/bin/sh
# shellcheck disable=SC2016,SC2059
KEYBOARD_ID="AT Translated Set 2 keyboard"
# cpm: characters per minute
# wpm: words per minute (1 word = 5 characters)
METRIC=wpm
FORMAT=" %d $METRIC"
INTERVAL=2
# If you have a keyboard layout that is not listed here yet, create a condition
# yourself. $3 is the key index. Use `xinput test "AT Translated Set 2 keyboard"`
# to see key codes in real time. Be sure to open a pull request for your
# layout's condition!
LAYOUT=qwerty
case "$LAYOUT" in
qwerty) CONDITION='($3 >= 10 && $3 <= 19) || ($3 >= 24 && $3 <= 33) || ($3 >= 37 && $3 <= 53) || ($3 >= 52 && $3 <= 58)'; ;;
azerty) CONDITION='($3 >= 10 && $3 <= 19) || ($3 >= 24 && $3 <= 33) || ($3 >= 37 && $3 <= 54) || ($3 >= 52 && $3 <= 57)'; ;;
qwertz) CONDITION='($3 >= 10 && $3 <= 20) || ($3 >= 24 && $3 <= 34) || ($3 == 36) || ($3 >= 38 && $3 <= 48) || ($3 >= 52 && $3 <= 58)'; ;;
dontcare) CONDITION='1'; ;; # Just register all key presses, not only letters and numbers
*) echo "Unsupported layout \"$LAYOUT\""; exit 1; ;;
esac
# We have to account for the fact we're not listening a whole minute
multiply_by=60
divide_by=$INTERVAL
case "$METRIC" in
wpm) divide_by=$((divide_by * 5)); ;;
cpm) ;;
*) echo "Unsupported metric \"$METRIC\""; exit 1; ;;
esac
hackspeed_cache="$(mktemp -p '' hackspeed_cache.XXXXX)"
trap 'rm "$hackspeed_cache"' EXIT
# Write a dot to our cache for each key press
printf '' > "$hackspeed_cache"
xinput test "$KEYBOARD_ID" | \
stdbuf -o0 awk '$1 == "key" && $2 == "press" && ('"$CONDITION"') {printf "."}' >> "$hackspeed_cache" &
while true; do
# Ask the kernel how big the file is with the command `stat`. The number we
# get is the file size in bytes, which equals the amount of dots the file
# contains, and hence how much keys were pressed since the file was last
# cleared.
lines=$(stat --format %s "$hackspeed_cache")
# Truncate the cache file so that in the next iteration, we count only new
# keypresses
printf '' > "$hackspeed_cache"
# The shell only does integer operations, so make sure to first multiply and
# then divide
value=$((lines * multiply_by / divide_by))
printf "$FORMAT\\n" "$value"
sleep $INTERVAL
done

25
.local/bin/i3scripts/info-idle Executable file
View File

@@ -0,0 +1,25 @@
#!/bin/bash
## Author: Shaun Reed | Contact: shaunrd0@gmail.com | URL: www.shaunreed.com ##
## Depends on xprintidle package ##
## A script to track system idle time within a polybar menu ##
###############################################################################
# info-idle.sh
METRIC=sec
FORMAT=" %d $METRIC"
INTERVAL=2
case "$METRIC" in
min) DIVIDE_BY=$((1000 * 60)); ;;
sec) DIVIDE_BY=1000; ;;
msec) DIVIDE_BY=1 ;;
*) echo "Unsupported metric \"$METRIC\""; exit 1; ;;
esac
while true; do
VALUE=$(($(xprintidle)/ DIVIDE_BY))
printf "$FORMAT\\n" "$VALUE"
sleep $INTERVAL
done

View File

@@ -0,0 +1,41 @@
#!/bin/sh
BAR_HEIGHT=22 # polybar height
BORDER_SIZE=1 # border size from your wm settings
YAD_WIDTH=222 # 222 is minimum possible value
YAD_HEIGHT=193 # 193 is minimum possible value
DATE="$(TZ=UTC date +"%a %d %H:%M")"
case "$1" in
--popup)
if [ "$(xdotool getwindowfocus getwindowname)" = "yad-calendar" ]; then
exit 0
fi
eval "$(xdotool getmouselocation --shell)"
eval "$(xdotool getdisplaygeometry --shell)"
# X
if [ "$((X + YAD_WIDTH / 2 + BORDER_SIZE))" -gt "$WIDTH" ]; then #Right side
: $((pos_x = WIDTH - YAD_WIDTH - BORDER_SIZE))
elif [ "$((X - YAD_WIDTH / 2 - BORDER_SIZE))" -lt 0 ]; then #Left side
: $((pos_x = BORDER_SIZE))
else #Center
: $((pos_x = X - YAD_WIDTH / 2))
fi
# Y
if [ "$Y" -gt "$((HEIGHT / 2))" ]; then #Bottom
: $((pos_y = HEIGHT - YAD_HEIGHT - BAR_HEIGHT - BORDER_SIZE))
else #Top
: $((pos_y = BAR_HEIGHT + BORDER_SIZE))
fi
yad --calendar --undecorated --fixed --close-on-unfocus --no-buttons \
--width=$YAD_WIDTH --height=$YAD_HEIGHT --posx=$pos_x --posy=$pos_y \
--title="yad-calendar" --borders=0 >/dev/null &
;;
*)
echo "$DATE"
;;
esac

10
.local/bin/i3scripts/start-htop Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/bash
#start-htop.sh
#
#i3 move to workspace number $ws95;i3 floating enable;i3 resize set height 700;i3 resize set width 1000;i3 move position center && i3-sensible-terminal -e htop;
(urxvt -hold -e htop && i3 move to workspace number $ws95 && i3 floating enable && i3 resize set height 700 && i3 resize set width 1000 && i3 move position center)

View File

@@ -0,0 +1,6 @@
#!/bin/bash
conky -c $HOME/.config/conky/shortcuts_green &&
conky -c $HOME/.config/conky/sysinfo_green &&
exit 0

49
.local/bin/i3scripts/weather Executable file
View File

@@ -0,0 +1,49 @@
#!/usr/bin/env bash
################################
# Shows info about the weather (in Cincinnati) from accuweather.com
#
# TODO: completely rewrite, probably using openweather APIs
# TODO: make location configurable
# TODO: make temperature unit configurable
#
# @return {Number(degrees Fahrenheit)}: Current temperature in Cincinnati
################################
dir=$(dirname $0)
source $dir/util.sh
full=""
short=""
status=0
URL='http://www.accuweather.com/en/us/cincinnati-oh/45212/weather-forecast/350126'
SITE="$(curl -s "$URL")"
weather="$(echo "$SITE" | awk -F\' '/acm_RecentLocationsCarousel\.push/{print $13 }'| head -1)"
temp="$(echo "$SITE" | awk -F\' '/acm_RecentLocationsCarousel\.push/{print $10 }'| head -1)"
if [[ $weather == *thunder* || $weather == *Thunder* ]]; then
icon=""
else
if [[ $weather == *rain* || $weather == *Rain* ]]; then
icon=""
else
if [[ $weather == *snow* || $weather == *Snow* ]]; then
icon="❄"
else
if [[ $weather == *cloud* || $weather == *Cloud* ]]; then
icon=""
else
icon=""
fi
fi
fi
fi
full="$icon $temp°"
short="$temp°"
echo $full
echo $short
exit $status

99
.local/bin/i3scripts/weathermap Executable file
View File

@@ -0,0 +1,99 @@
#!/bin/sh
get_icon() {
case $1 in
01d) icon="滛";; # Sun clear
01n) icon="";; # Moon clear
02d) icon="";; # Sun cloudy
02n) icon="";; # Moon cloudy
03*) icon="";; # Cloud
04*) icon="";; # Clouds
09d) icon="";; # Day, cloud, rain, wind
09n) icon="";; # Night, cloud, rain, wind
10d) icon="";; # Day rain
10n) icon="";; # Night rain
11d) icon="";; # Day, rain, lightning
11n) icon="";; # Night, rain, lightning
13d) icon="";; # Day, snow
13n) icon="";; # Night, snow
50d) icon="";; # Day, fog
50n) icon="";; # Night, fog
*) icon=""; # Sun clear, default icon
esac
echo $icon
}
get_duration() {
osname=$(uname -s)
case $osname in
*BSD) date -r "$1" -u +%H:%M;;
*) date --date="@$1" -u +%H:%M;;
esac
}
KEY="3fbb0282dfd1ba8295bcb93b329fd152"
CITY="5149222"
UNITS="imperial"
SYMBOL="°"
API="https://api.openweathermap.org/data/2.5"
if [ -n "$CITY" ]; then
if [ "$CITY" -eq "$CITY" ] 2>/dev/null; then
CITY_PARAM="id=$CITY"
else
CITY_PARAM="q=$CITY"
fi
current=$(curl -sf "$API/weather?appid=$KEY&$CITY_PARAM&units=$UNITS")
forecast=$(curl -sf "$API/forecast?appid=$KEY&$CITY_PARAM&units=$UNITS&cnt=1")
else
location=$(curl -sf https://location.services.mozilla.com/v1/geolocate?key=geoclue)
if [ -n "$location" ]; then
location_lat="$(echo "$location" | jq '.location.lat')"
location_lon="$(echo "$location" | jq '.location.lng')"
current=$(curl -sf "$API/weather?appid=$KEY&lat=$location_lat&lon=$location_lon&units=$UNITS")
forecast=$(curl -sf "$API/forecast?appid=$KEY&lat=$location_lat&lon=$location_lon&units=$UNITS&cnt=1")
fi
fi
if [ -n "$current" ] && [ -n "$forecast" ]; then
current_temp=$(echo "$current" | jq ".main.temp" | cut -d "." -f 1)
current_icon=$(echo "$current" | jq -r ".weather[0].icon")
forecast_temp=$(echo "$forecast" | jq ".list[].main.temp" | cut -d "." -f 1)
forecast_icon=$(echo "$forecast" | jq -r ".list[].weather[0].icon")
if [ "$current_temp" -gt "$forecast_temp" ]; then
trend="" # Arrow, down-right slant
elif [ "$forecast_temp" -gt "$current_temp" ]; then
trend="" # Arrow, up-right slant
else
trend="" # Arrow, left-to-right
fi
sun_rise=$(echo "$current" | jq ".sys.sunrise")
sun_set=$(echo "$current" | jq ".sys.sunset")
now=$(date +%s)
# Format of sunset/rise display and icons
if [ "$sun_rise" -gt "$now" ]; then
daytime="  $(get_duration "$((sun_rise-now))")" # Sun rise
elif [ "$sun_set" -gt "$now" ]; then
daytime="  $(get_duration "$((sun_set-now))")" # Sun set
else
daytime="  $(get_duration "$((sun_rise-now))")" # Unknown
fi
# Format of resulting forecast
echo "$(get_icon "$current_icon") $current_temp$SYMBOL $trend $(get_icon "$forecast_icon") $forecast_temp$SYMBOL$daytime"
#echo "$(get_icon "$current_icon") $current_temp$SYMBOL $trend $(get_icon "$forecast_icon") $forecast_temp$SYMBOL $daytime"
fi

23
.local/bin/i3scripts/xoffee Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/bash
## Author: Shaun Reed | Contact: shaunrd0@gmail.com | URL: www.shaunreed.com ##
## ##
## A script to toggle and notify xautolock via polybar menus ##
###############################################################################
# xoffee.sh
if [ $# -ne 1 ]; then
echo "Incorrect number of arguments provided"
exit 1
fi
if [ "$1" = "enable" ]; then
xautolock -disable
notify-send "Caffeine enabled"
elif [ "$1" = "disable" ]; then
xautolock -enable
notify-send "Caffeine disabled"
else
notify-send "Error: Incorrect arg for xoffee script"
exit 1
fi