Initial chezmoi commit
This commit is contained in:
167
dot_config/i3blocks/i3blocks-display.conf
Normal file
167
dot_config/i3blocks/i3blocks-display.conf
Normal file
@@ -0,0 +1,167 @@
|
||||
# properties {{{ #
|
||||
# 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
|
||||
# }}} properties #
|
||||
|
||||
# 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.
|
||||
align=center
|
||||
# command=/usr/share/i3blocks/$BLOCK_NAME
|
||||
command=~/linux-config/configs/i3blocks-scripts/$BLOCK_NAME
|
||||
separator=true
|
||||
separator_block_width=25
|
||||
markup=pango
|
||||
# }}} Global properties #
|
||||
|
||||
[time]
|
||||
label=
|
||||
command=date '+%H:%M.%a-%m-%d'
|
||||
interval=30
|
||||
color=#acc0cd
|
||||
|
||||
[spotify]
|
||||
command=python ~/linux-config/configs/i3blocks-scripts/spotify.py
|
||||
label=
|
||||
color=#999999
|
||||
interval=5
|
||||
|
||||
# [wifi]
|
||||
# label=
|
||||
# instance=wlp4s0
|
||||
# interval=10
|
||||
|
||||
# unbold this?
|
||||
# [load_average]
|
||||
# label=
|
||||
# interval=5
|
||||
# color=#990000
|
||||
|
||||
# [cpu_usage -w 50 -c 80]
|
||||
[cpu_usage]
|
||||
label=
|
||||
color=#990000
|
||||
interval=5
|
||||
|
||||
[memory]
|
||||
label=
|
||||
color=#3da061
|
||||
interval=5
|
||||
|
||||
[name]
|
||||
label=
|
||||
color=#1e5b99
|
||||
interval=6000
|
||||
|
||||
# unused blocks {{{ #
|
||||
# Volume indicator
|
||||
#
|
||||
# The first parameter sets the step (and units to display)
|
||||
# The second parameter overrides the mixer selection
|
||||
# See the script for details.
|
||||
# [volume]
|
||||
# label=VOL
|
||||
# #label=♪
|
||||
# instance=Master
|
||||
# #instance=PCM
|
||||
# interval=once
|
||||
# signal=10
|
||||
|
||||
# [memory]
|
||||
# label=SWAP
|
||||
# instance=swap
|
||||
# separator=false
|
||||
# interval=30
|
||||
|
||||
# Disk usage
|
||||
#
|
||||
# The directory defaults to $HOME if the instance is not specified.
|
||||
# The script may be called with a optional argument to set the alert
|
||||
# (defaults to 10 for 10%).
|
||||
# [disk]
|
||||
# label=HOME
|
||||
# #instance=/mnt/data
|
||||
# interval=30
|
||||
|
||||
# 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
|
||||
# interval=10
|
||||
# separator=false
|
||||
|
||||
# [bandwidth]
|
||||
# #instance=eth0
|
||||
# interval=5
|
||||
|
||||
# Battery indicator
|
||||
#
|
||||
# The battery instance defaults to 0.
|
||||
# [battery]
|
||||
# label=BAT
|
||||
# #label=⚡
|
||||
# #instance=1
|
||||
# interval=30
|
||||
|
||||
# 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
|
||||
#
|
||||
# Support multiple VPN, with colors.
|
||||
#[openvpn]
|
||||
#interval=20
|
||||
|
||||
# Temperature
|
||||
#
|
||||
# Support multiple chips, though lm-sensors.
|
||||
# The script may be called with -w and -c switches to specify thresholds,
|
||||
# see the script for details.
|
||||
#[temperature]
|
||||
#label=TEMP
|
||||
#interval=10
|
||||
|
||||
# Key indicators
|
||||
#
|
||||
# Add the following bindings to i3 config file:
|
||||
#
|
||||
# bindsym --release Caps_Lock exec pkill -SIGRTMIN+11 i3blocks
|
||||
# bindsym --release Num_Lock exec pkill -SIGRTMIN+11 i3blocks
|
||||
#[keyindicator]
|
||||
#instance=CAPS
|
||||
#interval=once
|
||||
#signal=11
|
||||
|
||||
#[keyindicator]
|
||||
#instance=NUM
|
||||
#interval=once
|
||||
#signal=11
|
||||
# }}} unused blocks #
|
||||
171
dot_config/i3blocks/i3blocks.conf
Normal file
171
dot_config/i3blocks/i3blocks.conf
Normal file
@@ -0,0 +1,171 @@
|
||||
# The top properties below are applied to every block, but can be overridden.
|
||||
# Each block command defaults to the script name to avoid boilerplate.
|
||||
align=center
|
||||
command=~/.config/i3blocks/scripts/$BLOCK_NAME
|
||||
separator=true
|
||||
separator_block_width=25
|
||||
markup=pango
|
||||
# color=#d1e7ff
|
||||
# color=#acc0cd
|
||||
color=#cbe4ff
|
||||
|
||||
# color=$foreground
|
||||
# color="${foreground}"
|
||||
# color="$(echo $foreground)"
|
||||
|
||||
# [time]
|
||||
# label=
|
||||
# # label=🕓
|
||||
# # command=date '+%H:%M.%a-%m-%d'
|
||||
# interval=30
|
||||
# # color=#acc0cd
|
||||
|
||||
[volume]
|
||||
interval=once
|
||||
signal=1
|
||||
interval=60
|
||||
|
||||
[calendar]
|
||||
interval=30
|
||||
label=
|
||||
DATEFMT=+%H:%M
|
||||
# SHORTFMT=+%H:%M:%S
|
||||
HEIGHT=180
|
||||
WIDTH=220
|
||||
|
||||
# unbold this?
|
||||
# [load_average]
|
||||
# label=
|
||||
# interval=5
|
||||
# color=#990000
|
||||
|
||||
[temperature]
|
||||
label=
|
||||
interval=5
|
||||
|
||||
# [cpu_usage -w 50 -c 80]
|
||||
[cpu_usage]
|
||||
label=
|
||||
# color=#990000
|
||||
interval=5
|
||||
|
||||
[memory]
|
||||
label=
|
||||
# color=#3da061
|
||||
interval=5
|
||||
|
||||
# [wifi]
|
||||
# label=
|
||||
# instance=wlp4s0
|
||||
# interval=10
|
||||
|
||||
[name]
|
||||
label=
|
||||
interval=30
|
||||
|
||||
# unused blocks {{{ #
|
||||
|
||||
# [memory]
|
||||
# label=SWAP
|
||||
# instance=swap
|
||||
# separator=false
|
||||
# interval=30
|
||||
|
||||
# Disk usage
|
||||
#
|
||||
# The directory defaults to $HOME if the instance is not specified.
|
||||
# The script may be called with a optional argument to set the alert
|
||||
# (defaults to 10 for 10%).
|
||||
# [disk]
|
||||
# label=HOME
|
||||
# #instance=/mnt/data
|
||||
# interval=30
|
||||
|
||||
# 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
|
||||
# interval=10
|
||||
# separator=false
|
||||
|
||||
# [bandwidth]
|
||||
# #instance=eth0
|
||||
# interval=5
|
||||
|
||||
# Battery indicator
|
||||
#
|
||||
# The battery instance defaults to 0.
|
||||
# [battery]
|
||||
# label=BAT
|
||||
# #label=⚡
|
||||
# #instance=1
|
||||
# interval=30
|
||||
|
||||
# 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
|
||||
#
|
||||
# Support multiple VPN, with colors.
|
||||
#[openvpn]
|
||||
#interval=20
|
||||
|
||||
# Temperature
|
||||
#
|
||||
# Support multiple chips, though lm-sensors.
|
||||
# The script may be called with -w and -c switches to specify thresholds,
|
||||
# see the script for details.
|
||||
#[temperature]
|
||||
#label=TEMP
|
||||
#interval=10
|
||||
|
||||
# Key indicators
|
||||
#
|
||||
# Add the following bindings to i3 config file:
|
||||
#
|
||||
# bindsym --release Caps_Lock exec pkill -SIGRTMIN+11 i3blocks
|
||||
# bindsym --release Num_Lock exec pkill -SIGRTMIN+11 i3blocks
|
||||
#[keyindicator]
|
||||
#instance=CAPS
|
||||
#interval=once
|
||||
#signal=11
|
||||
|
||||
#[keyindicator]
|
||||
#instance=NUM
|
||||
#interval=once
|
||||
#signal=11
|
||||
# }}} unused blocks #
|
||||
|
||||
# list of properties {{{ #
|
||||
# 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
|
||||
# }}} properties #
|
||||
|
||||
35
dot_config/i3blocks/sam-i3blocks.conf
Normal file
35
dot_config/i3blocks/sam-i3blocks.conf
Normal file
@@ -0,0 +1,35 @@
|
||||
# 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.
|
||||
align=center
|
||||
command=~/.config/i3blocks/scripts/$BLOCK_NAME
|
||||
separator=true
|
||||
separator_block_width=25
|
||||
markup=pango
|
||||
color=#cbe4ff
|
||||
# }}} Global properties #
|
||||
|
||||
[spotify]
|
||||
# command=python ~/linux-config/configs/i3blocks-scripts/spotify.py
|
||||
# label=
|
||||
label=
|
||||
# label=🎧
|
||||
# green
|
||||
# color=#198c19
|
||||
# aqua
|
||||
# color=#2d7272
|
||||
interval=5
|
||||
|
||||
[volume]
|
||||
interval=once
|
||||
signal=1
|
||||
interval=60
|
||||
|
||||
[calendar]
|
||||
interval=30
|
||||
label=
|
||||
DATEFMT=+%H:%M.%a-%m-%d
|
||||
# SHORTFMT=+%H:%M:%S
|
||||
HEIGHT=180
|
||||
WIDTH=220
|
||||
|
||||
9
dot_config/i3blocks/scripts/executable_backlight
Normal file
9
dot_config/i3blocks/scripts/executable_backlight
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
# https://askubuntu.com/a/179949/794515
|
||||
round()
|
||||
{
|
||||
echo $(printf %.$2f $(echo "scale=$2;(((10^$2)*$1)+0.5)/(10^$2)" | bc))
|
||||
};
|
||||
|
||||
cur_bl=$(xbacklight -get)
|
||||
echo "$(round "$cur_bl" 0)%"
|
||||
78
dot_config/i3blocks/scripts/executable_battery
Normal file
78
dot_config/i3blocks/scripts/executable_battery
Normal file
@@ -0,0 +1,78 @@
|
||||
#!/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 $full_text;
|
||||
my $short_text;
|
||||
my $bat_number = $ENV{BLOCK_INSTANCE} || 0;
|
||||
|
||||
# read the first line of the "acpi" command output
|
||||
open (ACPI, "acpi -b | grep 'Battery $bat_number' |") or die;
|
||||
$acpi = <ACPI>;
|
||||
close(ACPI);
|
||||
|
||||
# fail on unexpected output
|
||||
if ($acpi !~ /: (\w+), (\d+)%/) {
|
||||
die "$acpi\n";
|
||||
}
|
||||
|
||||
$status = $1;
|
||||
$percent = $2;
|
||||
$full_text = "$percent%";
|
||||
|
||||
if ($status eq 'Discharging') {
|
||||
$full_text .= ' DIS';
|
||||
} elsif ($status eq 'Charging') {
|
||||
$full_text .= ' CHR';
|
||||
}
|
||||
|
||||
$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";
|
||||
} else {
|
||||
print "#2c9332\n";
|
||||
}
|
||||
|
||||
if ($percent < 5) {
|
||||
exit(33);
|
||||
}
|
||||
} else {
|
||||
print "#2c9332\n";
|
||||
}
|
||||
|
||||
exit(0);
|
||||
42
dot_config/i3blocks/scripts/executable_calendar
Normal file
42
dot_config/i3blocks/scripts/executable_calendar
Normal file
@@ -0,0 +1,42 @@
|
||||
#! /bin/sh
|
||||
|
||||
WIDTH=${WIDTH:-200}
|
||||
HEIGHT=${HEIGHT:-200}
|
||||
DATEFMT=${DATEFMT:-"+%a %d.%m.%Y %H:%M:%S"}
|
||||
SHORTFMT=${SHORTFMT:-"+%H:%M:%S"}
|
||||
|
||||
OPTIND=1
|
||||
while getopts ":f:W:H:" opt; do
|
||||
case $opt in
|
||||
f) DATEFMT="$OPTARG" ;;
|
||||
W) WIDTH="$OPTARG" ;;
|
||||
H) HEIGHT="$OPTARG" ;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
exit 1
|
||||
;;
|
||||
:)
|
||||
echo "Option -$OPTARG requires an argument." >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
case "$BLOCK_BUTTON" in
|
||||
1|2|3)
|
||||
|
||||
# the position of the upper left corner of the popup
|
||||
posX=$(($BLOCK_X - $WIDTH / 2))
|
||||
posY=$(($BLOCK_Y - $HEIGHT))
|
||||
|
||||
i3-msg -q "exec yad --calendar \
|
||||
--width=$WIDTH --height=$HEIGHT \
|
||||
--undecorated --fixed \
|
||||
--close-on-unfocus --no-buttons \
|
||||
--posx=$posX --posy=$posY \
|
||||
> /dev/null"
|
||||
esac
|
||||
. "/home/kevin/.cache/wal/colors.sh"
|
||||
echo "$LABEL$(date "$DATEFMT")"
|
||||
echo "$LABEL$(date "$SHORTFMT")"
|
||||
echo "$color7"
|
||||
8
dot_config/i3blocks/scripts/executable_cpu_usage
Normal file
8
dot_config/i3blocks/scripts/executable_cpu_usage
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
. "/home/kevin/.cache/wal/colors.sh"
|
||||
|
||||
idle="$(mpstat 1 1 -P ALL | sed -n -e '4{p;q}' | awk '{print $NF}')"
|
||||
used=$(echo 100 - "$idle" | bc)
|
||||
used_rounded=$(printf %.0f "$used")
|
||||
printf "%s%%\n\n%s\n" "$used_rounded" "$color7"
|
||||
34
dot_config/i3blocks/scripts/executable_load_average
Normal file
34
dot_config/i3blocks/scripts/executable_load_average
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
'
|
||||
51
dot_config/i3blocks/scripts/executable_memory
Normal file
51
dot_config/i3blocks/scripts/executable_memory
Normal file
@@ -0,0 +1,51 @@
|
||||
#!/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}"
|
||||
. "/home/kevin/.cache/wal/colors.sh"
|
||||
|
||||
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 {
|
||||
# full text
|
||||
if (type == "swap")
|
||||
printf("%.1fG\n", (swap_total-swap_free)/1024/1024)
|
||||
else
|
||||
printf("%.1fG\n", (mem_total-mem_free)/1024/1024)
|
||||
|
||||
# TODO: short text
|
||||
|
||||
# TODO: color (if less than X%)
|
||||
}
|
||||
' /proc/meminfo
|
||||
printf "\n%s\n" "$color7"
|
||||
4
dot_config/i3blocks/scripts/executable_name
Normal file
4
dot_config/i3blocks/scripts/executable_name
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
. "/home/kevin/.cache/wal/colors.sh"
|
||||
printf "Kevin\n\n%s\n" "$color7"
|
||||
12
dot_config/i3blocks/scripts/executable_spotify
Normal file
12
dot_config/i3blocks/scripts/executable_spotify
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
case "$BLOCK_BUTTON" in
|
||||
1) dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause ;;
|
||||
2) dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous ;;
|
||||
3) dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next ;;
|
||||
esac
|
||||
|
||||
. "/home/kevin/.cache/wal/colors.sh"
|
||||
long_title=$(spotify-now -i '%artist - %title' -p '' -e '' | sed 's/&/&/g')
|
||||
short_title=$(spotify-now -i '%title' -p '' -e '' | sed 's/&/&/g')
|
||||
printf "$long_title\n$short_title\n%s\n" "$color7"
|
||||
7
dot_config/i3blocks/scripts/executable_temperature
Normal file
7
dot_config/i3blocks/scripts/executable_temperature
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
. "/home/kevin/.cache/wal/colors.sh"
|
||||
|
||||
temps="$(sensors | rg 'temp1:.*' | awk '{ print $2 }' | rg -o '\d{2}' | \
|
||||
sed 's/$/°C/' | tr '\n' ' ' | xargs)"
|
||||
printf "%s\n\n%s\n" "$temps" "$color7"
|
||||
6
dot_config/i3blocks/scripts/executable_time
Normal file
6
dot_config/i3blocks/scripts/executable_time
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
. "/home/kevin/.cache/wal/colors.sh"
|
||||
printf "$(date '+%H:%M.%a-%m-%d')\n\n%s\n" "$color7"
|
||||
# echo "<span foreground=\"%s\">$(date '+%H:%M.%a-%m-%d')%s</span>" "$color2"
|
||||
# printf "%s" "$color2"
|
||||
220
dot_config/i3blocks/scripts/executable_volume
Normal file
220
dot_config/i3blocks/scripts/executable_volume
Normal file
@@ -0,0 +1,220 @@
|
||||
#!/bin/bash
|
||||
# Displays the default device, volume, and mute status for i3blocks
|
||||
|
||||
# default vars {{{ #
|
||||
|
||||
set -a
|
||||
|
||||
SINK_SYMB=""
|
||||
|
||||
AUDIO_HIGH_SYMBOL=${AUDIO_HIGH_SYMBOL:-''}
|
||||
|
||||
AUDIO_MED_THRESH=${AUDIO_MED_THRESH:-50}
|
||||
AUDIO_MED_SYMBOL=${AUDIO_MED_SYMBOL:-''}
|
||||
|
||||
AUDIO_LOW_THRESH=${AUDIO_LOW_THRESH:-0}
|
||||
AUDIO_LOW_SYMBOL=${AUDIO_LOW_SYMBOL:-''}
|
||||
|
||||
AUDIO_MUTED_SYMBOL=${AUDIO_MUTED_SYMBOL:-''}
|
||||
|
||||
. "/home/kevin/.cache/wal/colors.sh"
|
||||
# DEFAULT_COLOR=${DEFAULT_COLOR:-"#ffffff"}
|
||||
DEFAULT_COLOR="$color7"
|
||||
MUTED_COLOR=${MUTED_COLOR:-"#a0a0a0"}
|
||||
|
||||
USE_ALSA_NAME=${USE_ALSA_NAME:-0}
|
||||
USE_DESCRIPTION=${USE_DESCRIPTION:-0}
|
||||
|
||||
SUBSCRIBE=${SUBSCRIBE:-0}
|
||||
|
||||
MIXER=${MIXER:-""}
|
||||
SCONTROL=${SCONTROL:-""}
|
||||
|
||||
# }}} default vars #
|
||||
|
||||
AUDIO_DELTA=${AUDIO_DELTA:-5}
|
||||
|
||||
# LONG_FORMAT=${LONG_FORMAT:-'${SYMB} ${VOL}% [${INDEX}:${NAME}]'}
|
||||
LONG_FORMAT=${SHORT_FORMAT:-'${SINK_SYMB} ${VOL}%'}
|
||||
# SHORT_FORMAT=${SHORT_FORMAT:-'${SYMB} ${VOL}%[${INDEX}]'}
|
||||
SHORT_FORMAT=${SHORT_FORMAT:-'${SINK_SYMB} ${VOL}%[${INDEX}]'}
|
||||
|
||||
# flags {{{ #
|
||||
|
||||
while getopts F:Sf:adH:M:L:X:T:t:C:c:i:m:s:h opt; do
|
||||
case "$opt" in
|
||||
S) SUBSCRIBE=1 ;;
|
||||
F) LONG_FORMAT="$OPTARG" ;;
|
||||
f) SHORT_FORMAT="$OPTARG" ;;
|
||||
a) USE_ALSA_NAME=1 ;;
|
||||
d) USE_DESCRIPTION=1 ;;
|
||||
H) AUDIO_HIGH_SYMBOL="$OPTARG" ;;
|
||||
M) AUDIO_MED_SYMBOL="$OPTARG" ;;
|
||||
L) AUDIO_LOW_SYMBOL="$OPTARG" ;;
|
||||
X) AUDIO_MUTED_SYMBOL="$OPTARG" ;;
|
||||
T) AUDIO_MED_THRESH="$OPTARG" ;;
|
||||
t) AUDIO_LOW_THRESH="$OPTARG" ;;
|
||||
C) DEFAULT_COLOR="$OPTARG" ;;
|
||||
c) MUTED_COLOR="$OPTARG" ;;
|
||||
i) AUDIO_INTERVAL="$OPTARG" ;;
|
||||
m) MIXER="$OPTARG" ;;
|
||||
s) SCONTROL="$OPTARG" ;;
|
||||
h) printf \
|
||||
"Usage: volume-pulseaudio [-S] [-F format] [-f format] [-p] [-a|-d] [-H symb] [-M symb]
|
||||
[-L symb] [-X symb] [-T thresh] [-t thresh] [-C color] [-c color] [-i inter]
|
||||
[-m mixer] [-s scontrol] [-h]
|
||||
Options:
|
||||
-F, -f\tOutput format (-F long format, -f short format) to use, with exposed variables:
|
||||
\${SYMB}, \${VOL}, \${INDEX}, \${NAME}
|
||||
-S\tSubscribe to volume events (requires persistent block, always uses long format)
|
||||
-a\tUse ALSA name if possible
|
||||
-d\tUse device description instead of name if possible
|
||||
-H\tSymbol to use when audio level is high. Default: '$AUDIO_HIGH_SYMBOL'
|
||||
-M\tSymbol to use when audio level is medium. Default: '$AUDIO_MED_SYMBOL'
|
||||
-L\tSymbol to use when audio level is low. Default: '$AUDIO_LOW_SYMBOL'
|
||||
-X\tSymbol to use when audio is muted. Default: '$AUDIO_MUTED_SYMBOL'
|
||||
-T\tThreshold for medium audio level. Default: $AUDIO_MED_THRESH
|
||||
-t\tThreshold for low audio level. Default: $AUDIO_LOW_THRESH
|
||||
-C\tColor for non-muted audio. Default: $DEFAULT_COLOR
|
||||
-c\tColor for muted audio. Default: $MUTED_COLOR
|
||||
-i\tInterval size of volume increase/decrease. Default: $AUDIO_DELTA
|
||||
-m\tUse the given mixer.
|
||||
-s\tUse the given scontrol.
|
||||
-h\tShow this help text
|
||||
" && exit 0;;
|
||||
esac
|
||||
done
|
||||
|
||||
# }}} flags #
|
||||
|
||||
# functions {{{ #
|
||||
|
||||
if [[ -z "$MIXER" ]] ; then
|
||||
MIXER="default"
|
||||
if amixer -D pulse info >/dev/null 2>&1 ; then
|
||||
MIXER="pulse"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -z "$SCONTROL" ]] ; then
|
||||
SCONTROL=$(amixer -D "$MIXER" scontrols | sed -n "s/Simple mixer control '\([^']*\)',0/\1/p" | head -n1)
|
||||
fi
|
||||
|
||||
CAPABILITY=$(amixer -D $MIXER get $SCONTROL | sed -n "s/ Capabilities:.*cvolume.*/Capture/p")
|
||||
|
||||
|
||||
function move_sinks_to_new_default {
|
||||
DEFAULT_SINK=$1
|
||||
pacmd list-sink-inputs | grep index: | grep -o '[0-9]\+' | while read SINK
|
||||
do
|
||||
pacmd move-sink-input $SINK $DEFAULT_SINK
|
||||
done
|
||||
}
|
||||
|
||||
function set_default_playback_device_next {
|
||||
inc=${1:-1}
|
||||
num_devices=$(pacmd list-sinks | grep -c index:)
|
||||
sink_arr=($(pacmd list-sinks | grep index: | grep -o '[0-9]\+'))
|
||||
default_sink_index=$(( $(pacmd list-sinks | grep index: | grep -no '*' | grep -o '^[0-9]\+') - 1 ))
|
||||
default_sink_index=$(( ($default_sink_index + $num_devices + $inc) % $num_devices ))
|
||||
default_sink=${sink_arr[$default_sink_index]}
|
||||
pacmd set-default-sink $default_sink
|
||||
move_sinks_to_new_default $default_sink
|
||||
}
|
||||
|
||||
# }}} functions #
|
||||
|
||||
# triggers {{{ #
|
||||
|
||||
case "$BLOCK_BUTTON" in
|
||||
1) set_default_playback_device_next ;;
|
||||
2) amixer -q -D $MIXER sset $SCONTROL $CAPABILITY toggle ;;
|
||||
3) set_default_playback_device_next -1 ;;
|
||||
4) amixer -q -D $MIXER sset $SCONTROL $CAPABILITY $AUDIO_DELTA%+ ;;
|
||||
5) amixer -q -D $MIXER sset $SCONTROL $CAPABILITY $AUDIO_DELTA%- ;;
|
||||
esac
|
||||
|
||||
# }}} triggers #
|
||||
|
||||
# print_format {{{ #
|
||||
|
||||
function print_format {
|
||||
# echo $NAME
|
||||
case $NAME in
|
||||
*"USB"*)
|
||||
SINK_SYMB=""
|
||||
;;
|
||||
*"hdmi"*)
|
||||
SINK_SYMB=""
|
||||
;;
|
||||
*"pci"*)
|
||||
SINK_SYMB=""
|
||||
;;
|
||||
esac
|
||||
# echo "$1" | envsubst '${SYMB}${VOL}${INDEX}${NAME}'
|
||||
echo "$1" | envsubst '${SINK_SYMB}${VOL}${INDEX}${NAME}'
|
||||
}
|
||||
|
||||
# }}} print_format #
|
||||
|
||||
# print_block {{{ #
|
||||
|
||||
function print_block {
|
||||
for name in INDEX NAME VOL MUTED; do
|
||||
read $name
|
||||
done < <(pacmd list-sinks | grep "index:\|name:\|volume: front\|muted:" | grep -A3 '*')
|
||||
INDEX=$(echo "$INDEX" | grep -o '[0-9]\+')
|
||||
VOL=$(echo "$VOL" | grep -o "[0-9]*%" | head -1 )
|
||||
VOL="${VOL%?}"
|
||||
|
||||
NAME=$(echo "$NAME")
|
||||
# NAME=$(echo "$NAME" | sed \
|
||||
# 's/.*<.*\.\(.*\)>.*/\1/; t;'\
|
||||
# 's/.*<\(.*\)>.*/\1/; t;'\
|
||||
# 's/.*/unknown/')
|
||||
# NAME=$(echo "$NAME" | sed \
|
||||
# 's/.*<.*\.\(.*\)\..*>.*/\1/; t;')
|
||||
|
||||
if [[ $USE_ALSA_NAME == 1 ]] ; then
|
||||
ALSA_NAME=$(pacmd list-sinks |\
|
||||
awk '/^\s*\*/{f=1}/^\s*index:/{f=0}f' |\
|
||||
grep "alsa.name\|alsa.mixer_name" |\
|
||||
head -n1 |\
|
||||
sed 's/.*= "\(.*\)".*/\1/')
|
||||
NAME=${ALSA_NAME:-$NAME}
|
||||
elif [[ $USE_DESCRIPTION == 1 ]] ; then
|
||||
DESCRIPTION=$(pacmd list-sinks |\
|
||||
awk '/^\s*\*/{f=1}/^\s*index:/{f=0}f' |\
|
||||
grep "device.description" |\
|
||||
head -n1 |\
|
||||
sed 's/.*= "\(.*\)".*/\1/')
|
||||
NAME=${DESCRIPTION:-$NAME}
|
||||
fi
|
||||
|
||||
if [[ $MUTED =~ "no" ]] ; then
|
||||
SYMB=$AUDIO_HIGH_SYMBOL
|
||||
[[ $VOL -le $AUDIO_MED_THRESH ]] && SYMB=$AUDIO_MED_SYMBOL
|
||||
[[ $VOL -le $AUDIO_LOW_THRESH ]] && SYMB=$AUDIO_LOW_SYMBOL
|
||||
COLOR=$DEFAULT_COLOR
|
||||
else
|
||||
SYMB=$AUDIO_MUTED_SYMBOL
|
||||
COLOR=$MUTED_COLOR
|
||||
fi
|
||||
|
||||
if [[ $SUBSCRIBE == 1 ]] ; then
|
||||
print_format "$LONG_FORMAT"
|
||||
else
|
||||
print_format "$LONG_FORMAT"
|
||||
print_format "$SHORT_FORMAT"
|
||||
echo "$COLOR"
|
||||
fi
|
||||
}
|
||||
|
||||
# }}} print_block #
|
||||
|
||||
print_block
|
||||
if [[ $SUBSCRIBE == 1 ]] ; then
|
||||
while read -r EVENT; do
|
||||
print_block
|
||||
done < <(pactl subscribe | stdbuf -oL grep change)
|
||||
fi
|
||||
50
dot_config/i3blocks/scripts/executable_wifi
Normal file
50
dot_config/i3blocks/scripts/executable_wifi
Normal file
@@ -0,0 +1,50 @@
|
||||
#!/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/>.
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
|
||||
INTERFACE="${BLOCK_INSTANCE:-wlan0}"
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
|
||||
# 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 ]] ||
|
||||
# [[ "$(cat /sys/class/net/$INTERFACE/operstate)" = 'down' ]] && exit
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
|
||||
QUALITY=$(sudo grep $INTERFACE /proc/net/wireless | awk '{ print int($3 * 100 / 70) }')
|
||||
W_inter=$(ip link | grep "[1-9]: wlp" | cut -d " " -f2 | tr -d ':')
|
||||
W_name=$(nmcli d | grep "$W_inter" | awk '{print $4}')
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
|
||||
# echo $QUALITY% "$W_name" # full text
|
||||
# echo $QUALITY% # short text
|
||||
. "/home/kevin/.cache/wal/colors.sh"
|
||||
printf "%s%%\n\n%s\n" $QUALITY $color7
|
||||
|
||||
# color
|
||||
# if [[ $QUALITY -ge 80 ]]; then
|
||||
# echo "#00FF00"
|
||||
# elif [[ $QUALITY -lt 80 ]]; then
|
||||
# echo "#FFF600"
|
||||
# elif [[ $QUALITY -lt 60 ]]; then
|
||||
# echo "#FFAE00"
|
||||
# elif [[ $QUALITY -lt 40 ]]; then
|
||||
# echo "#FF0000"
|
||||
# fi
|
||||
Reference in New Issue
Block a user