summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam T. Carpenter <atc@sparrowhawk.53hor.net>2020-05-13 08:19:11 -0400
committerAdam T. Carpenter <atc@sparrowhawk.53hor.net>2020-05-13 08:19:11 -0400
commit8b1a2abb3bc497af04f9531db46af4b0dda42117 (patch)
tree14e91cc7a77d6d4756d58db6e004cdab3546f627
parentb184782970853b3c479f6c4ad833a36a3aea7afa (diff)
downloadscripts-8b1a2abb3bc497af04f9531db46af4b0dda42117.tar.xz
scripts-8b1a2abb3bc497af04f9531db46af4b0dda42117.zip
updated for FreeBSD userland, included wpg scripts
-rwxr-xr-xi3blocks-battery.sh39
-rwxr-xr-xi3blocks-cpuload.sh5
-rwxr-xr-xi3blocks-cputemp.sh14
-rwxr-xr-xi3blocks-memory.sh2
-rwxr-xr-xi3blocks-packages.sh5
-rwxr-xr-xi3blocks-updates.sh5
-rwxr-xr-xwpg12
-rwxr-xr-xwpg-install.sh262
8 files changed, 303 insertions, 41 deletions
diff --git a/i3blocks-battery.sh b/i3blocks-battery.sh
index 33e6a74..af2d37f 100755
--- a/i3blocks-battery.sh
+++ b/i3blocks-battery.sh
@@ -1,32 +1,15 @@
#!/bin/sh
-base="/sys/class/power_supply/BAT0/"
-low=25
-med=50
-high=75
-icon_charging_high=󱊦
-icon_charging_low=󱊤
-icon_charging_med=󱊥
-icon_charging_dry=󰢟
-icon_high=󱊣
-icon_low=󱊡
-icon_med=󱊢
-icon_dry=󰂎
+icon_high=󰁹
+icon_low=󰁾
+icon_crit=󱃍
+icon_charging=󰂄
-full=$(< $base/energy_full_design)
-now=$(< $base/energy_now)
-stat=$(< $base/status)
-percent=$(echo "result = $now / $full * 100; scale=0; result / 1" | bc -l)
+status=$(apm -b)
+level=$(apm -l)
-if [ "$stat" = "Discharging" ]; then
- [ $percent -lt $low ] && printf $icon_dry
- [ $percent -ge $low ] && [ $percent -lt $med ] && printf $icon_low
- [ $percent -ge $med ] && [ $percent -lt $high ] && printf $icon_med
- [ $percent -ge $high ] && printf $icon_high
-else
- [ $percent -lt $low ] && printf $icon_charging_dry
- [ $percent -ge $low ] && [ $percent -lt $med ] && printf $icon_charging_low
- [ $percent -ge $med ] && [ $percent -lt $high ] && printf $icon_charging_med
- [ $percent -ge $high ] && printf $icon_charging_high
-fi
+[ $status -eq 0 ] && printf "%s" $icon_high
+[ $status -eq 1 ] && printf "%s" $icon_low
+[ $status -eq 2 ] && printf "%s" $icon_crit
+[ $status -eq 3 ] && printf "%s" $icon_charging
-printf " %s%%\n" $percent
+printf " %s%%\n" $level
diff --git a/i3blocks-cpuload.sh b/i3blocks-cpuload.sh
index 6d3773f..8d61815 100755
--- a/i3blocks-cpuload.sh
+++ b/i3blocks-cpuload.sh
@@ -2,15 +2,14 @@
cpu_count=4
low=25
high=75
-icon=󰻠
icon_low=󰒲
icon_mid=󰜎
icon_high=󱅝
-avg_load=$(uptime | cut -d, -f4 | cut -d: -f2)
+#min_avg_usage=$(vmstat | tail -1 | cut -w -f17)
+avg_load=$(sysctl vm.loadavg | cut -w -f3)
percent=$(echo "result = $avg_load / $cpu_count * 100; scale=0; result / 1" | bc -l)
-printf $icon
[ $percent -lt $low ] && printf $icon_low
[ $percent -ge $low ] && [ $percent -lt $high ] && printf $icon_mid
[ $percent -ge $high ] && printf $icon_high
diff --git a/i3blocks-cputemp.sh b/i3blocks-cputemp.sh
index 94a9a2b..c88ecef 100755
--- a/i3blocks-cputemp.sh
+++ b/i3blocks-cputemp.sh
@@ -1,14 +1,16 @@
#!/bin/sh
-kelvins=$(cat /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp1_input)
low=122 # 50C
high=176 # 80C
icon_low=󱃃
icon_mid=󰔏
icon_high=󱃂
-fahrenheit=$(expr $(expr $(expr $(expr $kelvins \* 9) / 5) / 1000) + 32)
-[ $fahrenheit -lt $low ] && printf $icon_low
-[ $fahrenheit -ge $low ] && [ $fahrenheit -lt $high ] && printf $icon_mid
-[ $fahrenheit -ge $high ] && printf $icon_high
+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
-printf " %s ℉\n" $fahrenheit
+#printf " %s C\n" $celcius
+
+# 'Murica
+printf " %s ℉\n" $(echo "scale=1; $celcius * 9 / 5 + 32" | bc -l)
diff --git a/i3blocks-memory.sh b/i3blocks-memory.sh
index f37dc4c..e40c2df 100755
--- a/i3blocks-memory.sh
+++ b/i3blocks-memory.sh
@@ -1,4 +1,4 @@
#!/bin/sh
icon=󰍛
-printf "$icon %s\n" "$(free -h | awk 'FNR==2 { print $3 }')"
+printf "$icon %s\n" $(vmstat -h | tail -1 | cut -w -f5)
diff --git a/i3blocks-packages.sh b/i3blocks-packages.sh
new file mode 100755
index 0000000..347a687
--- /dev/null
+++ b/i3blocks-packages.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+icon=󰏖
+
+package_count=$(pkg upgrade -n | tail -1 | cut -s -d':' -f2)
+[ $package_count -gt 0 ] && printf "$icon %s\n" $package_count
diff --git a/i3blocks-updates.sh b/i3blocks-updates.sh
index 1c1e825..a35bbe0 100755
--- a/i3blocks-updates.sh
+++ b/i3blocks-updates.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-icon=󰏖
+icon=󰣠
-packages="$(pacman -Qu | wc -l)"
-[ $packages -gt 0 ] && printf "$icon %s\n" $packages
+freebsd-update updatesready && printf "$update_icon Updates are ready. "
diff --git a/wpg b/wpg
new file mode 100755
index 0000000..693a550
--- /dev/null
+++ b/wpg
@@ -0,0 +1,12 @@
+#!/usr/local/bin/python3.7
+# EASY-INSTALL-ENTRY-SCRIPT: 'wpgtk==6.1.0','console_scripts','wpg'
+__requires__ = 'wpgtk==6.1.0'
+import re
+import sys
+from pkg_resources import load_entry_point
+
+if __name__ == '__main__':
+ sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
+ sys.exit(
+ load_entry_point('wpgtk==6.1.0', 'console_scripts', 'wpg')()
+ )
diff --git a/wpg-install.sh b/wpg-install.sh
new file mode 100755
index 0000000..9cf076e
--- /dev/null
+++ b/wpg-install.sh
@@ -0,0 +1,262 @@
+#!/usr/bin/env bash
+
+__ScriptVersion="0.1.5";
+
+if [ -n "${XDG_CONFIG_HOME}" ]; then
+ CONFIG="${XDG_CONFIG_HOME}"
+else
+ CONFIG="${HOME}/.config"
+fi
+
+if [ -n "${XDG_DATA_HOME}" ]; then
+ LOCAL="${XDG_DATA_HOME}"
+else
+ LOCAL="${HOME}/.local/share"
+fi
+
+THEMES_DIR="${HOME}/.themes";
+SRC_DIR="${PWD}/wpgtk-templates";
+TEMPLATE_DIR="${CONFIG}/wpg/templates";
+
+#=== FUNCTION ================================================================
+# NAME: wpg-install.sh
+# DESCRIPTION: Installs various wpgtk themes.
+#===============================================================================
+usage()
+{
+ echo "Usage : $0 [options] [--]
+
+ Options:
+ -h Display this message
+ -v Display script version
+ -o Install openbox templates
+ -t Install tint2 template
+ -g Install gtk template
+ -i Install icon-set
+ -r Install rofi template
+ -I Install i3 template
+ -p Install polybar template
+ -b Install bspwm template
+ -d Install dunst template
+ -H Specify hash of wpgtk-templates repository to use
+ "
+}
+
+checkprogram()
+{
+ command -v $1 >/dev/null 2>&1;
+ if [[ $? -eq 1 ]]; then
+ echo "Please install $1 before proceeding";
+ exit 1;
+ fi
+}
+
+getfiles()
+{
+ checkprogram 'git';
+ checkprogram 'wpg';
+ mkdir -p "${LOCAL}/themes/color_other";
+ mkdir -p "${LOCAL}/icons";
+ git clone https://github.com/deviantfero/wpgtk-templates "$SRC_DIR";
+ if [[ $? -eq 0 ]]; then
+ cd "$SRC_DIR";
+ [[ ! -z "$commit" ]] && git checkout $commit;
+ return 0;
+ else
+ exit 1;
+ fi
+}
+
+install_tint2()
+{
+ echo -n "This might override your tint2 config, Continue?[Y/n]: ";
+ read -r response;
+ if [[ ! "$response" == "n" ]]; then
+ echo "Installing tint2 config";
+ echo ":: backing up current tint2 conf in tint2rc.old.bak";
+ cp "${CONFIG}/tint2/tint2rc" "${CONFIG}/tint2/tint2rc.old.bak" 2>/dev/null;
+ cp --remove-destination ./tint2/tint2rc "${CONFIG}/tint2/tint2rc" && \
+ cp --remove-destination ./tint2/tint2rc.base "${TEMPLATE_DIR}" && \
+ ln -sf "${CONFIG}/tint2/tint2rc" "${TEMPLATE_DIR}/tint2rc" && \
+ echo ":: tint2 template install done."
+ return 0;
+ fi
+ echo ":: tint2 template not installed";
+}
+
+install_rofi()
+{
+ echo -n "This might override your rofi config, Continue?[Y/n]: ";
+ read -r response;
+ if [[ ! "$response" == "n" ]]; then
+ echo "Installing rofi config";
+ echo ":: backing up current rofi conf in rofi.bak";
+ cp "${CONFIG}/rofi/config" "${CONFIG}/rofi/config.bak" 2>/dev/null;
+ cp --remove-destination ./rofi/config "${CONFIG}/rofi/config" && \
+ cp --remove-destination ./rofi/rofi.base "${TEMPLATE_DIR}" && \
+ ln -sf "${CONFIG}/rofi/config" "${TEMPLATE_DIR}/rofi" && \
+ echo ":: rofi template install done."
+ return 0;
+ fi
+ echo ":: rofi template not installed";
+}
+
+install_i3()
+{
+ echo -n "This might override your i3 config, Continue?[Y/n]: ";
+ read -r response;
+ if [[ ! "$response" == "n" ]]; then
+ echo "Installing i3 config";
+ echo ":: backing up current i3 conf in config.bak";
+ cp "${CONFIG}/i3/config" "${CONFIG}/i3/config.bak" 2>/dev/null;
+ cp --remove-destination ./i3/config "${CONFIG}/i3/config" && \
+ cp --remove-destination ./i3/i3.base "${TEMPLATE_DIR}" && \
+ ln -sf "${CONFIG}/i3/config" "${TEMPLATE_DIR}/i3" && \
+ echo ":: i3 template install done."
+ return 0;
+ fi
+ echo ":: i3 template not installed";
+}
+
+install_polybar()
+{
+ echo -n "This might override your polybar config, Continue?[Y/n]: ";
+ read -r response;
+ if [[ ! "$response" == "n" ]]; then
+ echo "Installing polybar config";
+ echo ":: backing up current polybar conf in config.bak";
+ cp "${CONFIG}/polybar/config" "${CONFIG}/polybar/config.bak" 2>/dev/null;
+ cp --remove-destination ./polybar/config "${CONFIG}/polybar/config" && \
+ cp --remove-destination ./polybar/polybar.base "${TEMPLATE_DIR}" && \
+ ln -sf "${CONFIG}/polybar/config" "${TEMPLATE_DIR}/polybar" && \
+ echo ":: polybar template install done."
+ return 0;
+ fi
+ echo ":: polybar template not installed";
+}
+
+install_gtk()
+{
+ echo "Installing gtk themes";
+ cp -r ./FlatColor "${LOCAL}/themes/" && \
+
+ cp --remove-destination ./FlatColor/gtk-2.0/gtkrc.base "${TEMPLATE_DIR}/gtk2.base" && \
+ ln -sf "${LOCAL}/themes/FlatColor/gtk-2.0/gtkrc" "${TEMPLATE_DIR}/gtk2" && \
+ ln -sf "${LOCAL}/themes/FlatColor" "${THEMES_DIR}/FlatColor" && \
+ echo ":: gtk2 theme done" "${TEMPLATE_DIR}/gtk2";
+
+ cp --remove-destination ./FlatColor/gtk-3.0/gtk.css.base "${TEMPLATE_DIR}/gtk3.0.base" && \
+ ln -sf "${LOCAL}/themes/FlatColor/gtk-3.0/gtk.css" "${TEMPLATE_DIR}/gtk3.0" && \
+ echo ":: gtk3.0 theme done"
+
+ cp --remove-destination ./FlatColor/gtk-3.20/gtk.css.base "${TEMPLATE_DIR}/gtk3.20.base" && \
+ ln -sf "${LOCAL}/themes/FlatColor/gtk-3.20/gtk.css" "${TEMPLATE_DIR}/gtk3.20" && \
+ echo ":: gtk3.20 theme done"
+
+ echo ":: FlatColor gtk themes install done."
+}
+
+install_icons()
+{
+ echo "Installing icon pack";
+ cp -r flattrcolor "${LOCAL}/icons/" && \
+ cp -r flattrcolor-dark "${LOCAL}/icons/" && \
+ echo ":: flattr icons install done."
+}
+
+install_openbox()
+{
+ echo "Installing openbox themes";
+ cp --remove-destination -r ./openbox/colorbamboo/* "${LOCAL}/themes/colorbamboo"
+
+ if [[ $? -eq 0 ]]; then
+ mv "${LOCAL}/themes/colorbamboo/openbox-3/themerc.base" "${TEMPLATE_DIR}/ob_colorbamboo.base" && \
+ ln -sf "${LOCAL}/themes/colorbamboo/openbox-3/themerc" "${TEMPLATE_DIR}/ob_colorbamboo" && \
+ ln -sf "${LOCAL}/themes/colorbamboo" "${THEMES_DIR}/colorbamboo" && \
+ echo ":: colorbamboo openbox themes install done.";
+ fi
+}
+
+install_bspwm()
+{
+ echo "Installing bspwm colors";
+ mv "./bspwm/bspwm_colors.base" "${TEMPLATE_DIR}/bspwm_colors.base";
+ mv "./bspwm/bspwm_colors" "${TEMPLATE_DIR}/bspwm_colors";
+ ln -sf "${CONFIG}/bspwm/bspwm_colors.sh" "${TEMPLATE_DIR}/bspwm_colors" && \
+ printf 'bash %s/bspwm/bspwm_colors.sh &' ${CONFIG} >> "${CONFIG}/bspwm/bspwmrc";
+ echo ":: bspwm colors install done.";
+}
+
+install_dunst()
+{
+ echo "Installing dunst colors";
+ echo ":: backing up current dunst conf in dunstrc.bak";
+ cp "${CONFIG}/dunst/dunstrc" "${CONFIG}/dunst/dunstrc.bak" 2>/dev/null;
+
+ mv "./dunst/dunstrc.base" "${TEMPLATE_DIR}/dunstrc.base";
+ mv "./dunst/dunstrc" "${TEMPLATE_DIR}/dunstrc";
+ ln -sf "${CONFIG}/dunst/dunstrc" "${TEMPLATE_DIR}/dunstrc" && \
+ echo ":: dunst colors install done.";
+}
+
+clean_up()
+{
+ rm -rf "$SRC_DIR";
+}
+
+
+#-----------------------------------------------------------------------
+# Handle command line arguments
+#-----------------------------------------------------------------------
+
+getargs()
+{
+ while getopts "H:bhvotgiIprd" opt
+ do
+ case $opt in
+ h)
+ usage;
+ exit 0
+ ;;
+ v)
+ echo "$0 -- Version $__ScriptVersion";
+ exit 0;
+ ;;
+ o) openbox="true" ;;
+ i) icons="true" ;;
+ g) gtk="true" ;;
+ t) tint2="true" ;;
+ r) rofi="true" ;;
+ I) i3="true" ;;
+ p) polybar="true" ;;
+ b) bspwm="true" ;;
+ d) dunst="true" ;;
+ H) commit="${OPTARG}" ;;
+ *)
+ echo -e "\n Option does not exist : $OPTARG\n"
+ usage;
+ exit 1
+ ;;
+
+ esac
+ done
+ shift "$((OPTIND - 1))"
+}
+
+main()
+{
+ getargs "$@";
+ getfiles;
+ [[ "$openbox" == "true" ]] && install_openbox;
+ [[ "$tint2" == "true" ]] && install_tint2;
+ [[ "$rofi" == "true" ]] && install_rofi;
+ [[ "$gtk" == "true" ]] && install_gtk;
+ [[ "$icons" == "true" ]] && install_icons;
+ [[ "$polybar" == "true" ]] && install_polybar;
+ [[ "$i3" == "true" ]] && install_i3;
+ [[ "$bspwm" == "true" ]] && install_bspwm;
+ [[ "$dunst" == "true" ]] && install_dunst;
+ clean_up;
+}
+
+main "$@"