commit 1b07bd80f91b198b5ce183429fba25d3449f0c7c
parent 9421b70c0f053404e6ed0dcebb887ef54c989407
Author: Shimmy Xu <shimmy.xu@shimmy1996.com>
Date: Sat, 19 Jan 2019 18:42:46 -0500
Add settings for i3blocks.
Diffstat:
7 files changed, 249 insertions(+), 0 deletions(-)
diff --git a/.config/i3blocks/config b/.config/i3blocks/config
@@ -0,0 +1,52 @@
+# i3blocks config file
+#
+# Please see man i3blocks for a complete reference!
+# The man page is also hosted at http://vivien.github.io/i3blocks
+#
+# List of valid properties:
+#
+# align
+# color
+# command
+# full_text
+# instance
+# interval
+# label
+# min_width
+# name
+# separator
+# separator_block_width
+# short_text
+# signal
+# urgent
+
+# Global properties
+#
+# The top properties below are applied to every block, but can be overridden.
+# Each block command defaults to the script name to avoid boilerplate.
+# Change $SCRIPT_DIR to the location of your scripts!
+command=~/.local/bin/i3blocks/$BLOCK_NAME
+separator_block_width=15
+markup=none
+
+[ssid]
+label=NWK:
+interval=5
+
+[volume]
+label=VOL:
+interval=once
+signal=10
+
+[backlight]
+label=BKL:
+interval=once
+signal=11
+
+[battery]
+label=BAT:
+interval=30
+
+[time]
+command=date '+%Y-%m-%d %H:%M:%S'
+interval=1
diff --git a/.gitignore b/.gitignore
@@ -10,6 +10,8 @@
!.config/alacritty/*
!.config/gtk-3.0
!.config/gtk-3.0/*
+!.config/i3blocks
+!.config/i3blocks/*
!.config/sway
!.config/sway/*
!.config/mako
@@ -21,5 +23,6 @@
!.local
!.local/bin
!.local/bin/*
+!.local/bin/i3blocks/*
!.profile
!.zprofile
\ No newline at end of file
diff --git a/.local/bin/i3blocks/backlight b/.local/bin/i3blocks/backlight
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+BACKLIGHT_LEVEL=$(xbacklight -get)
+
+echo "$LABEL$BACKLIGHT_LEVEL"
diff --git a/.local/bin/i3blocks/battery b/.local/bin/i3blocks/battery
@@ -0,0 +1,94 @@
+#!/usr/bin/perl
+#
+# Copyright 2014 Pierre Mavro <deimos@deimos.fr>
+# Copyright 2014 Vivien Didelot <vivien@didelot.org>
+#
+# Licensed under the terms of the GNU GPL v3, or any later version.
+#
+# This script is meant to use with i3blocks. It parses the output of the "acpi"
+# command (often provided by a package of the same name) to read the status of
+# the battery, and eventually its remaining time (to full charge or discharge).
+#
+# The color will gradually change for a percentage below 85%, and the urgency
+# (exit code 33) is set if there is less that 5% remaining.
+
+use strict;
+use warnings;
+use utf8;
+
+my $acpi;
+my $status;
+my $percent;
+my $ac_adapt;
+my $full_text;
+my $short_text;
+my $bat_number = $ENV{BAT_NUMBER} || 0;
+my $label = $ENV{LABEL} || "";
+
+# read the first line of the "acpi" command output
+open (ACPI, "acpi -b 2>/dev/null| grep 'Battery $bat_number' |") or die;
+$acpi = <ACPI>;
+close(ACPI);
+
+# fail on unexpected output
+if (not defined($acpi)) {
+ # don't print anything to stderr if there is no battery
+ exit(0);
+}
+elsif ($acpi !~ /: ([\w\s]+), (\d+)%/) {
+ die "$acpi\n";
+}
+
+$status = $1;
+$percent = $2;
+$full_text = "$label$percent%";
+
+if ($status eq 'Discharging') {
+ $full_text .= ' DIS';
+} elsif ($status eq 'Charging') {
+ $full_text .= ' CHR';
+} elsif ($status eq 'Unknown') {
+ open (AC_ADAPTER, "acpi -a |") or die;
+ $ac_adapt = <AC_ADAPTER>;
+ close(AC_ADAPTER);
+
+ if ($ac_adapt =~ /: ([\w-]+)/) {
+ $ac_adapt = $1;
+
+ if ($ac_adapt eq 'on-line') {
+ $full_text .= ' CHR';
+ } elsif ($ac_adapt eq 'off-line') {
+ $full_text .= ' DIS';
+ }
+ }
+}
+
+$short_text = $full_text;
+
+if ($acpi =~ /(\d\d:\d\d):/) {
+ $full_text .= " ($1)";
+}
+
+# print text
+print "$full_text\n";
+print "$short_text\n";
+
+# consider color and urgent flag only on discharge
+if ($status eq 'Discharging') {
+
+ if ($percent < 20) {
+ print "#FF0000\n";
+ } elsif ($percent < 40) {
+ print "#FFAE00\n";
+ } elsif ($percent < 60) {
+ print "#FFF600\n";
+ } elsif ($percent < 85) {
+ print "#A8FF00\n";
+ }
+
+ if ($percent < 5) {
+ exit(33);
+ }
+}
+
+exit(0);
diff --git a/.local/bin/i3blocks/ssid b/.local/bin/i3blocks/ssid
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+
+SSID_NAME=$(/sbin/iwgetid -r)
+
+if [[ "${SSID_NAME}" != "" ]]; then
+ echo "${SSID_NAME}"
+else
+ echo "NONE"
+fi
diff --git a/.local/bin/i3blocks/volume b/.local/bin/i3blocks/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/README.org b/README.org
@@ -5,6 +5,9 @@ An archive of core configuration files for the fabled Bipedal Inter-Galactic Mas
* Functional Dependencies
Missing those may cause system to behave funny.
+| =i3blocks= |
+| =acpi= |
+| =alsa-utils= |
| =alacritty= |
| =pass= |
| =rofi-pass= |