From b68268b5a5a21bcf9eea94e0818e61cd5434b2a1 Mon Sep 17 00:00:00 2001 From: David Todd Date: Mon, 4 Mar 2019 21:56:22 -0600 Subject: [PATCH] Add i3blocks-contrib stuff Stuff pulled from [i3blocks-contrib](https://github.com/vivien/i3blocks-contrib) and Luke Smith's [dotfiles](https://github.com/LukeSmithxyz/voidrice/tree/master/.scripts/statusbar) the contents may have been modified to work on my system --- i3/i3blocks.conf | 34 +++++++++---- i3/i3blocks/bandwidth | 104 +++++++++++++++++++++++++++++++++++++++ i3/i3blocks/cpu_usage | Bin 0 -> 26608 bytes i3/i3blocks/gpu-load | 67 +++++++++++++++++++++++++ i3/i3blocks/load_average | 34 +++++++++++++ 5 files changed, 230 insertions(+), 9 deletions(-) create mode 100755 i3/i3blocks/bandwidth create mode 100755 i3/i3blocks/cpu_usage create mode 100755 i3/i3blocks/gpu-load create mode 100755 i3/i3blocks/load_average diff --git a/i3/i3blocks.conf b/i3/i3blocks.conf index a4b6f19..634fb69 100644 --- a/i3/i3blocks.conf +++ b/i3/i3blocks.conf @@ -29,21 +29,37 @@ command=~/bin/i3blocks/$BLOCK_NAME separator_block_width=15 markup=pango -[disk] -interval=60 -command=~/bin/i3blocks/disk / +[gpu-load] +interval=15 +label=⎚ -[disk] -interval=60 -command=~/bin/i3blocks/disk /home 🏠 +[load_average] +interval=15 +label=⨏ + +[cpu_usage] +interval=persist +label=💻 + +[cpu] +interval=15 +label=🌡 [memory] interval=30 label=🧠 -[cpu] -interval=15 -label=💻 +[bandwidth] +interval=persist +#label= + +#[disk] +#interval=60 +#command=~/bin/i3blocks/disk / + +#[disk] +#interval=60 +#command=~/bin/i3blocks/disk /home 🏠 [clock] label=📅 diff --git a/i3/i3blocks/bandwidth b/i3/i3blocks/bandwidth new file mode 100755 index 0000000..26bb904 --- /dev/null +++ b/i3/i3blocks/bandwidth @@ -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 \" %%-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); + } +} +' diff --git a/i3/i3blocks/cpu_usage b/i3/i3blocks/cpu_usage new file mode 100755 index 0000000000000000000000000000000000000000..60b9c824efeb5b80088f63cbdf1f9007e6e52c45 GIT binary patch literal 26608 zcmeHweRx#Wo&ULWGm{w-CU3+9C@?~zpym~jfPj;b;6x(^2pR+&hnYz-buyFA3vaE3 z8nuj+7F=!7?N6xBvz4chwsd!YtE+B>`fmH%s?|zg)*ri%wuxG$xGJlw+0Xaf^SyIt zNZkH@f9$i*vpI0@_x*dm=jGme=G=2nc6W5GwrQH+q>Gh;sACld$EyUVZ%_z;SG0&C zoNL59;Q(DAd4}9;07#8AV9SM0#n%DJ?x>RI!!Ia3h8!V5vYRlul!RfaL6e=GP(|m% zaG{~ckmY869z!nj;7Jt>L#rLt%}AYLH?krZ9#iFhPC>RKlI+eZyR*uU;VB9Ti6Pe~ zg+a$t%3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+W#*~BUn5-G4?VN|9)baKawR~YnlgwR$s6^ z|IT9Qu_^=S=ODA2fLQJM_ZY+cVO+j_JM2Hiw+Ea*e~-a%zRHNlSNxpk{An3Go(5+8 z{JjRlQso${mt;M$J=Pn@L^CdU)R^|Px{VUUlDrDbBjt1*eOtlt^Y2B5ml*EM@geIm zya{spR)cB&UCGd^?DOMSY_SUn)hXK_Cq*QNrw!7~KfnC9LQeK=N{_!kVaVUBP_@vI zC*S^?;8C5ZY-#XfBn9(-VNqVzlmTJ2_b5At96#ISxfgfk+4J~_VTT!*;eqYh-@SSE z{5zTSRNbz(13l9iN9(gu8mqH0}{W0q(kQ{ruASo%>Wl-ihKmWgj#A?sK z-x<od*p=di&j*|g_<&QI5ow{y$Ob_`EKhnk44 zK}tMtz<+Pzl!~95k?pu0{~0!)aU&}#m~T&X zUKL5rQ_8+q. + +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 ] [-c ]\n"; + print "-w : warning threshold to become amber\n"; + print "-c : 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 () { + 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; diff --git a/i3/i3blocks/load_average b/i3/i3blocks/load_average new file mode 100755 index 0000000..37a5c71 --- /dev/null +++ b/i3/i3blocks/load_average @@ -0,0 +1,34 @@ +#!/bin/sh +# Copyright (C) 2014 Julien Bonjean + +# 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 . + +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; + } + } +'