diff options
Diffstat (limited to '.config/i3blocks')
| -rw-r--r-- | .config/i3blocks/config | 111 | ||||
| m--------- | .config/i3blocks/i3blocks-cmus | 0 | ||||
| -rwxr-xr-x | .config/i3blocks/scripts/arch-update.py | 5 | ||||
| -rwxr-xr-x | .config/i3blocks/scripts/bandwidth | 113 | ||||
| -rwxr-xr-x | .config/i3blocks/scripts/cpu_usage | 62 | ||||
| -rwxr-xr-x | .config/i3blocks/scripts/disk | 48 | ||||
| -rwxr-xr-x | .config/i3blocks/scripts/disk-io | 2 | ||||
| -rwxr-xr-x | .config/i3blocks/scripts/i3blocks-cmus | bin | 0 -> 2557784 bytes | |||
| m--------- | .config/i3blocks/scripts/i3blocks-contrib | 0 | ||||
| -rwxr-xr-x | .config/i3blocks/scripts/iface | 70 | ||||
| -rwxr-xr-x | .config/i3blocks/scripts/keyindicator | 89 | ||||
| -rwxr-xr-x | .config/i3blocks/scripts/load_average | 34 | ||||
| -rw-r--r-- | .config/i3blocks/scripts/mediaplayer | bin | 4693 -> 3124880 bytes | |||
| -rwxr-xr-x | .config/i3blocks/scripts/memory | 69 | ||||
| -rwxr-xr-x | .config/i3blocks/scripts/myCalendar | 2 | ||||
| -rwxr-xr-x | .config/i3blocks/scripts/temperature | 69 | ||||
| -rwxr-xr-x | .config/i3blocks/scripts/volume | 83 | ||||
| -rwxr-xr-x | .config/i3blocks/scripts/wifi | 53 |
18 files changed, 749 insertions, 61 deletions
diff --git a/.config/i3blocks/config b/.config/i3blocks/config index a8001dd..fff8dd6 100644 --- a/.config/i3blocks/config +++ b/.config/i3blocks/config @@ -24,22 +24,22 @@ # # The top properties below are applied to every block, but can be overridden. # Each block command defaults to the script name to avoid boilerplate. -command=/usr/lib/i3blocks/$BLOCK_NAME +command=~/.config/i3blocks/scripts/$BLOCK_NAME separator_block_width=15 markup=none - [arch-update] -command=python ~/.config/i3blocks/scripts/arch-update.py #run arch-update.py -h for options +command=~/.config/i3blocks/scripts/arch-update.py #run arch-update.py -h for options interval=3600 markup=pango +color=#006DA3 -[mediaplayer] -command=perl ~/.config/i3blocks/scripts/mediaplayer -instance=cmus +# This displays "ARTIST - SONG" if a music is playing. +# I rewrote this in rust because the old perl script was giving me issues +[i3blocks-cmus] interval=5 -signal=10 -label=♪ +#signal=10 + # Memory usage # @@ -67,18 +67,19 @@ interval=30 separator=false [disk-io] -label= -command=~/.config/i3blocks/scripts/disk-io +label= +command=~/.config/i3blocks/scripts/disk-io -w 2 +#command=$SCRIPT_DIR/disk-io -w 3 -M -P 0 interval=persist -#markup=pango - +markup=pango +instance=/sda/ # Network interface monitoring # # If the instance is not specified, use the interface used for default route. # The address can be forced to IPv4 or IPv6 with -4 or -6 switches. [iface] #instance=wlan0 -color=#00FF00 +color=#00ffff interval=10 separator=false @@ -101,6 +102,12 @@ interval=10 #min_width=CPU: 100.00% separator=false +[load_average] +interval=10 +separator=false +label=AVG + +# # Temperature # # Support multiple chips, though lm-sensors. @@ -109,29 +116,18 @@ separator=false [temperature] label=TEMP interval=10 -separator=false - -[load_average] -interval=10 -# Battery indicator -# -# The battery instance defaults to 0. -#[battery] -#label=BAT -#label=⚡ -#instance=1 -#interval=30 -#separator=false +[volume] +#label=VOL +label=♪ +instance=Master +#instance=PCM +interval=once +signal=10 -#[brightness] -#command=~/.config/i3blocks/brightness.py -#label=☀ -#interval=once -#signal=12 # Key indicators -#🎧 +# # Add the following bindings to i3 config file: # # bindsym --release Caps_Lock exec pkill -SIGRTMIN+11 i3blocks @@ -140,11 +136,34 @@ interval=10 instance=CAPS interval=once signal=11 - +markup=pango +# [keyindicator] instance=NUM interval=once signal=11 +markup=pango + +#[brightness] +#command=~/.config/i3blocks/scripts/brightness.py +#label= +#☀️ +#interval=once +#signal=12 + +# Battery indicator +# +# The battery instance defaults to 0. +#[battery] +#command=~/.config/i3blocks/scripts/batterybar +#label=BAT +#markup=pango +#label= BAT +#🔋 +#⚡ +#instance=1 +#interval=30 +#separator=false # Volume indicator # @@ -152,36 +171,15 @@ signal=11 # The second parameter overrides the mixer selection # See the script for details. -[volume] -#label=VOL -label=VOL -instance=Master -#instance=PCM -interval=once -signal=10 - # Date Time # -#[calendar] -#command=~/.config/i3blocks/scripts/calendar -#label= -#interval=3600 - [time] -command=~/.config/i3blocks/scripts/myCalendar -f '+%a %Y-%m-%d %H:%M:%S' label= -#command=date '+%a %Y-%m-%d %H:%M:%S' +command=~/.config/i3blocks/scripts/myCalendar -f '+%a %Y-%m-%d %H:%M:%S' interval=1 -# Generic media player support -# -# This displays "ARTIST - SONG" if a music is playing. -# Supported players are: spotify, vlc, audacious, xmms2, mplayer, and others. -#[mediaplayer] -#instance=spotify -#interval=5 -#signal=10 + # OpenVPN support # @@ -190,4 +188,3 @@ interval=1 #interval=20 - diff --git a/.config/i3blocks/i3blocks-cmus b/.config/i3blocks/i3blocks-cmus new file mode 160000 +Subproject c6969fcea8f09152ea4d1844f7ac11243618d24 diff --git a/.config/i3blocks/scripts/arch-update.py b/.config/i3blocks/scripts/arch-update.py index 7a7be68..7dc5d62 100755 --- a/.config/i3blocks/scripts/arch-update.py +++ b/.config/i3blocks/scripts/arch-update.py @@ -8,7 +8,6 @@ import subprocess from subprocess import check_output import argparse import re -import os def create_argparse(): @@ -104,6 +103,7 @@ if update_count > 0: info += ' [{0}]'.format(', '.join(matches)) print(message.format(args.updates_available_color, info)) + import os if 'BLOCK_BUTTON' in os.environ: button = os.environ['BLOCK_BUTTON'] if button is not '': @@ -112,6 +112,5 @@ if update_count > 0: subprocess.call("termite -e 'sudo pacman -Syu' --hold", shell=True) - elif not args.quiet: - print(message.format(args.base_color, '-Syu ')) + print(message.format(args.base_color, '-Syu ')) diff --git a/.config/i3blocks/scripts/bandwidth b/.config/i3blocks/scripts/bandwidth new file mode 100755 index 0000000..6a93c35 --- /dev/null +++ b/.config/i3blocks/scripts/bandwidth @@ -0,0 +1,113 @@ +#!/bin/bash +# Copyright (C) 2012 Stefan Breunig <stefan+measure-net-speed@mathphys.fsk.uni-heidelberg.de> +# Copyright (C) 2014 kaueraal +# Copyright (C) 2015 Thiago Perrotta <perrotta dot thiago at poli dot ufrj dot br> + +# 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/>. + +# Get custom IN and OUT labels if provided by command line arguments +while [[ $# -gt 1 ]]; do + key="$1" + case "$key" in + -i|--inlabel) + INLABEL="$2" + shift;; + -o|--outlabel) + OUTLABEL="$2" + shift;; + esac + shift +done + +[[ -z "$INLABEL" ]] && INLABEL="IN " +[[ -z "$OUTLABEL" ]] && OUTLABEL="OUT " + +# Use the provided interface, otherwise the device used for the default route. +if [[ -z $INTERFACE ]] && [[ -n $BLOCK_INSTANCE ]]; then + INTERFACE=$BLOCK_INSTANCE +elif [[ -z $INTERFACE ]]; then + INTERFACE=$(ip route | awk '/^default/ { print $5 ; exit }') +fi + +# Exit if there is no default route +[[ -z "$INTERFACE" ]] && exit + +# Issue #36 compliant. +if ! [ -e "/sys/class/net/${INTERFACE}/operstate" ] || \ + (! [ "$TREAT_UNKNOWN_AS_UP" = "1" ] && + ! [ "`cat /sys/class/net/${INTERFACE}/operstate`" = "up" ]) +then + echo "$INTERFACE down" + echo "$INTERFACE down" + echo "#FF0000" + exit 0 +fi + +# path to store the old results in +path="/dev/shm/$(basename $0)-${INTERFACE}" + +# grabbing data for each adapter. +read rx < "/sys/class/net/${INTERFACE}/statistics/rx_bytes" +read tx < "/sys/class/net/${INTERFACE}/statistics/tx_bytes" + +# get time +time=$(date +%s) + +# write current data if file does not exist. Do not exit, this will cause +# problems if this file is sourced instead of executed as another process. +if ! [[ -f "${path}" ]]; then + echo "${time} ${rx} ${tx}" > "${path}" + chmod 0666 "${path}" +fi + + +# read previous state and update data storage +read old < "${path}" +echo "${time} ${rx} ${tx}" > "${path}" + +# parse old data and calc time passed +old=(${old//;/ }) +time_diff=$(( $time - ${old[0]} )) + +# sanity check: has a positive amount of time passed +[[ "${time_diff}" -gt 0 ]] || exit + +# calc bytes transferred, and their rate in byte/s +rx_diff=$(( $rx - ${old[1]} )) +tx_diff=$(( $tx - ${old[2]} )) +rx_rate=$(( $rx_diff / $time_diff )) +tx_rate=$(( $tx_diff / $time_diff )) + +# shift by 10 bytes to get KiB/s. If the value is larger than +# 1024^2 = 1048576, then display MiB/s instead + +# incoming +echo -n "$INLABEL" +rx_kib=$(( $rx_rate >> 10 )) +if hash bc 2>/dev/null && [[ "$rx_rate" -gt 1048576 ]]; then + printf '%sM' "`echo "scale=1; $rx_kib / 1024" | bc`" +else + echo -n "${rx_kib}K" +fi + +echo -n " " + +# outgoing +echo -n "$OUTLABEL" +tx_kib=$(( $tx_rate >> 10 )) +if hash bc 2>/dev/null && [[ "$tx_rate" -gt 1048576 ]]; then + printf '%sM\n' "`echo "scale=1; $tx_kib / 1024" | bc`" +else + echo "${tx_kib}K" +fi diff --git a/.config/i3blocks/scripts/cpu_usage b/.config/i3blocks/scripts/cpu_usage new file mode 100755 index 0000000..44c1189 --- /dev/null +++ b/.config/i3blocks/scripts/cpu_usage @@ -0,0 +1,62 @@ +#!/usr/bin/perl +# +# Copyright 2014 Pierre Mavro <deimos@deimos.fr> +# Copyright 2014 Vivien Didelot <vivien@didelot.org> +# Copyright 2014 Andreas Guldstrand <andreas.guldstrand@gmail.com> +# +# Licensed under the terms of the GNU GPL v3, or any later version. + +use strict; +use warnings; +use utf8; +use Getopt::Long; + +# default values +my $t_warn = $ENV{T_WARN} // 50; +my $t_crit = $ENV{T_CRIT} // 80; +my $cpu_usage = -1; +my $decimals = $ENV{DECIMALS} // 2; +my $label = $ENV{LABEL} // ""; + +sub help { + print "Usage: cpu_usage [-w <warning>] [-c <critical>] [-d <decimals>]\n"; + print "-w <percent>: warning threshold to become yellow\n"; + print "-c <percent>: critical threshold to become red\n"; + print "-d <decimals>: Use <decimals> decimals for percentage (default is $decimals) \n"; + exit 0; +} + +GetOptions("help|h" => \&help, + "w=i" => \$t_warn, + "c=i" => \$t_crit, + "d=i" => \$decimals, +); + +# Get CPU usage +$ENV{LC_ALL}="en_US"; # if mpstat is not run under en_US locale, things may break, so make sure it is +open (MPSTAT, 'mpstat 1 1 |') or die; +while (<MPSTAT>) { + if (/^.*\s+(\d+\.\d+)[\s\x00]?$/) { + $cpu_usage = 100 - $1; # 100% - %idle + last; + } +} +close(MPSTAT); + +$cpu_usage eq -1 and die 'Can\'t find CPU information'; + +# Print short_text, full_text +print "${label}"; +printf "%.${decimals}f%%\n", $cpu_usage; +print "${label}"; +printf "%.${decimals}f%%\n", $cpu_usage; + +# Print color, if needed +if ($cpu_usage >= $t_crit) { + print "#FF0000\n"; + exit 33; +} elsif ($cpu_usage >= $t_warn) { + print "#FFFC00\n"; +} + +exit 0; diff --git a/.config/i3blocks/scripts/disk b/.config/i3blocks/scripts/disk new file mode 100755 index 0000000..c34240d --- /dev/null +++ b/.config/i3blocks/scripts/disk @@ -0,0 +1,48 @@ +#!/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/>. + +DIR="${DIR:-$BLOCK_INSTANCE}" +DIR="${DIR:-$HOME}" +ALERT_LOW="${ALERT_LOW:-$1}" +ALERT_LOW="${ALERT_LOW:-10}" # color will turn red under this value (default: 10%) + +LOCAL_FLAG="-l" +if [ "$1" = "-n" ] || [ "$2" = "-n" ]; then + LOCAL_FLAG="" +fi + +df -h -P $LOCAL_FLAG "$DIR" | awk -v label="$LABEL" -v alert_low=$ALERT_LOW ' +/\/.*/ { + # full text + print label $4 + + # short text + print label $4 + + use=$5 + + # no need to continue parsing + exit 0 +} + +END { + gsub(/%$/,"",use) + if (100 - use < alert_low) { + # color + print "#FF0000" + } +} +' diff --git a/.config/i3blocks/scripts/disk-io b/.config/i3blocks/scripts/disk-io index 6e89bef..b6bebc2 100755 --- a/.config/i3blocks/scripts/disk-io +++ b/.config/i3blocks/scripts/disk-io @@ -5,7 +5,7 @@ # # i3blocks blocklet script to monitor disk io -label="${PREFIX:-""}" +label="${LABEL:-""}" dt="${DT:-5}" MB_only="${MB_ONLY:-0}" kB_only="${KB_ONLY:-0}" diff --git a/.config/i3blocks/scripts/i3blocks-cmus b/.config/i3blocks/scripts/i3blocks-cmus Binary files differnew file mode 100755 index 0000000..bd90f14 --- /dev/null +++ b/.config/i3blocks/scripts/i3blocks-cmus diff --git a/.config/i3blocks/scripts/i3blocks-contrib b/.config/i3blocks/scripts/i3blocks-contrib new file mode 160000 +Subproject 21708edc3d12c1f37285e3e9363f6541be72359 diff --git a/.config/i3blocks/scripts/iface b/.config/i3blocks/scripts/iface new file mode 100755 index 0000000..75baa94 --- /dev/null +++ b/.config/i3blocks/scripts/iface @@ -0,0 +1,70 @@ +#!/bin/bash +# Copyright (C) 2014 Julien Bonjean <julien@bonjean.info> +# Copyright (C) 2014 Alexander Keller <github@nycroth.com> + +# 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 the provided interface, otherwise the device used for the default route. +IF="${IFACE:-$BLOCK_INSTANCE}" +IF="${IF:-$(ip route | awk '/^default/ { print $5 ; exit }')}" + +# Exit if there is no default route +[[ -z "$IF" ]] && exit + +#------------------------------------------------------------------------ + +# As per #36 -- It is transparent: e.g. if the machine has no battery or wireless +# connection (think desktop), the corresponding block should not be displayed. +[[ ! -d /sys/class/net/${IF} ]] && exit + +#------------------------------------------------------------------------ + +AF=${ADDRESS_FAMILY:-inet6?} +LABEL="${LABEL:-}" + +for flag in "$1" "$2"; do + case "$flag" in + -4) + AF=inet ;; + -6) + AF=inet6 ;; + -L) + if [[ "$IF" = "" ]]; then + LABEL="iface " + else + LABEL="$IF: " + fi ;; + esac +done + +if [[ "$IF" = "" ]] || [[ "$(cat /sys/class/net/$IF/operstate)" = 'down' ]]; then + echo "${LABEL}down" # full text + echo "${LABEL}down" # short text + echo \#FF0000 # color + exit +fi + +# if no interface is found, use the first device with a global scope +IPADDR=$(ip addr show $IF | perl -n -e "/$AF ([^ \/]+).* scope global/ && print \$1 and exit") + +case $BLOCK_BUTTON in + 3) echo -n "$IPADDR" | xclip -q -se c ;; +esac + +#------------------------------------------------------------------------ + +echo "$LABEL$IPADDR" # full text +echo "$LABEL$IPADDR" # short text diff --git a/.config/i3blocks/scripts/keyindicator b/.config/i3blocks/scripts/keyindicator new file mode 100755 index 0000000..50c3a3f --- /dev/null +++ b/.config/i3blocks/scripts/keyindicator @@ -0,0 +1,89 @@ +#!/usr/bin/env perl +# +# Copyright 2014 Marcelo Cerri <mhcerri at gmail dot com> +# +# 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; +use File::Basename; + +# Default values +my $indicator = $ENV{BLOCK_INSTANCE} || $ENV{KEY} || "CAPS"; +my $color_on = $ENV{COLOR_ON} || "#00FF00"; +my $color_off = $ENV{COLOR_OFF} || "#222222"; +my $bg_color_on = $ENV{BG_COLOR_ON}; +my $bg_color_off = $ENV{BG_COLOR_OFF}; +my $hide = $ENV{HIDE_WHEN_OFF} || 0; + +sub help { + my $program = basename($0); + printf "Usage: %s [-c <color on>] [-C <color off>] [-b <bg color on>] [-B <bg color off>] [--hide]\n", $program; + printf " -c <color on>: hex color to use when indicator is on\n"; + printf " -C <color off>: hex color to use when indicator is off\n"; + printf " -b <background color on>: hex color to use when indicator is on\n"; + printf " -B <background color off>: hex color to use when indicator is off\n"; + printf " --hide: don't output anything when indicator is off\n"; + printf "\n"; + printf "Note: environment variable \$BLOCK_INSTANCE should be one of:\n"; + printf " CAPS, NUM (default is CAPS).\n"; + exit 0; +} + +Getopt::Long::config qw(no_ignore_case); +GetOptions("help|h" => \&help, + "c=s" => \$color_on, + "C=s" => \$color_off, + "b=s" => \$bg_color_on, + "B=s" => \$bg_color_off, + "hide" => \$hide) or exit 1; + +# Key mapping +my %indicators = ( + CAPS => 0x00000001, + NUM => 0x00000002, +); + +# Retrieve key flags +my $mask = 0; +open(XSET, "xset -q |") or die; +while (<XSET>) { + if (/LED mask:\s*([0-9a-f]+)/) { + $mask = hex $1; + last; + } +} +close(XSET); + +# Determine if indicator is on or off +my $indicator_status = ($indicators{$indicator} || 0) & $mask; + +# Exit if --hide and indicator is off +if ($hide and !$indicator_status) { + exit 0 +} + +# Output +my $fg_color = $indicator_status ? $color_on : $color_off; +my $bg_color = $indicator_status ? $bg_color_on : $bg_color_off; + +if (defined $bg_color) { + printf "<span color='%s' bgcolor='%s'>%s</span>\n", $fg_color, $bg_color, $indicator; +} else { + printf "<span color='%s'>%s</span>\n", $fg_color, $indicator; +} + +exit 0 diff --git a/.config/i3blocks/scripts/load_average b/.config/i3blocks/scripts/load_average new file mode 100755 index 0000000..37a5c71 --- /dev/null +++ b/.config/i3blocks/scripts/load_average @@ -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; + } + } +' diff --git a/.config/i3blocks/scripts/mediaplayer b/.config/i3blocks/scripts/mediaplayer Binary files differindex 718e335..dede5fd 100644 --- a/.config/i3blocks/scripts/mediaplayer +++ b/.config/i3blocks/scripts/mediaplayer diff --git a/.config/i3blocks/scripts/memory b/.config/i3blocks/scripts/memory new file mode 100755 index 0000000..90eb2c6 --- /dev/null +++ b/.config/i3blocks/scripts/memory @@ -0,0 +1,69 @@ +#!/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/>. + +TYPE="${BLOCK_INSTANCE:-mem}" + +awk -v type=$TYPE ' +/^MemTotal:/ { + mem_total=$2 +} +/^MemFree:/ { + mem_free=$2 +} +/^Buffers:/ { + mem_free+=$2 +} +/^Cached:/ { + mem_free+=$2 +} +/^SwapTotal:/ { + swap_total=$2 +} +/^SwapFree:/ { + swap_free=$2 +} +END { + if (type == "swap") { + free=swap_free/1024/1024 + used=(swap_total-swap_free)/1024/1024 + total=swap_total/1024/1024 + } else { + free=mem_free/1024/1024 + used=(mem_total-mem_free)/1024/1024 + total=mem_total/1024/1024 + } + + pct=0 + if (total > 0) { + pct=used/total*100 + } + + # full text + printf("%.1fG/%.1fG (%.f%%)\n", used, total, pct) + + # short text + printf("%.f%%\n", pct) + + # color + if (pct > 90) { + print("#FF0000") + } else if (pct > 80) { + print("#FFAE00") + } else if (pct > 70) { + print("#FFF600") + } +} +' /proc/meminfo diff --git a/.config/i3blocks/scripts/myCalendar b/.config/i3blocks/scripts/myCalendar index 686fd00..d1557ba 100755 --- a/.config/i3blocks/scripts/myCalendar +++ b/.config/i3blocks/scripts/myCalendar @@ -1,4 +1,6 @@ #!/bin/bash +# this is a simple bash script / blocklet for i3blocks +# that will open a new termite instance with 'cal' when clicked datefmt='+%a %Y-%m-%d %H:%M:%S' diff --git a/.config/i3blocks/scripts/temperature b/.config/i3blocks/scripts/temperature new file mode 100755 index 0000000..2170f10 --- /dev/null +++ b/.config/i3blocks/scripts/temperature @@ -0,0 +1,69 @@ +#!/usr/bin/env perl +# Copyright 2014 Pierre Mavro <deimos@deimos.fr> +# Copyright 2014 Vivien Didelot <vivien@didelot.org> +# Copyright 2014 Andreas Guldstrand <andreas.guldstrand@gmail.com> +# Copyright 2014 Benjamin Chretien <chretien at lirmm dot fr> + +# 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; + +binmode(STDOUT, ":utf8"); + +# default values +my $t_warn = $ENV{T_WARN} || 70; +my $t_crit = $ENV{T_CRIT} || 90; +my $chip = $ENV{SENSOR_CHIP} || ""; +my $temperature = -9999; + +sub help { + print "Usage: temperature [-w <warning>] [-c <critical>] [--chip <chip>]\n"; + print "-w <percent>: warning threshold to become yellow\n"; + print "-c <percent>: critical threshold to become red\n"; + print "--chip <chip>: sensor chip\n"; + exit 0; +} + +GetOptions("help|h" => \&help, + "w=i" => \$t_warn, + "c=i" => \$t_crit, + "chip=s" => \$chip); + +# Get chip temperature +open (SENSORS, "sensors -u $chip |") or die; +while (<SENSORS>) { + if (/^\s+temp1_input:\s+[\+]*([\-]*\d+\.\d)/) { + $temperature = $1; + last; + } +} +close(SENSORS); + +$temperature eq -9999 and die 'Cannot find temperature'; + +# Print short_text, full_text +print "$temperature°C\n" x2; + +# Print color, if needed +if ($temperature >= $t_crit) { + print "#FF0000\n"; + exit 33; +} elsif ($temperature >= $t_warn) { + print "#FFFC00\n"; +} + +exit 0; diff --git a/.config/i3blocks/scripts/volume b/.config/i3blocks/scripts/volume new file mode 100755 index 0000000..6e0c4fe --- /dev/null +++ b/.config/i3blocks/scripts/volume @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +# Copyright (C) 2014 Julien Bonjean <julien@bonjean.info> +# Copyright (C) 2014 Alexander Keller <github@nycroth.com> + +# 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/>. + +#------------------------------------------------------------------------ + +# The second parameter overrides the mixer selection +# For PulseAudio users, eventually use "pulse" +# For Jack/Jack2 users, use "jackplug" +# For ALSA users, you may use "default" for your primary card +# or you may use hw:# where # is the number of the card desired +if [[ -z "$MIXER" ]] ; then + MIXER="default" + if command -v pulseaudio >/dev/null 2>&1 && pulseaudio --check ; then + # pulseaudio is running, but not all installations use "pulse" + if amixer -D pulse info >/dev/null 2>&1 ; then + MIXER="pulse" + fi + fi + [ -n "$(lsmod | grep jack)" ] && MIXER="jackplug" + MIXER="${2:-$MIXER}" +fi + +# The instance option sets the control to report and configure +# This defaults to the first control of your selected mixer +# For a list of the available, use `amixer -D $Your_Mixer scontrols` +if [[ -z "$SCONTROL" ]] ; then + SCONTROL="${BLOCK_INSTANCE:-$(amixer -D $MIXER scontrols | + sed -n "s/Simple mixer control '\([^']*\)',0/\1/p" | + head -n1 + )}" +fi + +# The first parameter sets the step to change the volume by (and units to display) +# This may be in in % or dB (eg. 5% or 3dB) +if [[ -z "$STEP" ]] ; then + STEP="${1:-5%}" +fi + +#------------------------------------------------------------------------ + +capability() { # Return "Capture" if the device is a capture device + amixer -D $MIXER get $SCONTROL | + sed -n "s/ Capabilities:.*cvolume.*/Capture/p" +} + +volume() { + amixer -D $MIXER get $SCONTROL $(capability) +} + +format() { + + perl_filter='if (/.*\[(\d+%)\] (\[(-?\d+.\d+dB)\] )?\[(on|off)\]/)' + perl_filter+='{CORE::say $4 eq "off" ? "MUTE" : "' + # If dB was selected, print that instead + perl_filter+=$([[ $STEP = *dB ]] && echo '$3' || echo '$1') + perl_filter+='"; exit}' + output=$(perl -ne "$perl_filter") + echo "$LABEL$output" +} + +#------------------------------------------------------------------------ + +case $BLOCK_BUTTON in + 3) amixer -q -D $MIXER sset $SCONTROL $(capability) toggle ;; # right click, mute/unmute + 4) amixer -q -D $MIXER sset $SCONTROL $(capability) ${STEP}+ unmute ;; # scroll up, increase + 5) amixer -q -D $MIXER sset $SCONTROL $(capability) ${STEP}- unmute ;; # scroll down, decrease +esac + +volume | format diff --git a/.config/i3blocks/scripts/wifi b/.config/i3blocks/scripts/wifi new file mode 100755 index 0000000..34b6348 --- /dev/null +++ b/.config/i3blocks/scripts/wifi @@ -0,0 +1,53 @@ +#!/bin/bash +# Copyright (C) 2014 Alexander Keller <github@nycroth.com> + +# 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/>. + +#------------------------------------------------------------------------ +if [[ -z "$INTERFACE" ]] ; then + INTERFACE="${BLOCK_INSTANCE:-wlan0}" +fi +#------------------------------------------------------------------------ + +# As per #36 -- It is transparent: e.g. if the machine has no battery or wireless +# connection (think desktop), the corresponding block should not be displayed. +[[ ! -d /sys/class/net/${INTERFACE}/wireless ]] && exit + +# If the wifi interface exists but no connection is active, "down" shall be displayed. +if [[ "$(cat /sys/class/net/$INTERFACE/operstate)" = 'down' ]]; then + echo "down" + echo "down" + echo "#FF0000" + exit +fi + +#------------------------------------------------------------------------ + +QUALITY=$(grep $INTERFACE /proc/net/wireless | awk '{ print int($3 * 100 / 70) }') + +#------------------------------------------------------------------------ + +echo $QUALITY% # full text +echo $QUALITY% # short text + +# color +if [[ $QUALITY -ge 80 ]]; then + echo "#00FF00" +elif [[ $QUALITY -ge 60 ]]; then + echo "#FFF600" +elif [[ $QUALITY -ge 40 ]]; then + echo "#FFAE00" +else + echo "#FF0000" +fi |
