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
|
# full_text
|
||||||
# instance
|
# instance
|
||||||
# interval
|
# interval
|
||||||
# label
|
|
||||||
# min_width
|
# min_width
|
||||||
# name
|
# name
|
||||||
# separator
|
# separator
|
||||||
|
@ -24,7 +23,7 @@
|
||||||
#
|
#
|
||||||
# The top properties below are applied to every block, but can be overridden.
|
# The top properties below are applied to every block, but can be overridden.
|
||||||
# Each block command defaults to the script name to avoid boilerplate.
|
# Each block command defaults to the script name to avoid boilerplate.
|
||||||
command=${HOME}/.i3blocks/$BLOCK_NAME
|
command=${HOME}/.i3blocks/$name
|
||||||
separator_block_width=11
|
separator_block_width=11
|
||||||
markup=pango
|
markup=pango
|
||||||
|
|
||||||
|
@ -37,13 +36,11 @@ markup=pango
|
||||||
# The script may be called with -w and -c switches to specify thresholds,
|
# The script may be called with -w and -c switches to specify thresholds,
|
||||||
# see the script for details.
|
# see the script for details.
|
||||||
[cpu_usage]
|
[cpu_usage]
|
||||||
#label=
|
|
||||||
interval=1
|
interval=1
|
||||||
#min_width= 99.99%
|
#min_width= 99.99%
|
||||||
#separator=false
|
#separator=false
|
||||||
|
|
||||||
[load_average]
|
[load_average]
|
||||||
#label=
|
|
||||||
interval=5
|
interval=5
|
||||||
|
|
||||||
# Temperature
|
# Temperature
|
||||||
|
@ -52,27 +49,22 @@ interval=5
|
||||||
# The script may be called with -w and -c switches to specify thresholds,
|
# The script may be called with -w and -c switches to specify thresholds,
|
||||||
# see the script for details.
|
# see the script for details.
|
||||||
#[temperature]
|
#[temperature]
|
||||||
##label=
|
|
||||||
#label=cpu
|
|
||||||
#instance=coretemp-isa-0000
|
#instance=coretemp-isa-0000
|
||||||
#interval=3
|
#interval=3
|
||||||
#separator=false
|
#separator=false
|
||||||
#
|
#
|
||||||
#[temperature]
|
#[temperature]
|
||||||
#label=gpu
|
|
||||||
#instance=radeon-pci-0300
|
#instance=radeon-pci-0300
|
||||||
#interval=3
|
#interval=3
|
||||||
# Memory usage
|
# Memory usage
|
||||||
#
|
#
|
||||||
# The type defaults to "mem" if the instance is not specified.
|
# The type defaults to "mem" if the instance is not specified.
|
||||||
[memory]
|
[memory]
|
||||||
label=ram
|
|
||||||
#separator=false
|
#separator=false
|
||||||
interval=2
|
interval=2
|
||||||
#min_width=RAM 99.99%
|
#min_width=RAM 99.99%
|
||||||
|
|
||||||
#[memory]
|
#[memory]
|
||||||
#label=swap
|
|
||||||
#instance=swap
|
#instance=swap
|
||||||
##separator=false
|
##separator=false
|
||||||
#interval=2
|
#interval=2
|
||||||
|
@ -84,18 +76,15 @@ interval=2
|
||||||
# The script may be called with a optional argument to set the alert
|
# The script may be called with a optional argument to set the alert
|
||||||
# (defaults to 10 for 10%).
|
# (defaults to 10 for 10%).
|
||||||
#[disk]
|
#[disk]
|
||||||
#label=
|
|
||||||
#instance=/
|
#instance=/
|
||||||
#interval=30
|
#interval=30
|
||||||
#separator=false
|
#separator=false
|
||||||
|
|
||||||
#[disk]
|
#[disk]
|
||||||
#label=
|
|
||||||
#instance=/mnt/data
|
#instance=/mnt/data
|
||||||
#interval=30
|
#interval=30
|
||||||
|
|
||||||
[internet]
|
[internet]
|
||||||
label=wan
|
|
||||||
interval=30
|
interval=30
|
||||||
separator=false
|
separator=false
|
||||||
|
|
||||||
|
@ -104,18 +93,15 @@ separator=false
|
||||||
# If the instance is not specified, use the interface used for default route.
|
# 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.
|
# The address can be forced to IPv4 or IPv6 with -4 or -6 switches.
|
||||||
#[iface]
|
#[iface]
|
||||||
#label=wlan
|
|
||||||
#instance=wlp1s0
|
#instance=wlp1s0
|
||||||
#interval=10
|
#interval=10
|
||||||
#separator=false
|
#separator=false
|
||||||
|
|
||||||
#[public_ip]
|
#[public_ip]
|
||||||
#label=
|
|
||||||
#interval=60
|
#interval=60
|
||||||
#separator=false
|
#separator=false
|
||||||
|
|
||||||
[vpn]
|
[vpn]
|
||||||
label=vpn
|
|
||||||
interval=30
|
interval=30
|
||||||
separator=false
|
separator=false
|
||||||
|
|
||||||
|
@ -125,13 +111,10 @@ separator=false
|
||||||
|
|
||||||
# Packages to update
|
# Packages to update
|
||||||
[updates]
|
[updates]
|
||||||
label=updt
|
|
||||||
interval=600
|
interval=600
|
||||||
|
|
||||||
|
|
||||||
#[wifi]
|
#[wifi]
|
||||||
##label=
|
|
||||||
##label=wlan
|
|
||||||
#instance=wlp1s0
|
#instance=wlp1s0
|
||||||
#interval=3
|
#interval=3
|
||||||
#separator=false
|
#separator=false
|
||||||
|
@ -151,14 +134,11 @@ interval=600
|
||||||
#
|
#
|
||||||
# The battery instance defaults to 0.
|
# The battery instance defaults to 0.
|
||||||
#[battery]
|
#[battery]
|
||||||
#label=BAT
|
|
||||||
#label=⚡
|
|
||||||
#instance=0
|
#instance=0
|
||||||
#interval=5
|
#interval=5
|
||||||
|
|
||||||
#[batterybar]
|
#[batterybar]
|
||||||
#[battery]
|
#[battery]
|
||||||
#label=bat
|
|
||||||
#interval=10
|
#interval=10
|
||||||
#min_width="bat ██████"
|
#min_width="bat ██████"
|
||||||
|
|
||||||
|
@ -184,19 +164,17 @@ signal=13
|
||||||
# The second parameter overrides the mixer selection
|
# The second parameter overrides the mixer selection
|
||||||
# See the script for details.
|
# See the script for details.
|
||||||
[volume]
|
[volume]
|
||||||
instance=Master
|
instance=vol
|
||||||
#instance=PCM
|
#instance=PCM
|
||||||
interval=once
|
interval=once
|
||||||
signal=10
|
signal=10
|
||||||
separator=false
|
separator=false
|
||||||
label=vol
|
|
||||||
|
|
||||||
[volume]
|
[volume]
|
||||||
instance=Capture
|
instance=mic
|
||||||
#instance=PCM
|
#instance=PCM
|
||||||
interval=once
|
interval=once
|
||||||
signal=10
|
signal=10
|
||||||
label=mic
|
|
||||||
|
|
||||||
|
|
||||||
# Key indicators
|
# Key indicators
|
||||||
|
@ -206,15 +184,13 @@ label=mic
|
||||||
# bindsym --release Caps_Lock exec pkill -SIGRTMIN+11 i3blocks
|
# bindsym --release Caps_Lock exec pkill -SIGRTMIN+11 i3blocks
|
||||||
# bindsym --release Num_Lock exec pkill -SIGRTMIN+12 i3blocks
|
# bindsym --release Num_Lock exec pkill -SIGRTMIN+12 i3blocks
|
||||||
[keyindicator]
|
[keyindicator]
|
||||||
label=caps
|
instance=Caps
|
||||||
instance=CAPS
|
|
||||||
interval=once
|
interval=once
|
||||||
signal=11
|
signal=11
|
||||||
separator=false
|
separator=false
|
||||||
|
|
||||||
[keyindicator]
|
[keyindicator]
|
||||||
label=num
|
instance=Num
|
||||||
instance=NUM
|
|
||||||
interval=once
|
interval=once
|
||||||
signal=12
|
signal=12
|
||||||
# Date Time
|
# Date Time
|
||||||
|
|
|
@ -19,4 +19,4 @@ else color="#66cccc"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Affichage
|
# 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
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "<span foreground=\"$color\">█</span>"
|
echo "wan <span foreground=\"$color\">█</span>"
|
||||||
|
|
|
@ -1,70 +1,14 @@
|
||||||
#!/usr/bin/perl
|
#!/bin/bash
|
||||||
#
|
|
||||||
# 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;
|
[[ -z "$instance" ]] && instance=Caps
|
||||||
use warnings;
|
|
||||||
use utf8;
|
|
||||||
use Getopt::Long;
|
|
||||||
use File::Basename;
|
|
||||||
|
|
||||||
# Default values
|
status=$(xset q | grep -Po "$instance Lock: +(on|off)" | grep -Po "on|off")
|
||||||
my $indicator = $ENV{BLOCK_INSTANCE} || "CAPS";
|
|
||||||
my $color_on = "#99cc99";
|
|
||||||
my $color_off = "#515151";
|
|
||||||
|
|
||||||
sub help {
|
if [[ "$status" = "on" ]]
|
||||||
my $program = basename($0);
|
then
|
||||||
printf "Usage: %s [-c <color on>] [-C <color off>]\n", $program;
|
color="#99CC99"
|
||||||
printf " -c <color on>: hex color to use when indicator is on\n";
|
else
|
||||||
printf " -C <color off>: hex color to use when indicator is off\n";
|
color="#515151"
|
||||||
printf "\n";
|
fi
|
||||||
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);
|
echo "${instance,*} <span foreground=\"$color\">█</span>"
|
||||||
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
|
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
TYPE="${BLOCK_INSTANCE:-mem}"
|
TYPE="${BLOCK_INSTANCE:-mem}"
|
||||||
|
|
||||||
|
echo -n "${TYPE//mem/ram} "
|
||||||
|
|
||||||
awk -v type=$TYPE '
|
awk -v type=$TYPE '
|
||||||
/^MemTotal:/ {
|
/^MemTotal:/ {
|
||||||
mem_total=$2
|
mem_total=$2
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo -n "updt "
|
||||||
|
|
||||||
if [[ -f /dev/shm/claws_offline ]]
|
if [[ -f /dev/shm/claws_offline ]]
|
||||||
then
|
then
|
||||||
echo "<span foreground=\"#F2777A\">█</span>"
|
echo "<span foreground=\"#F2777A\">█</span>"
|
||||||
|
|
112
.i3blocks/volume
112
.i3blocks/volume
|
@ -1,95 +1,29 @@
|
||||||
#!/bin/bash
|
#!/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
|
if [[ "$instance" == mic ]]
|
||||||
# it under the terms of the GNU General Public License as published by
|
then
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
options=" --default-source"
|
||||||
# (at your option) any later version.
|
fi
|
||||||
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
mixer="pamixer${options}"
|
||||||
# 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
|
case $button in
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1) $mixer -d 1;;
|
||||||
|
2) $mixer -t;;
|
||||||
#------------------------------------------------------------------------
|
3) $mixer -i 1;;
|
||||||
|
4) $mixer -i 5;;
|
||||||
# The second parameter overrides the mixer selection
|
5) $mixer -d 5;;
|
||||||
# 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" ]]
|
|
||||||
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\">'
|
|
||||||
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"
|
|
||||||
}
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
|
||||||
|
|
||||||
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
|
|
||||||
esac
|
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
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo -n "vpn "
|
||||||
|
|
||||||
if nmcli dev | grep tun0 | cut -f3 | grep " connecté" &>/dev/null
|
if nmcli dev | grep tun0 | cut -f3 | grep " connecté" &>/dev/null
|
||||||
then
|
then
|
||||||
echo "<span foreground=\"#99CC99\">█</span>"
|
echo "<span foreground=\"#99CC99\">█</span>"
|
||||||
|
|
Loading…
Reference in a new issue