Adaptation des scripts i3blocks
This commit is contained in:
parent
a91448b547
commit
4b71bae1e9
8 changed files with 46 additions and 186 deletions
|
@ -11,7 +11,6 @@
|
|||
# full_text
|
||||
# instance
|
||||
# interval
|
||||
# label
|
||||
# min_width
|
||||
# name
|
||||
# separator
|
||||
|
@ -24,7 +23,7 @@
|
|||
#
|
||||
# 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=${HOME}/.i3blocks/$BLOCK_NAME
|
||||
command=${HOME}/.i3blocks/$name
|
||||
separator_block_width=11
|
||||
markup=pango
|
||||
|
||||
|
@ -37,13 +36,11 @@ markup=pango
|
|||
# The script may be called with -w and -c switches to specify thresholds,
|
||||
# see the script for details.
|
||||
[cpu_usage]
|
||||
#label=
|
||||
interval=1
|
||||
#min_width= 99.99%
|
||||
#separator=false
|
||||
|
||||
[load_average]
|
||||
#label=
|
||||
interval=5
|
||||
|
||||
# Temperature
|
||||
|
@ -52,27 +49,22 @@ interval=5
|
|||
# The script may be called with -w and -c switches to specify thresholds,
|
||||
# see the script for details.
|
||||
#[temperature]
|
||||
##label=
|
||||
#label=cpu
|
||||
#instance=coretemp-isa-0000
|
||||
#interval=3
|
||||
#separator=false
|
||||
#
|
||||
#[temperature]
|
||||
#label=gpu
|
||||
#instance=radeon-pci-0300
|
||||
#interval=3
|
||||
# Memory usage
|
||||
#
|
||||
# The type defaults to "mem" if the instance is not specified.
|
||||
[memory]
|
||||
label=ram
|
||||
#separator=false
|
||||
interval=2
|
||||
#min_width=RAM 99.99%
|
||||
|
||||
#[memory]
|
||||
#label=swap
|
||||
#instance=swap
|
||||
##separator=false
|
||||
#interval=2
|
||||
|
@ -84,18 +76,15 @@ interval=2
|
|||
# The script may be called with a optional argument to set the alert
|
||||
# (defaults to 10 for 10%).
|
||||
#[disk]
|
||||
#label=
|
||||
#instance=/
|
||||
#interval=30
|
||||
#separator=false
|
||||
|
||||
#[disk]
|
||||
#label=
|
||||
#instance=/mnt/data
|
||||
#interval=30
|
||||
|
||||
[internet]
|
||||
label=wan
|
||||
interval=30
|
||||
separator=false
|
||||
|
||||
|
@ -104,18 +93,15 @@ separator=false
|
|||
# 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]
|
||||
#label=wlan
|
||||
#instance=wlp1s0
|
||||
#interval=10
|
||||
#separator=false
|
||||
|
||||
#[public_ip]
|
||||
#label=
|
||||
#interval=60
|
||||
#separator=false
|
||||
|
||||
[vpn]
|
||||
label=vpn
|
||||
interval=30
|
||||
separator=false
|
||||
|
||||
|
@ -125,13 +111,10 @@ separator=false
|
|||
|
||||
# Packages to update
|
||||
[updates]
|
||||
label=updt
|
||||
interval=600
|
||||
|
||||
|
||||
#[wifi]
|
||||
##label=
|
||||
##label=wlan
|
||||
#instance=wlp1s0
|
||||
#interval=3
|
||||
#separator=false
|
||||
|
@ -151,14 +134,11 @@ interval=600
|
|||
#
|
||||
# The battery instance defaults to 0.
|
||||
#[battery]
|
||||
#label=BAT
|
||||
#label=⚡
|
||||
#instance=0
|
||||
#interval=5
|
||||
|
||||
#[batterybar]
|
||||
#[battery]
|
||||
#label=bat
|
||||
#interval=10
|
||||
#min_width="bat ██████"
|
||||
|
||||
|
@ -184,19 +164,17 @@ signal=13
|
|||
# The second parameter overrides the mixer selection
|
||||
# See the script for details.
|
||||
[volume]
|
||||
instance=Master
|
||||
instance=vol
|
||||
#instance=PCM
|
||||
interval=once
|
||||
signal=10
|
||||
separator=false
|
||||
label=vol
|
||||
|
||||
[volume]
|
||||
instance=Capture
|
||||
instance=mic
|
||||
#instance=PCM
|
||||
interval=once
|
||||
signal=10
|
||||
label=mic
|
||||
|
||||
|
||||
# Key indicators
|
||||
|
@ -206,15 +184,13 @@ label=mic
|
|||
# bindsym --release Caps_Lock exec pkill -SIGRTMIN+11 i3blocks
|
||||
# bindsym --release Num_Lock exec pkill -SIGRTMIN+12 i3blocks
|
||||
[keyindicator]
|
||||
label=caps
|
||||
instance=CAPS
|
||||
instance=Caps
|
||||
interval=once
|
||||
signal=11
|
||||
separator=false
|
||||
|
||||
[keyindicator]
|
||||
label=num
|
||||
instance=NUM
|
||||
instance=Num
|
||||
interval=once
|
||||
signal=12
|
||||
# Date Time
|
||||
|
|
|
@ -19,4 +19,4 @@ else color="#66cccc"
|
|||
fi
|
||||
|
||||
# Affichage
|
||||
printf "cpu<span foreground=\"%s\">%3d%%</span>" "$color" "$used"
|
||||
printf "cpu<span foreground=\"%s\">%3d%%</span>\n" "$color" "$used"
|
||||
|
|
|
@ -28,4 +28,4 @@ else
|
|||
fi
|
||||
fi
|
||||
|
||||
echo "<span foreground=\"$color\">█</span>"
|
||||
echo "wan <span foreground=\"$color\">█</span>"
|
||||
|
|
|
@ -1,70 +1,14 @@
|
|||
#!/usr/bin/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/>.
|
||||
#!/bin/bash
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use utf8;
|
||||
use Getopt::Long;
|
||||
use File::Basename;
|
||||
[[ -z "$instance" ]] && instance=Caps
|
||||
|
||||
# Default values
|
||||
my $indicator = $ENV{BLOCK_INSTANCE} || "CAPS";
|
||||
my $color_on = "#99cc99";
|
||||
my $color_off = "#515151";
|
||||
status=$(xset q | grep -Po "$instance Lock: +(on|off)" | grep -Po "on|off")
|
||||
|
||||
sub help {
|
||||
my $program = basename($0);
|
||||
printf "Usage: %s [-c <color on>] [-C <color off>]\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 "\n";
|
||||
printf "Note: environment variable \$BLOCK_INSTANCE should be one of:\n";
|
||||
printf " CAPS, NUM (default is CAPS).\n";
|
||||
exit 0;
|
||||
}
|
||||
if [[ "$status" = "on" ]]
|
||||
then
|
||||
color="#99CC99"
|
||||
else
|
||||
color="#515151"
|
||||
fi
|
||||
|
||||
Getopt::Long::config qw(no_ignore_case);
|
||||
GetOptions("help|h" => \&help,
|
||||
"c=s" => \$color_on,
|
||||
"C=s" => \$color_off) 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-9]+)/) {
|
||||
$mask = $1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
close(XSET);
|
||||
|
||||
my $indi = "N";
|
||||
|
||||
# Output
|
||||
if (($indicators{$indicator} || 0) & $mask) {
|
||||
printf "<span foreground=\"%s\">█</span>", $color_on;
|
||||
} else {
|
||||
printf "<span foreground=\"%s\">█</span>", $color_off;
|
||||
}
|
||||
exit 0
|
||||
echo "${instance,*} <span foreground=\"$color\">█</span>"
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
TYPE="${BLOCK_INSTANCE:-mem}"
|
||||
|
||||
echo -n "${TYPE//mem/ram} "
|
||||
|
||||
awk -v type=$TYPE '
|
||||
/^MemTotal:/ {
|
||||
mem_total=$2
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo -n "updt "
|
||||
|
||||
if [[ -f /dev/shm/claws_offline ]]
|
||||
then
|
||||
echo "<span foreground=\"#F2777A\">█</span>"
|
||||
|
|
108
.i3blocks/volume
108
.i3blocks/volume
|
@ -1,95 +1,29 @@
|
|||
#!/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/>.
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
|
||||
# The second parameter overrides the mixer selection
|
||||
# For PulseAudio users, 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
|
||||
MIXER="default"
|
||||
[ -n "$(lsmod | grep pulse)" ] && MIXER="pulse"
|
||||
[ -n "$(lsmod | grep jack)" ] && MIXER="jackplug"
|
||||
MIXER="${2:-$MIXER}"
|
||||
|
||||
# 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`
|
||||
SCONTROL="${BLOCK_INSTANCE:-$(amixer -D $MIXER scontrols |
|
||||
sed -n "s/Simple mixer control '\([A-Za-z ]*\)',0/\1/p" |
|
||||
head -n1
|
||||
)}"
|
||||
|
||||
# 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)
|
||||
STEP="${1:-5%}"
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
|
||||
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() {
|
||||
TYPE=""
|
||||
TYPE_MUTE=""
|
||||
if [[ $SCONTROL = "Master" ]]
|
||||
if [[ "$instance" == mic ]]
|
||||
then
|
||||
# TYPE_MUTE=" "
|
||||
# TYPE=" "
|
||||
# TYPE="vol "
|
||||
# TYPE_MUTE="vol "
|
||||
TYPE='<span foreground=\"#99CC99\">'
|
||||
TYPE_MUTE='<span foreground=\"#F2777A\">'
|
||||
elif [[ $SCONTROL = "Capture" ]]
|
||||
then
|
||||
# TYPE_MUTE=" "
|
||||
# TYPE=" "
|
||||
# TYPE="mic "
|
||||
# TYPE_MUTE="mic "
|
||||
TYPE='<span foreground=\"#99CC99\">'
|
||||
TYPE_MUTE='<span foreground=\"#F2777A\">'
|
||||
options=" --default-source"
|
||||
fi
|
||||
perl_filter='if (/.*\[(\d+%)\] (\[(-?\d+.\d+dB)\] )?\[(on|off)\]/)'
|
||||
perl_filter+='{CORE::say $4 eq "off" ? "'
|
||||
perl_filter+=$TYPE_MUTE
|
||||
perl_filter+=$([[ $STEP = *dB ]] && echo '$3' || echo '$1')
|
||||
perl_filter+='</span>" : "'
|
||||
perl_filter+=$TYPE
|
||||
# If dB was selected, print that instead
|
||||
perl_filter+=$([[ $STEP = *dB ]] && echo '$3' || echo '$1')
|
||||
perl_filter+='</span>"; exit}'
|
||||
perl -ne "$perl_filter"
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
mixer="pamixer${options}"
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
3) amixer -q -D $MIXER sset $SCONTROL $(capability) 1%+ ;;
|
||||
1) amixer -q -D $MIXER sset $SCONTROL $(capability) 1%- ;;
|
||||
2) amixer -q -D $MIXER sset $SCONTROL $(capability) toggle ;; # right click, mute/unmute
|
||||
4) amixer -q -D $MIXER sset $SCONTROL $(capability) ${STEP}+ ;; # scroll up, increase
|
||||
5) amixer -q -D $MIXER sset $SCONTROL $(capability) ${STEP}- ;; # scroll down, decrease
|
||||
case $button in
|
||||
1) $mixer -d 1;;
|
||||
2) $mixer -t;;
|
||||
3) $mixer -i 1;;
|
||||
4) $mixer -i 5;;
|
||||
5) $mixer -d 5;;
|
||||
esac
|
||||
|
||||
volume | format
|
||||
volume="$($mixer --get-volume)"
|
||||
muted="$($mixer --get-mute)"
|
||||
|
||||
if $muted
|
||||
then
|
||||
color="#F2777A"
|
||||
else
|
||||
color="#99CC99"
|
||||
fi
|
||||
|
||||
printf "%s <span foreground=\"%s\">%2d%%</span>\n" "$BLOCK_INSTANCE" "$color" "$volume"
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo -n "vpn "
|
||||
|
||||
if nmcli dev | grep tun0 | cut -f3 | grep " connecté" &>/dev/null
|
||||
then
|
||||
echo "<span foreground=\"#99CC99\">█</span>"
|
||||
|
|
Loading…
Reference in a new issue