summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam T. Carpenter <atc@53hor.net>2020-05-18 20:56:13 -0400
committerAdam T. Carpenter <atc@53hor.net>2020-05-18 20:56:13 -0400
commit0ce7301d8799ba91a0d57ab208e2d80d20935a83 (patch)
treee509a730a429ffdbb418dbb53b42557d40541f8e
parent6e14535ef56fd91b05eb170f71f7989d7435d8c3 (diff)
downloadscripts-0ce7301d8799ba91a0d57ab208e2d80d20935a83.tar.xz
scripts-0ce7301d8799ba91a0d57ab208e2d80d20935a83.zip
temp fixes for blocks utf+8 errors, added dict.sh, updated porter
-rw-r--r--.i3blocks-mail.sh.swpbin0 -> 12288 bytes
-rwxr-xr-xabraham-porter.sh112
-rwxr-xr-xdict.sh51
-rwxr-xr-xi3blocks-audio.sh2
-rwxr-xr-xi3blocks-battery.sh4
-rwxr-xr-xi3blocks-cpuload.sh2
-rwxr-xr-xi3blocks-cputemp.sh18
-rwxr-xr-xi3blocks-date.sh2
-rwxr-xr-xi3blocks-disk.sh2
-rwxr-xr-xi3blocks-memory.sh2
-rwxr-xr-xi3blocks-net.sh4
-rwxr-xr-xi3blocks-news.sh2
-rwxr-xr-xi3blocks-packages.sh2
-rwxr-xr-xi3blocks-updates.sh2
-rwxr-xr-xi3blocks-uptime.sh2
-rwxr-xr-xlocker.sh12
-rwxr-xr-xopen-chats.sh7
17 files changed, 148 insertions, 78 deletions
diff --git a/.i3blocks-mail.sh.swp b/.i3blocks-mail.sh.swp
new file mode 100644
index 0000000..eae9649
--- /dev/null
+++ b/.i3blocks-mail.sh.swp
Binary files differ
diff --git a/abraham-porter.sh b/abraham-porter.sh
index 1498ccf..ec4ca55 100755
--- a/abraham-porter.sh
+++ b/abraham-porter.sh
@@ -4,10 +4,10 @@
dmenu="rofi -dmenu"
doas="doas"
terminal="alacritty"
-printer="rofi -width -81 -e"
+pager="rofi -location 2 -width -81 -e"
ports_dir="/usr/local/poudriere/ports/default"
pkglist="$HOME/.pkglist"
-poudriere_jail="121x64"
+jail="121x64"
## Error codes
@@ -16,33 +16,30 @@ NO_ACTION_PROVIDED=3
NO_PORT_PROVIDED=4
NO_PKG_DESCR_FOUND=5
NO_WANT_TERM_PROVIDED=6
+NO_WANT_ANOTHER_PROVIDED=7
## Gets a port name from the user with dmenu
get_port() {
cwd=$(pwd)
cd "$ports_dir"
- printf "%s\n" */* | $dmenu -p "Choose a port"
+ printf "%s\n" */* | $dmenu -p "Port"
cd "$cwd"
}
## Prompt user if they want to run command in a new term
wants_term() {
- choice=$($dmenu -p "Do you want to do this in a new terminal?" << EOF
-no
-yes
-EOF
- )
- [ $action = "yes" ] && return 1
- [ $action = "no" ] && return 0
+ choice=$(printf "no\nyes\n" | $dmenu -p "Do you want to do this in a new terminal?")
+ [ $choice = "no" ] && return 1
+ [ $choice = "yes" ] && return 0
exit $NO_WANT_TERM_PROVIDED
}
## Gets an action from the user with dmenu
get_action() {
- action=$($dmenu -p "Whadyagonnado" << EOF
+ action=$($dmenu -p "Abraham Porter" << EOF
1. print pkg-descr
2. set options
3. set options, add to pkglist
@@ -64,7 +61,7 @@ handle_print_pkg_desc() {
pkg_descr="$ports_dir"/$port/pkg-descr
[ ! -f "$pkg_descr" ] && exit $NO_PKG_DESCR_FOUND
text=$(cat "$ports_dir"/$port/pkg-descr)
- $printer "$text"
+ $pager "$text"
}
@@ -114,42 +111,57 @@ handle_poudriere_bulk_pkglist() {
}
+get_another() {
+ choice=$($dmenu -p "Do you want another?" << EOF
+no
+yes
+EOF
+ )
+ [ $choice = "no" ] && return 1
+ [ $choice = "yes" ] && return 0
+ exit $NO_WANT_ANOTHER_PROVIDED
+}
+
+
## Main
-action=$(get_action)
-case $action in
- 1)
- # 1. print pkg-descr
- handle_print_pkg_desc
- ;;
- 2)
- # 2. set options
- handle_poudriere_options_single $(get_port)
- ;;
- 3)
- # 3. set options, add to pkglist
- handle_poudriere_options_single $(handle_append_pkglist $(get_port))
- ;;
- 4)
- # 4. set options, build pkg
- handle_poudriere_bulk_single $(handle_poudriere_options_single $(get_port))
- ;;
- 5)
- # 5. set options, build pkg, add to pkglist
- handle_poudriere_bulk_single $(handle_poudriere_options_single $(handle_append_pkglist $(get_port)))
- ;;
- 6)
- # 6. add to pkglist
- handle_append_pkglist $(get_port)
- ;;
- 7)
- # 7. set options on pkglist
- handle_poudriere_options_pkglist
- ;;
- 8)
- # 8. build entire pkglist (lengthy and intensive!)
- handle_poudriere_bulk_pkglist
- ;;
- *)
- exit $NO_ACTION_PROVIDED
- ;;
-esac
+while true; do
+ action=$(get_action)
+ case $action in
+ 1)
+ # 1. print pkg-descr
+ handle_print_pkg_desc
+ ;;
+ 2)
+ # 2. set options
+ handle_poudriere_options_single $(get_port)
+ ;;
+ 3)
+ # 3. set options, add to pkglist
+ handle_poudriere_options_single $(handle_append_pkglist $(get_port))
+ ;;
+ 4)
+ # 4. set options, build pkg
+ handle_poudriere_bulk_single $(handle_poudriere_options_single $(get_port))
+ ;;
+ 5)
+ # 5. set options, build pkg, add to pkglist
+ handle_poudriere_bulk_single $(handle_poudriere_options_single $(handle_append_pkglist $(get_port)))
+ ;;
+ 6)
+ # 6. add to pkglist
+ handle_append_pkglist $(get_port)
+ ;;
+ 7)
+ # 7. set options on pkglist
+ handle_poudriere_options_pkglist
+ ;;
+ 8)
+ # 8. build entire pkglist (lengthy and intensive!)
+ handle_poudriere_bulk_pkglist
+ ;;
+ *)
+ exit $NO_ACTION_PROVIDED
+ ;;
+ esac
+ get_another || exit OK
+done
diff --git a/dict.sh b/dict.sh
new file mode 100755
index 0000000..53c10df
--- /dev/null
+++ b/dict.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+## dict.sh - nicely look up words in dictionaries with dictd
+
+## Configuration
+dmenu="rofi -dmenu"
+pager="rofi -location 2 -width -81 -e"
+
+
+## Error codes
+NO_TERM_PROVIDED=4
+NO_DICT_PROVIDED=5
+
+
+## Get available dictionaries
+get_dict() {
+ dict -D | \
+ tail -n +2 | \
+ grep -v "fd" | \
+ sed 's/^ [a-z0-9-]* *//' | \
+ $dmenu -i -p "Dictionary"
+}
+
+
+## Get search term
+get_search_term() {
+ term=$(printf "Clipboard\nPrimary selection\n" | $dmenu -i -p "Search term")
+ if [ "$term" = "Clipboard" ]; then
+ echo "$(xclip -o -selection clipboard)"
+ elif [ "$term" = "Primary selection" ]; then
+ echo "$(xclip -o -selection primary)"
+ else
+ echo "$term"
+ fi
+}
+
+
+## Search dictionary for term
+search() {
+ dict=$1
+ term=$2
+ dict -d $(dict -D | grep "$dict" | cut -w -f2) "$term"
+}
+
+
+## Main
+dict=$(get_dict)
+[ -z "$dict" ] && exit $NO_DICT_PROVIDED
+term=$(get_search_term)
+[ -z "$term" ] && exit $NO_TERM_PROVIDED
+result=$(search "$dict" "$term")
+[ -z "$result" ] && $pager "No results found." || $pager "$result"
diff --git a/i3blocks-audio.sh b/i3blocks-audio.sh
index 53b00e3..1a54199 100755
--- a/i3blocks-audio.sh
+++ b/i3blocks-audio.sh
@@ -13,4 +13,4 @@ icon=
[ $volume -gt 0 ] && [ $volume -lt $low ] && icon=$icon_low
[ $volume -ge $low ] && [ $volume -lt $high ] && icon=$icon_mid
[ $volume -ge $high ] && icon=$icon_high
-printf "%s %s%%\n" $icon $volume
+printf "%s%s%%\n" $icon $volume
diff --git a/i3blocks-battery.sh b/i3blocks-battery.sh
index af2d37f..c37c7a2 100755
--- a/i3blocks-battery.sh
+++ b/i3blocks-battery.sh
@@ -9,7 +9,7 @@ level=$(apm -l)
[ $status -eq 0 ] && printf "%s" $icon_high
[ $status -eq 1 ] && printf "%s" $icon_low
-[ $status -eq 2 ] && printf "%s" $icon_crit
+[ $status -eq 2 ] && printf "%s" $icon_crit && notify-send "Battery critically low"
[ $status -eq 3 ] && printf "%s" $icon_charging
-printf " %s%%\n" $level
+printf "%s%%\n" $level
diff --git a/i3blocks-cpuload.sh b/i3blocks-cpuload.sh
index 65ccaca..acd6eb0 100755
--- a/i3blocks-cpuload.sh
+++ b/i3blocks-cpuload.sh
@@ -15,4 +15,4 @@ ghz=$(echo "result = $mhz / 1000; scale=1; result / 1" | bc -l)
[ $percent -lt $low ] && printf $icon_low
[ $percent -ge $low ] && [ $percent -lt $high ] && printf $icon_mid
[ $percent -ge $high ] && printf $icon_high
-printf " %s%% %s GHz\n" $percent $ghz
+printf "%s%% %s GHz\n" $percent $ghz
diff --git a/i3blocks-cputemp.sh b/i3blocks-cputemp.sh
index c88ecef..faac2de 100755
--- a/i3blocks-cputemp.sh
+++ b/i3blocks-cputemp.sh
@@ -1,16 +1,18 @@
#!/bin/sh
-low=122 # 50C
+#low=122 # 50C
high=176 # 80C
-icon_low=󱃃
-icon_mid=󰔏
-icon_high=󱃂
+#icon_low=󱃃
+#icon_mid=󰔏
+#icon_high=󱃂
+icon=󰔏
celcius=$(sysctl -n dev.cpu.0.temperature | cut -d'.' -f1)
-[ $celcius -lt $low ] && printf $icon_low
-[ $celcius -ge $low ] && [ $fahrenheit -lt $high ] && printf $icon_mid
-[ $celcius -ge $high ] && printf $icon_high
+#[ $celcius -lt $low ] && printf $icon_low
+#[ $celcius -ge $low ] && [ $fahrenheit -lt $high ] && printf $icon_mid
+#[ $celcius -ge $high ] && printf $icon_high
+[ $celcius -ge $high ] && notify-send "CPU temperature hit 176F (80C)"
#printf " %s C\n" $celcius
# 'Murica
-printf " %s ℉\n" $(echo "scale=1; $celcius * 9 / 5 + 32" | bc -l)
+printf "$icon%s ℉\n" $(echo "scale=1; $celcius * 9 / 5 + 32" | bc -l)
diff --git a/i3blocks-date.sh b/i3blocks-date.sh
index 80bb4dd..2c71451 100755
--- a/i3blocks-date.sh
+++ b/i3blocks-date.sh
@@ -1,4 +1,4 @@
#!/bin/sh
icon=󰃰
-printf "$icon %s\n" "$(date '+%a %b %e %l:%M %p')"
+printf "$icon%s\n" "$(date '+%a %b %e %l:%M %p')"
diff --git a/i3blocks-disk.sh b/i3blocks-disk.sh
index fba0cf6..c1ad745 100755
--- a/i3blocks-disk.sh
+++ b/i3blocks-disk.sh
@@ -1,4 +1,4 @@
#!/bin/sh
icon=󰋊
-printf "$icon %s\n" $(df -h | awk '$6=="/" { print $5 }')
+printf "$icon%s\n" $(df -h | awk '$6=="/" { print $5 }')
diff --git a/i3blocks-memory.sh b/i3blocks-memory.sh
index 308b2b1..dde8470 100755
--- a/i3blocks-memory.sh
+++ b/i3blocks-memory.sh
@@ -1,4 +1,4 @@
#!/bin/sh
icon=󰍛
-printf "$icon %s\n" $(top -d 1 | grep Mem | cut -w -f2)
+printf "$icon%s\n" $(top -d 1 | grep Mem | cut -w -f2)
diff --git a/i3blocks-net.sh b/i3blocks-net.sh
index cd0f6c4..3d65ddb 100755
--- a/i3blocks-net.sh
+++ b/i3blocks-net.sh
@@ -5,8 +5,8 @@ icon_wireless=󰖩
is_ethernet=$(ifconfig em0 | grep status | cut -d':' -f2)
if [ "$is_ethernet" = " active" ]; then
inet=$(ifconfig lagg0 | grep inet\ | cut -w -f3)
- printf "$icon_ethernet %s\n" $inet
+ printf "$icon_ethernet%s\n" $inet
else
ssid=$(ifconfig wlan0 | grep ssid | cut -d'"' -f2)
- printf "$icon_wireless %s\n" "$ssid"
+ printf "$icon_wireless%s\n" "$ssid"
fi
diff --git a/i3blocks-news.sh b/i3blocks-news.sh
index 024043a..c40b486 100755
--- a/i3blocks-news.sh
+++ b/i3blocks-news.sh
@@ -2,4 +2,4 @@
icon=󰎕
unread=$(newsboat -x print-unread | cut -d' ' -f1)
-[ $unread -gt 0 ] && printf "$icon %s\n" $unread
+[ $unread -gt 0 ] && printf "$icon%s\n" $unread && notify-send "$unread unread articles in newsboat"
diff --git a/i3blocks-packages.sh b/i3blocks-packages.sh
index 347a687..3717a01 100755
--- a/i3blocks-packages.sh
+++ b/i3blocks-packages.sh
@@ -2,4 +2,4 @@
icon=󰏖
package_count=$(pkg upgrade -n | tail -1 | cut -s -d':' -f2)
-[ $package_count -gt 0 ] && printf "$icon %s\n" $package_count
+[ $package_count -gt 0 ] && printf "$icon%s\n" $package_count && notify-send "$package_count package upgrades available"
diff --git a/i3blocks-updates.sh b/i3blocks-updates.sh
index a35bbe0..3b73f3c 100755
--- a/i3blocks-updates.sh
+++ b/i3blocks-updates.sh
@@ -1,4 +1,4 @@
#!/bin/sh
icon=󰣠
-freebsd-update updatesready && printf "$update_icon Updates are ready. "
+freebsd-update updatesready && printf "%s" $icon && notify-send "FreeBSD updates are ready to install"
diff --git a/i3blocks-uptime.sh b/i3blocks-uptime.sh
index 3be3b2a..515f056 100755
--- a/i3blocks-uptime.sh
+++ b/i3blocks-uptime.sh
@@ -1,4 +1,4 @@
#!/bin/sh
icon=󰣠
-printf "$icon %s\n" "$(uptime -p | cut -d, -f1,2)"
+printf "$icon%s\n" "$(uptime -p | cut -d, -f1,2)"
diff --git a/locker.sh b/locker.sh
new file mode 100755
index 0000000..89549fe
--- /dev/null
+++ b/locker.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+## Alternative, use the vignette wallpaper set by themer sript.
+i3lock -n -f -c 000000 -i $HOME/.local/share/wallpapers/lock.png; sleep 0.2
+
+
+# alacritty -e asciiquarium &
+# sleep 0.2
+#
+# i3-msg fullscreen
+#
+# i3lock -n -f -c 000000 ; i3-msg kill
diff --git a/open-chats.sh b/open-chats.sh
deleted file mode 100755
index 063d9ac..0000000
--- a/open-chats.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-while [ -n "$1" ]; do
- [ "$1" = "-d" ] && surf "discord.com/app" &
- [ "$1" = "-m" ] && surf "messenger.com" &
- shift
-done