Add files via upload
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
#!/bin/bash
|
||||
# Source: http://www.onlamp.com/pub/a/linux/2000/11/16/LinuxAdmin.html
|
||||
|
||||
INSTANCE="${BLOCK_INSTANCE}"
|
||||
# If you don't like you can use any other IP
|
||||
INTERFACE="$(ip route get 8.8.8.8 | grep -Po '(?<=(dev )).*(?= src)')"
|
||||
|
||||
if [[ "${INSTANCE}" = "" ]]; then
|
||||
INSTANCE="${INTERFACE};both"
|
||||
fi
|
||||
|
||||
DISPLAY=$(echo "${INSTANCE}" | awk -F ';' '{print $2}')
|
||||
INSTANCE=$(echo "${INSTANCE}" | awk -F ';' '{print $1}')
|
||||
|
||||
if [[ "${DISPLAY}" = "" ]]; then
|
||||
DISPLAY="both"
|
||||
fi
|
||||
|
||||
ONE_KB=1024
|
||||
ONE_MB=$(echo "${ONE_KB}*1024" | bc -l)
|
||||
TEN_MB=$(echo "${ONE_MB}*10" | bc -l)
|
||||
OHD_MB=$(echo "${TEN_MB}*10" | bc -l)
|
||||
|
||||
URGENT_VALUE="${ONE_MB}"
|
||||
|
||||
PREV_IN=0
|
||||
PREV_OUT=0
|
||||
|
||||
PREV_FILE="/tmp/.bandwidth"
|
||||
|
||||
if [[ -f "${PREV_FILE}" ]]; then
|
||||
PREV_CONT=$(cat "${PREV_FILE}")
|
||||
PREV_IN=$(echo "${PREV_CONT}" | head -n 1)
|
||||
PREV_OUT=$(echo "${PREV_CONT}" | tail -n 1)
|
||||
fi
|
||||
|
||||
BANDWIDTH=$(grep "${INSTANCE}" /proc/net/dev | awk -F: '{print $2}' | awk '{print $1" "$9}')
|
||||
|
||||
if [[ "${BANDWIDTH}" = "" ]]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
BYTES_IN=$(echo "${BANDWIDTH}" | awk -F ' ' '{print $1}')
|
||||
BYTES_OUT=$(echo "${BANDWIDTH}" | awk -F ' ' '{print $2}')
|
||||
|
||||
function FormatNumber() {
|
||||
if [[ "${1}" -ge "${OHD_MB}" ]]; then
|
||||
printf "%03d" $(echo "scale=0;${1}/${ONE_MB}" | bc -l)
|
||||
echo "m"
|
||||
elif [[ "${1}" -ge "${TEN_MB}" ]]; then
|
||||
printf "%03d" $(echo "scale=1;${1}/${ONE_MB}" | bc -l)
|
||||
echo "m"
|
||||
elif [[ "${1}" -ge "${ONE_MB}" ]]; then
|
||||
printf "%03d" $(echo "scale=2;${1}/${ONE_MB}" | bc -l)
|
||||
echo "m"
|
||||
elif [[ "${1}" -ge "${ONE_KB}" ]]; then
|
||||
printf "%03d" $(echo "scale=0;${1}/${ONE_KB}" | bc -l)
|
||||
echo "k"
|
||||
else
|
||||
printf "%03d" "$1"
|
||||
echo "b"
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ "${PREV_IN}" != "" ]] && [[ "${PREV_OUT}" != "" ]]; then
|
||||
# Calculate the CPU usage since we last checked.
|
||||
DIFF_IN=$(echo "scale=0;${BYTES_IN} - ${PREV_IN}" | bc -l)
|
||||
DIFF_OUT=$(echo "scale=0;${BYTES_OUT} - ${PREV_OUT}" | bc -l)
|
||||
DIFF_TOTAL=0
|
||||
|
||||
USAGE_IN=$(FormatNumber "${DIFF_IN}")
|
||||
USAGE_OUT=$(FormatNumber "${DIFF_OUT}")
|
||||
|
||||
if [[ "${DISPLAY}" = "both" ]]; then
|
||||
echo "${USAGE_IN} : ${USAGE_OUT}"
|
||||
echo "${USAGE_IN} : ${USAGE_OUT}"
|
||||
echo ""
|
||||
DIFF_TOTAL=$((DIFF_TOTAL+DIFF_IN))
|
||||
DIFF_TOTAL=$((DIFF_TOTAL+DIFF_OUT))
|
||||
elif [[ "${DISPLAY}" = "in" ]]; then
|
||||
echo "${USAGE_IN}"
|
||||
echo "${USAGE_IN}"
|
||||
echo ""
|
||||
DIFF_TOTAL=$((DIFF_TOTAL+DIFF_IN))
|
||||
elif [[ "${DISPLAY}" = "out" ]]; then
|
||||
echo "${USAGE_OUT}"
|
||||
echo "${USAGE_OUT}"
|
||||
echo ""
|
||||
DIFF_TOTAL=$((DIFF_TOTAL+DIFF_OUT))
|
||||
fi
|
||||
else
|
||||
echo "?"
|
||||
echo "?"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Remember the total and idle CPU times for the next check.
|
||||
echo "${BYTES_IN}" > "${PREV_FILE}"
|
||||
echo "${BYTES_OUT}" >> "${PREV_FILE}"
|
||||
|
||||
if [[ "${DIFF_TOTAL}" -ge "${URGENT_VALUE}" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
BATTERY=0
|
||||
BATTERY_INFO=$(acpi -b | grep "Battery ${BATTERY}")
|
||||
BATTERY_STATE=$(echo "${BATTERY_INFO}" | grep -wo "Full\|Charging\|Not")
|
||||
BATTERY_POWER=$(echo "${BATTERY_INFO}" | grep -o '[0-9]\+%' | tr -d '%')
|
||||
|
||||
URGENT_VALUE=10
|
||||
|
||||
if [[ "${BATTERY_STATE}" = "Charging" ]]; then
|
||||
echo "${BATTERY_POWER}%+"
|
||||
echo "${BATTERY_POWER}%+"
|
||||
echo ""
|
||||
elif [[ "${BATTERY_STATE}" = "Not" ]]; then
|
||||
echo "${BATTERY_POWER}%-"
|
||||
echo "${BATTERY_POWER}%-"
|
||||
echo ""
|
||||
else
|
||||
echo "${BATTERY_POWER}%"
|
||||
echo "${BATTERY_POWER}%"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [[ "${BATTERY_POWER}" -le "${URGENT_VALUE}" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
@@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
|
||||
# One of the following: xrandr, xbacklight, kernel
|
||||
METHOD="xbacklight"
|
||||
|
||||
# Left click
|
||||
if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then
|
||||
~/.Scripts/ChangeWallpapers.sh
|
||||
#elif [[ "${BLOCK_BUTTON}" -eq 2 ]]; then
|
||||
# ~/.Scripts/ChangeWallpapers.sh
|
||||
#elif [[ "${BLOCK_BUTTON}" -eq 3 ]]; then
|
||||
# xbacklight -dec 10
|
||||
elif [[ "${BLOCK_BUTTON}" -eq 4 ]]; then
|
||||
xbacklight -inc 5
|
||||
elif [[ "${BLOCK_BUTTON}" -eq 5 ]]; then
|
||||
xbacklight -dec 5
|
||||
fi
|
||||
|
||||
URGENT_VALUE=10
|
||||
|
||||
if [[ "${METHOD}" = "xrandr" ]]; then
|
||||
device="${BLOCK_INSTANCE:-primary}"
|
||||
xrandrOutput=$(xrandr --verbose)
|
||||
|
||||
if [[ "${device}" = "primary" ]]; then
|
||||
device=$(echo "${xrandrOutput}" | grep 'primary' | head -n 1 | awk -F ' ' '{print $1}')
|
||||
fi
|
||||
|
||||
curBrightness=$(echo "${xrandrOutput}" | grep "${device}" -A 5 | grep -i "Brightness" | awk -F ':' '{print $2}')
|
||||
elif [[ "${METHOD}" = "kernel" ]]; then
|
||||
device="${BLOCK_INSTANCE:-intel_backlight}"
|
||||
maxBrightness=$(cat /sys/class/backlight/${device}/max_brightness)
|
||||
curBrightness=$(cat /sys/class/backlight/${device}/brightness)
|
||||
elif [[ "${METHOD}" = "xbacklight" ]]; then
|
||||
curBrightness=$(xbacklight -get)
|
||||
fi
|
||||
|
||||
if [[ "${curBrightness}" -le 0 ]]; then
|
||||
echo "X"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [[ "${METHOD}" = "xrandr" ]]; then
|
||||
percent=$(echo "scale=0;${curBrightness} * 100" | bc -l)
|
||||
elif [[ "${METHOD}" = "kernel" ]]; then
|
||||
percent=$(echo "scale=0;${curBrightness} / ${maxBrightness} * 100" | bc -l)
|
||||
elif [[ "${METHOD}" = "xbacklight" ]]; then
|
||||
percent=$(echo "scale=0;${curBrightness}" | bc -l)
|
||||
fi
|
||||
|
||||
percent=${percent%.*}
|
||||
|
||||
if [[ "${percent}" -le 0 ]]; then
|
||||
echo "X"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
echo "${percent}%"
|
||||
echo "${percent}%"
|
||||
echo ""
|
||||
|
||||
if [[ "${percent}" -le "${URGENT_VALUE}" ]]; then
|
||||
exit 33
|
||||
fi
|
||||
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
# Source: http://askubuntu.com/a/450136
|
||||
|
||||
URGENT_VALUE=90
|
||||
|
||||
PREV_TOTAL=0
|
||||
PREV_IDLE=0
|
||||
|
||||
cpuFile="/tmp/.cpu"
|
||||
|
||||
if [[ -f "${cpuFile}" ]]; then
|
||||
fileCont=$(cat "${cpuFile}")
|
||||
PREV_TOTAL=$(echo "${fileCont}" | head -n 1)
|
||||
PREV_IDLE=$(echo "${fileCont}" | tail -n 1)
|
||||
fi
|
||||
|
||||
CPU=(`cat /proc/stat | grep '^cpu '`) # Get the total CPU statistics.
|
||||
unset CPU[0] # Discard the "cpu" prefix.
|
||||
IDLE=${CPU[4]} # Get the idle CPU time.
|
||||
|
||||
# Calculate the total CPU time.
|
||||
TOTAL=0
|
||||
|
||||
for VALUE in "${CPU[@]:0:4}"; do
|
||||
let "TOTAL=$TOTAL+$VALUE"
|
||||
done
|
||||
|
||||
if [[ "${PREV_TOTAL}" != "" ]] && [[ "${PREV_IDLE}" != "" ]]; then
|
||||
# Calculate the CPU usage since we last checked.
|
||||
let "DIFF_IDLE=$IDLE-$PREV_IDLE"
|
||||
let "DIFF_TOTAL=$TOTAL-$PREV_TOTAL"
|
||||
let "DIFF_USAGE=(1000*($DIFF_TOTAL-$DIFF_IDLE)/$DIFF_TOTAL+5)/10"
|
||||
echo "${DIFF_USAGE}%"
|
||||
echo "${DIFF_USAGE}%"
|
||||
echo ""
|
||||
else
|
||||
echo "?"
|
||||
echo "?"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Remember the total and idle CPU times for the next check.
|
||||
echo "${TOTAL}" > "${cpuFile}"
|
||||
echo "${IDLE}" >> "${cpuFile}"
|
||||
|
||||
if [[ "${DIFF_USAGE}" -gt 0 ]] && [[ "${DIFF_USAGE}" -gt "${URGENT_VALUE}" ]]; then
|
||||
exit 33
|
||||
fi
|
||||
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
SSPID=$(pgrep -l fcitx |awk -F ' ' '{print $1}')
|
||||
|
||||
if [[ "${SSPID}" != "" ]]; then
|
||||
echo ""
|
||||
echo ""
|
||||
else
|
||||
echo ""
|
||||
echo ""
|
||||
fi
|
||||
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Left click
|
||||
if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then
|
||||
sudo ufw enable
|
||||
# Middle click
|
||||
elif [[ "${BLOCK_BUTTON}" -eq 2 ]]; then
|
||||
sudo ufw reload
|
||||
# Right click
|
||||
elif [[ "${BLOCK_BUTTON}" -eq 3 ]]; then
|
||||
sudo ufw disable
|
||||
fi
|
||||
|
||||
status=$(sudo ufw status 2>/dev/null)
|
||||
|
||||
if [[ $? -gt 0 ]]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
if [[ "${status}" != *inactive* ]]; then
|
||||
echo "on"
|
||||
echo "on"
|
||||
echo ""
|
||||
else
|
||||
echo "off"
|
||||
echo "off"
|
||||
echo ""
|
||||
fi
|
||||
@@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
|
||||
#if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then
|
||||
# termite -e alsamixer
|
||||
#elif [[ "${BLOCK_BUTTON}" -eq 4 ]]; then
|
||||
# amixer -q sset Master 2%+
|
||||
#elif [[ "${BLOCK_BUTTON}" -eq 5 ]]; then
|
||||
# amixer -q sset Master 2%-
|
||||
#fi
|
||||
VALUE=$(amixer -c 0 contents | \
|
||||
awk -F"," '
|
||||
$1 == "numid=14" {
|
||||
c=1
|
||||
} c && /: values/ {
|
||||
split($0, a, "=")
|
||||
print a[2];
|
||||
exit
|
||||
}')
|
||||
|
||||
if [[ "${VALUE}" == "on" ]]; then
|
||||
echo ""
|
||||
#else
|
||||
# echo ""
|
||||
# echo ""
|
||||
fi
|
||||
|
||||
|
||||
#from https://unix.stackexchange.com/questions/76375/how-do-i-detect-wheter-the-audio-cable-is-connected
|
||||
#One way could perhaps be to use amixer.
|
||||
|
||||
#Jack plugged in:
|
||||
|
||||
#$ amixer -c 0 contents
|
||||
#numid=29,iface=CARD,name='Front Headphone Jack'
|
||||
# ; type=BOOLEAN,access=r-------,values=1
|
||||
# : values=on
|
||||
#...
|
||||
#Jack not plugged in:
|
||||
|
||||
#$ amixer -c 0 contents
|
||||
#numid=29,iface=CARD,name='Front Headphone Jack'
|
||||
# ; type=BOOLEAN,access=r-------,values=1
|
||||
# : values=off
|
||||
#...
|
||||
#So for that specific one I could do:
|
||||
|
||||
#amixer -c 0 contents | \
|
||||
#awk -F"," '
|
||||
#$1 == "numid=own" { 此處的own的序號必須自己尋找
|
||||
# c=1
|
||||
#} c && /: values/ {
|
||||
# split($0, a, "=")
|
||||
# print a[2];
|
||||
# exit
|
||||
#}'
|
||||
#giving output of on or off.
|
||||
#
|
||||
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
TYPE="${BLOCK_INSTANCE:-caps}"
|
||||
|
||||
lockLine=$(xset -q | grep "Num Lock")
|
||||
|
||||
capsLock=$(echo "${lockLine}" | awk -F ' ' '{print $4}')
|
||||
numLock=$(echo "${lockLine}" | awk -F ' ' '{print $8}')
|
||||
|
||||
if [[ "${capsLock}" == "on" && "${numLock}" == "on" ]]; then
|
||||
echo " "
|
||||
echo ""
|
||||
elif [[ "${capsLock}" == "on" ]]; then
|
||||
echo ""
|
||||
echo ""
|
||||
elif [[ "${numLock}" == "on" ]]; then
|
||||
echo ""
|
||||
echo ""
|
||||
else
|
||||
exit
|
||||
fi
|
||||
@@ -0,0 +1,154 @@
|
||||
#!/usr/bin/env perl
|
||||
# Copyright (C) 2014 Tony Crisci <tony@dubstepdish.com>
|
||||
# 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/>.
|
||||
|
||||
# Requires playerctl binary to be in your path (except cmus)
|
||||
# See: https://github.com/acrisci/playerctl
|
||||
|
||||
# Set instance=NAME in the i3blocks configuration to specify a music player
|
||||
# (playerctl will attempt to connect to org.mpris.MediaPlayer2.[NAME] on your
|
||||
# DBus session).
|
||||
|
||||
use Time::HiRes qw(usleep);
|
||||
use Env qw(BLOCK_INSTANCE);
|
||||
|
||||
use constant DELAY => 50; # Delay in ms to let network-based players (spotify) reflect new data.
|
||||
use constant SPOTIFY_STR => 'spotify';
|
||||
|
||||
my @metadata = ();
|
||||
my $player_arg = "";
|
||||
|
||||
if ($BLOCK_INSTANCE) {
|
||||
$player_arg = "--player='$BLOCK_INSTANCE'";
|
||||
}
|
||||
|
||||
sub buttons {
|
||||
my $method = shift;
|
||||
|
||||
if($method eq 'mpd') {
|
||||
if ($ENV{'BLOCK_BUTTON'} == 1) {
|
||||
system("mpc prev");
|
||||
} elsif ($ENV{'BLOCK_BUTTON'} == 2) {
|
||||
system("mpc toggle");
|
||||
} elsif ($ENV{'BLOCK_BUTTON'} == 3) {
|
||||
system("mpc next");
|
||||
} elsif ($ENV{'BLOCK_BUTTON'} == 4) {
|
||||
system("mpc volume +10");
|
||||
} elsif ($ENV{'BLOCK_BUTTON'} == 5) {
|
||||
system("mpc volume -10");
|
||||
}
|
||||
} elsif ($method eq 'cmus') {
|
||||
if ($ENV{'BLOCK_BUTTON'} == 1) {
|
||||
system("cmus-remote --prev");
|
||||
} elsif ($ENV{'BLOCK_BUTTON'} == 2) {
|
||||
system("cmus-remote --pause");
|
||||
} elsif ($ENV{'BLOCK_BUTTON'} == 3) {
|
||||
system("cmus-remote --next");
|
||||
}
|
||||
} elsif ($method eq 'playerctl') {
|
||||
if ($ENV{'BLOCK_BUTTON'} == 1) {
|
||||
system("playerctl $player_arg previous");
|
||||
usleep(DELAY * 1000) if $BLOCK_INSTANCE eq SPOTIFY_STR;
|
||||
} elsif ($ENV{'BLOCK_BUTTON'} == 2) {
|
||||
system("playerctl $player_arg play-pause");
|
||||
} elsif ($ENV{'BLOCK_BUTTON'} == 3) {
|
||||
system("playerctl $player_arg next");
|
||||
usleep(DELAY * 1000) if $BLOCK_INSTANCE eq SPOTIFY_STR;
|
||||
} elsif ($ENV{'BLOCK_BUTTON'} == 4) {
|
||||
system("playerctl $player_arg volume 0.01+");
|
||||
} elsif ($ENV{'BLOCK_BUTTON'} == 5) {
|
||||
system("playerctl $player_arg volume 0.01-");
|
||||
}
|
||||
} elsif ($method eq 'rhythmbox') {
|
||||
if ($ENV{'BLOCK_BUTTON'} == 1) {
|
||||
system("rhythmbox-client --previous");
|
||||
} elsif ($ENV{'BLOCK_BUTTON'} == 2) {
|
||||
system("rhythmbox-client --play-pause");
|
||||
} elsif ($ENV{'BLOCK_BUTTON'} == 3) {
|
||||
system("rhythmbox-client --next");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub cmus {
|
||||
my @cmus = split /^/, qx(cmus-remote -Q);
|
||||
if ($? == 0) {
|
||||
foreach my $line (@cmus) {
|
||||
my @data = split /\s/, $line;
|
||||
if (shift @data eq 'tag') {
|
||||
my $key = shift @data;
|
||||
my $value = join ' ', @data;
|
||||
|
||||
@metadata[0] = $value if $key eq 'artist';
|
||||
@metadata[1] = $value if $key eq 'title';
|
||||
}
|
||||
}
|
||||
|
||||
if (@metadata) {
|
||||
buttons('cmus');
|
||||
|
||||
# metadata found so we are done
|
||||
print(join ' - ', @metadata);
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub mpd {
|
||||
my $data = qx(mpc current);
|
||||
if (not $data eq '') {
|
||||
buttons("mpd");
|
||||
print($data);
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
|
||||
sub playerctl {
|
||||
buttons('playerctl');
|
||||
|
||||
my $artist = qx(playerctl $player_arg metadata artist);
|
||||
# exit status will be nonzero when playerctl cannot find your player
|
||||
exit(0) if $? || $artist eq '(null)';
|
||||
|
||||
push(@metadata, $artist) if $artist;
|
||||
|
||||
my $title = qx(playerctl $player_arg metadata title);
|
||||
exit(0) if $? || $title eq '(null)';
|
||||
|
||||
push(@metadata, $title) if $title;
|
||||
|
||||
print(join(" - ", @metadata)) if @metadata;
|
||||
}
|
||||
|
||||
sub rhythmbox {
|
||||
buttons('rhythmbox');
|
||||
|
||||
my $data = qx(rhythmbox-client --print-playing --no-start);
|
||||
print($data);
|
||||
}
|
||||
|
||||
if ($player_arg eq '' or $player_arg =~ /mpd/) {
|
||||
mpd;
|
||||
}
|
||||
elsif ($player_arg =~ /cmus/) {
|
||||
cmus;
|
||||
}
|
||||
elsif ($player_arg =~ /rhythmbox/) {
|
||||
rhythmbox;
|
||||
}
|
||||
else {
|
||||
playerctl;
|
||||
}
|
||||
@@ -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("%.f%%\n",pct)
|
||||
|
||||
# short text
|
||||
printf("%.f%%\n", pct)
|
||||
|
||||
# color
|
||||
if (pct > 90) {
|
||||
print("#FF0000\n")
|
||||
} else if (pct > 80) {
|
||||
print("#FFAE00\n")
|
||||
} else if (pct > 70) {
|
||||
print("#FFF600\n")
|
||||
}
|
||||
}
|
||||
' /proc/meminfo
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Left click
|
||||
if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then
|
||||
amixer -q sset Capture 5%+
|
||||
# Middle click
|
||||
elif [[ "${BLOCK_BUTTON}" -eq 2 ]]; then
|
||||
amixer -q sset Capture toggle
|
||||
# Right click
|
||||
elif [[ "${BLOCK_BUTTON}" -eq 3 ]]; then
|
||||
amixer -q sset Capture 5%-
|
||||
fi
|
||||
|
||||
statusLine=$(amixer get Capture | tail -n 1)
|
||||
status=$(echo "${statusLine}" | grep -wo "on")
|
||||
volume=$(echo "${statusLine}" | awk -F ' ' '{print $5}' | tr -d '[]%')
|
||||
|
||||
if [[ "${status}" == "on" ]]; then
|
||||
echo "${volume}%"
|
||||
echo "${volume}%"
|
||||
echo ""
|
||||
else
|
||||
echo "off"
|
||||
echo "off"
|
||||
echo ""
|
||||
fi
|
||||
@@ -0,0 +1,188 @@
|
||||
#!/bin/bash
|
||||
# IMPORTANT:
|
||||
# To make this block work, you have to edit your block-command.
|
||||
# It should point to this file. For best performance, only use it on blocks
|
||||
# you want to monitor.
|
||||
#
|
||||
# Example:
|
||||
# command=~/.i3-blocks/blocks/notifier $BLOCK_NAME
|
||||
echo "ss"
|
||||
echo "ss"
|
||||
echo ""
|
||||
|
||||
BLOCK_NAME="${1}"
|
||||
|
||||
if [[ "${BLOCK_NAME}" == "" ]] || [[ "${BLOCK_NAME}" == "notifier" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
BLOCK_PATH="${SCRIPT_DIR}/${BLOCK_NAME}"
|
||||
|
||||
if [[ ! -f "${BLOCK_PATH}" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BLOCK_OUT=$(bash "${BLOCK_PATH}")
|
||||
BLOCK_URGENT=$?
|
||||
|
||||
# Nothing to display.
|
||||
if [[ "${BLOCK_OUT}" == "" ]]; then
|
||||
exit "${BLOCK_URGENT}"
|
||||
fi
|
||||
|
||||
NOTIFY=0
|
||||
|
||||
NOTIFY_CHANGES="weather display"
|
||||
NOTIFY_ALWAYS=""
|
||||
NOTIFY_NEVER="launcher playerctl scroll"
|
||||
|
||||
if [[ "${NOTIFY_NEVER}" != *${BLOCK_NAME}* ]]; then
|
||||
BLOCK_UCFIRST=$(echo "${BLOCK_NAME}" | head -c 1 | tr [a-z] [A-Z]; echo "${BLOCK_NAME}" | tail -c +2)
|
||||
|
||||
CHECK_SUM=$(echo "${BLOCK_NAME}-${BLOCK_INSTANCE}" | md5sum | awk '{print $1}')
|
||||
CACHE_FILE="/tmp/.notify-cache-${CHECK_SUM}"
|
||||
|
||||
BLOCK_DESC=$(echo "${BLOCK_OUT}" | head -n 1)
|
||||
BLOCK_VALUE=$(echo "${BLOCK_OUT}" | tail -n 1)
|
||||
BLOCK_ICON=""
|
||||
|
||||
if [[ "${NOTIFY_ALWAYS}" == *${BLOCK_NAME}* ]]; then
|
||||
NOTIFY=1
|
||||
elif [[ "${BLOCK_URGENT}" -gt 0 ]]; then
|
||||
NOTIFY=1
|
||||
fi
|
||||
|
||||
VALUE_CHANGED=0
|
||||
HAS_CACHEFILE=0
|
||||
if [[ -f "${CACHE_FILE}" ]]; then
|
||||
HAS_CACHEFILE=1
|
||||
CACHED_VALUE=$(cat "${CACHE_FILE}")
|
||||
#MODIFIED_TIME=$(stat -c '%Y' "${CACHE_FILE}")
|
||||
#CURRENT_TIME=$(date +%s)
|
||||
#ELAPSED_TIME=$((MODIFIED_TIME - CURRENT_TIME))
|
||||
if [[ "${BLOCK_VALUE}" != "${CACHED_VALUE}" ]]; then
|
||||
VALUE_CHANGED=1
|
||||
if [[ "${NOTIFY_CHANGES}" == *${BLOCK_NAME}* ]]; then
|
||||
NOTIFY=1
|
||||
fi
|
||||
fi
|
||||
elif [[ "${NOTIFY_CHANGES}" == *${BLOCK_NAME}* ]]; then
|
||||
NOTIFY=1
|
||||
fi
|
||||
|
||||
if [[ "${NOTIFY}" -eq 1 ]]; then
|
||||
if [[ "${BLOCK_NAME}" == "audio" ]]; then
|
||||
BLOCK_MESSAGE="Audio level changed to ${BLOCK_VALUE}."
|
||||
elif [[ "${BLOCK_NAME}" == "bandwidth" ]]; then
|
||||
BLOCK_MESSAGE="Traffic went to ${BLOCK_VALUE}."
|
||||
elif [[ "${BLOCK_NAME}" == "battery" ]]; then
|
||||
BLOCK_MESSAGE="Energy changed to ${BLOCK_VALUE}."
|
||||
elif [[ "${BLOCK_NAME}" == "countdown" ]]; then
|
||||
BLOCK_MESSAGE="Remaining time is now ${BLOCK_VALUE}."
|
||||
elif [[ "${BLOCK_NAME}" == "cpu" ]]; then
|
||||
BLOCK_MESSAGE="CPU utilization is now ${BLOCK_VALUE}."
|
||||
elif [[ "${BLOCK_NAME}" == "feed" ]]; then
|
||||
BLOCK_MESSAGE="Newest article is ${BLOCK_VALUE}."
|
||||
elif [[ "${BLOCK_NAME}" == "mail" ]]; then
|
||||
BLOCK_MESSAGE="Unread emails went to ${BLOCK_VALUE}."
|
||||
elif [[ "${BLOCK_NAME}" == "memory" ]]; then
|
||||
BLOCK_MESSAGE="Memory utilization is now ${BLOCK_VALUE}."
|
||||
elif [[ "${BLOCK_NAME}" == "packages" ]]; then
|
||||
BLOCK_MESSAGE="${BLOCK_VALUE} packages are now ready to update."
|
||||
elif [[ "${BLOCK_NAME}" == "space" ]]; then
|
||||
BLOCK_MESSAGE="Space utilization is now ${BLOCK_INSTANCE}."
|
||||
elif [[ "${BLOCK_NAME}" == "ssid" ]]; then
|
||||
BLOCK_MESSAGE="SSID changed to ${BLOCK_VALUE}."
|
||||
elif [[ "${BLOCK_NAME}" == "temperature" ]]; then
|
||||
BLOCK_MESSAGE="Sensor temperature changed to ${BLOCK_VALUE}."
|
||||
elif [[ "${BLOCK_NAME}" == "trash" ]]; then
|
||||
BLOCK_MESSAGE="${BLOCK_VALUE} items are now in the trash."
|
||||
else
|
||||
BLOCK_MESSAGE="${BLOCK_UCFIRST} is now ${BLOCK_VALUE}."
|
||||
fi
|
||||
|
||||
if [[ "${BLOCK_NAME}" == "audio" ]]; then
|
||||
BLOCK_ICON="audio-volume-high-symbolic"
|
||||
elif [[ "${BLOCK_NAME}" == "bandwidth" ]]; then
|
||||
BLOCK_ICON="network-wireless-acquiring-symbolic"
|
||||
elif [[ "${BLOCK_NAME}" == "battery" ]]; then
|
||||
BLOCK_ICON="battery-symbolic"
|
||||
elif [[ "${BLOCK_NAME}" == "bluetooth" ]]; then
|
||||
BLOCK_ICON="bluetooth-active-symbolic"
|
||||
elif [[ "${BLOCK_NAME}" == "brightness" ]]; then
|
||||
BLOCK_ICON="display-brightness-symbolic"
|
||||
elif [[ "${BLOCK_NAME}" == "cmus" ]]; then
|
||||
BLOCK_ICON="emblem-music-symbolic"
|
||||
elif [[ "${BLOCK_NAME}" == "countdown" ]]; then
|
||||
BLOCK_ICON="document-open-recent-symbolic"
|
||||
elif [[ "${BLOCK_NAME}" == "cpu" ]]; then
|
||||
BLOCK_ICON="indicator-cpufreq"
|
||||
elif [[ "${BLOCK_NAME}" == "datetime" ]]; then
|
||||
BLOCK_ICON="system-run-symbolic" # TODO
|
||||
elif [[ "${BLOCK_NAME}" == "device" ]]; then
|
||||
BLOCK_ICON="system-run-symbolic" # TODO
|
||||
elif [[ "${BLOCK_NAME}" == "display" ]]; then
|
||||
BLOCK_ICON="video-display-symbolic"
|
||||
elif [[ "${BLOCK_NAME}" == "feed" ]]; then
|
||||
BLOCK_ICON="folder-documents-symbolic"
|
||||
elif [[ "${BLOCK_NAME}" == "firewall" ]]; then
|
||||
BLOCK_ICON="changes-prevent-symbolic.svg" # TODO
|
||||
elif [[ "${BLOCK_NAME}" == "ip-address" ]]; then
|
||||
BLOCK_ICON="avatar-default-symbolic" # TODO
|
||||
elif [[ "${BLOCK_NAME}" == "keystate" ]]; then
|
||||
BLOCK_ICON="format-text-underline-symbolic" # TODO
|
||||
elif [[ "${BLOCK_NAME}" == "launcher" ]]; then
|
||||
BLOCK_ICON="system-run-symbolic"
|
||||
elif [[ "${BLOCK_NAME}" == "load" ]]; then
|
||||
BLOCK_ICON="indicator-cpufreq" # TODO
|
||||
elif [[ "${BLOCK_NAME}" == "locale" ]]; then
|
||||
BLOCK_ICON="format-text-larger-symbolic"
|
||||
elif [[ "${BLOCK_NAME}" == "mail" ]]; then
|
||||
BLOCK_ICON="mail-send-symbolic"
|
||||
elif [[ "${BLOCK_NAME}" == "memory" ]]; then
|
||||
BLOCK_ICON="drive-harddisk-solidstate-symbolic" # TODO
|
||||
elif [[ "${BLOCK_NAME}" == "microphone" ]]; then
|
||||
BLOCK_ICON="audio-input-microphone-symbolic"
|
||||
elif [[ "${BLOCK_NAME}" == "network" ]]; then
|
||||
BLOCK_ICON="network-wireless-connected-symbolic"
|
||||
elif [[ "${BLOCK_NAME}" == "packages" ]]; then
|
||||
BLOCK_ICON="view-refresh-symbolic"
|
||||
elif [[ "${BLOCK_NAME}" == "playerctl" ]]; then
|
||||
BLOCK_ICON="emblem-music-symbolic"
|
||||
elif [[ "${BLOCK_NAME}" == "process" ]]; then
|
||||
BLOCK_ICON="process-stop-symbolic"
|
||||
elif [[ "${BLOCK_NAME}" == "space" ]]; then
|
||||
BLOCK_ICON="drive-harddisk-solidstate-symbolic" # TODO
|
||||
elif [[ "${BLOCK_NAME}" == "ssid" ]]; then
|
||||
BLOCK_ICON="system-users-symbolic"
|
||||
elif [[ "${BLOCK_NAME}" == "temperature" ]]; then
|
||||
BLOCK_ICON="object-inverse" # TODO
|
||||
elif [[ "${BLOCK_NAME}" == "trash" ]]; then
|
||||
BLOCK_ICON="user-trash-symbolic"
|
||||
elif [[ "${BLOCK_NAME}" == "usb" ]]; then
|
||||
BLOCK_ICON="drive-removable-media-usb-symbolic-1"
|
||||
elif [[ "${BLOCK_NAME}" == "vpn" ]]; then
|
||||
BLOCK_ICON="dialog-password-symbolic" # TODO
|
||||
elif [[ "${BLOCK_NAME}" == "weather" ]]; then
|
||||
BLOCK_ICON="weather-few-clouds-symbolic"
|
||||
elif [[ "${BLOCK_NAME}" == "webcam" ]]; then
|
||||
BLOCK_ICON="camera-web-symbolic"
|
||||
elif [[ "${BLOCK_NAME}" == "window" ]]; then
|
||||
BLOCK_ICON="view-dual-symbolic" # TODO
|
||||
fi
|
||||
|
||||
if [[ "${BLOCK_URGENT}" -gt 0 ]]; then
|
||||
notify-send -u critical -t 5000 -i "${BLOCK_ICON}" -a "i3block-${BLOCK_NAME}" "${BLOCK_UCFIRST}" "${BLOCK_MESSAGE}"
|
||||
else
|
||||
notify-send -u normal -t 3500 -i "${BLOCK_ICON}" -a "i3block-${BLOCK_NAME}" "${BLOCK_UCFIRST}" "${BLOCK_MESSAGE}"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "${VALUE_CHANGED}" -eq 1 ]] || [[ "${HAS_CACHEFILE}" -eq 0 ]]; then
|
||||
echo "${BLOCK_VALUE}" > "${CACHE_FILE}"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "${BLOCK_OUT}"
|
||||
exit "${BLOCK_URGENT}"
|
||||
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
# Based on https://aur.archlinux.org/packages/playerctl/
|
||||
|
||||
INSTANCE="${BLOCK_INSTANCE}"
|
||||
if [[ "${INSTANCE}" != "" ]]; then
|
||||
ARGUMENTS="--player ${INSTANCE}"
|
||||
fi
|
||||
|
||||
ICON_PLAY="➤"
|
||||
ICON_PAUSE="Ⅱ"
|
||||
ICON_STOP="≠"
|
||||
CUR_ICON=""
|
||||
|
||||
if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then
|
||||
$(playerctl ${ARGUMENTS} previous)
|
||||
elif [[ "${BLOCK_BUTTON}" -eq 2 ]]; then
|
||||
$(playerctl ${ARGUMENTS} play-pause)
|
||||
elif [[ "${BLOCK_BUTTON}" -eq 3 ]]; then
|
||||
$(playerctl ${ARGUMENTS} next)
|
||||
elif [[ "${BLOCK_BUTTON}" -eq 4 ]]; then
|
||||
$(playerctl ${ARGUMENTS} volume 0.2+)
|
||||
elif [[ "${BLOCK_BUTTON}" -eq 5 ]]; then
|
||||
$(playerctl ${ARGUMENTS} volume 0.2-)
|
||||
fi
|
||||
|
||||
PLAYER_STATUS=$(playerctl ${ARGUMENTS} status)
|
||||
INFO_TITLE=$(playerctl ${ARGUMENTS} metadata title)
|
||||
INFO_ALBUM=$(playerctl ${ARGUMENTS} metadata album)
|
||||
INFO_ARTIST=$(playerctl ${ARGUMENTS} metadata artist)
|
||||
|
||||
if [[ "${PLAYER_STATUS}" = "Paused" ]]; then
|
||||
CUR_ICON="${ICON_PAUSE}"
|
||||
elif [[ "${PLAYER_STATUS}" = "Playing" ]]; then
|
||||
CUR_ICON="${ICON_PLAY}"
|
||||
else
|
||||
CUR_ICON="${ICON_STOP}"
|
||||
fi
|
||||
|
||||
if [[ "${INFO_TITLE}" != "" ]] && [[ "${INFO_ARTIST}" != "" ]]; then
|
||||
echo "${INFO_ARTIST} - ${INFO_TITLE} ${CUR_ICON}"
|
||||
echo "${INFO_ARTIST} - ${INFO_TITLE} ${CUR_ICON}"
|
||||
fi
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then
|
||||
termite -e nmtui
|
||||
fi
|
||||
|
||||
SSID_NAME=$(iwgetid -r)
|
||||
|
||||
# You can put any urgent name so the block will give warning
|
||||
# if a network with this name is used, like public wifi or alike.
|
||||
# You can separate multiple values with \|
|
||||
URGENT_VALUE=""
|
||||
|
||||
if [[ "${SSID_NAME}" != "" ]]; then
|
||||
echo "${SSID_NAME}"
|
||||
echo "${SSID_NAME}"
|
||||
echo ""
|
||||
|
||||
if [[ "${URGENT_VALUE}" != "" ]] && [[ $(echo "${SSID_NAME}" | grep -we "${URGENT_VALUE}") != "" ]]; then
|
||||
exit 33
|
||||
fi
|
||||
else
|
||||
echo "x"
|
||||
echo "x"
|
||||
echo ""
|
||||
fi
|
||||
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
SSPID=$(pgrep -l sslocal |awk -F ' ' '{print $1}')
|
||||
|
||||
if [[ "${SSPID}" != "" ]]; then
|
||||
echo ""
|
||||
echo ""
|
||||
else
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
fi
|
||||
@@ -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 = 70;
|
||||
my $t_crit = 90;
|
||||
my $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;
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
TIME=$(date '+%a %b %d %H:%M')
|
||||
|
||||
echo "${TIME}"
|
||||
echo "${TIME}"
|
||||
echo ""
|
||||
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
DEVICE_NAME="${BLOCK_INSTANCE:-Keyboard}"
|
||||
|
||||
DEVICE_INFO=$(lsusb | grep -i kingston)
|
||||
|
||||
if [[ "${DEVICE_INFO}" != "" ]]; then
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
@@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Left click
|
||||
if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then
|
||||
termite -e alsamixer
|
||||
# amixer -q sset Master 10%+
|
||||
# Middle click
|
||||
elif [[ "${BLOCK_BUTTON}" -eq 2 ]]; then
|
||||
amixer -q sset Master toggle
|
||||
# Right click
|
||||
#elif [[ "${BLOCK_BUTTON}" -eq 2 ]]; then
|
||||
# amixer -q sset Master 10%-
|
||||
elif [[ "${BLOCK_BUTTON}" -eq 4 ]]; then
|
||||
amixer -q sset Master 2%+
|
||||
elif [[ "${BLOCK_BUTTON}" -eq 5 ]]; then
|
||||
amixer -q sset Master 2%-
|
||||
fi
|
||||
|
||||
statusLine=$(amixer get Master | tail -n 1)
|
||||
status=$(echo "${statusLine}" | grep -wo "on")
|
||||
|
||||
volume=$(echo "${statusLine}" | awk -F ' ' '{print $4}' | tr -d '[]%')
|
||||
|
||||
VALUE=$(amixer -c 0 contents | \
|
||||
awk -F"," '
|
||||
$1 == "numid=14" {
|
||||
c=1s
|
||||
} c && /: values/ {
|
||||
split($0, a, "=")
|
||||
print a[2];
|
||||
exit
|
||||
}')
|
||||
|
||||
|
||||
if [[ "${status}" = "on" && "${VALUE}" = "on" ]]; then
|
||||
# if [[ "${VALUE}" = "on" ]]; then
|
||||
echo " ${volume}%"
|
||||
echo " ${volume}%"
|
||||
echo ""
|
||||
# elif
|
||||
# echo " ${volume}%"
|
||||
# echo " ${volume}%"
|
||||
# echo ""
|
||||
# fi
|
||||
elif [[ "${status}" = "on" && "${VALUE}" = "off" ]]; then
|
||||
echo " ${volume}%"
|
||||
echo ""
|
||||
else
|
||||
echo " 00%"
|
||||
echo " 00%"
|
||||
echo ""
|
||||
fi
|
||||
@@ -0,0 +1,55 @@
|
||||
#!/bin/bash
|
||||
# Based on http://openweathermap.org/current
|
||||
|
||||
API_KEY="8ca3ef456139c165488fb6a6f00739ed"
|
||||
|
||||
# Check on http://openweathermap.org/find
|
||||
CITY_ID="${BLOCK_INSTANCE}"
|
||||
|
||||
URGENT_LOWER=0
|
||||
URGENT_HIGHER=30
|
||||
|
||||
ICON_SUNNY=""
|
||||
ICON_CLOUDY=""
|
||||
ICON_RAINY=""
|
||||
ICON_STORM=""
|
||||
ICON_SNOW=""
|
||||
ICON_FOG=""
|
||||
|
||||
SYMBOL_CELSIUS="℃"
|
||||
# WEATHER_URL="http://api.openweathermap.org/data/2.5/weather?id="1808773"&appid="44db6a862fba0b067b1930da0d769e98"$&units=metric"
|
||||
WEATHER_URL="https://api.openweathermap.org/data/2.5/weather?id=${CITY_ID}&appid=${API_KEY}&units=metric"
|
||||
|
||||
WEATHER_INFO=$(wget -qO- "${WEATHER_URL}")
|
||||
WEATHER_MAIN=$(echo "${WEATHER_INFO}" | grep -o -e '\"main\":\"[a-Z]*\"' | awk -F ':' '{print $2}' | tr -d '"')
|
||||
WEATHER_TEMP=$(echo "${WEATHER_INFO}" | grep -o -e '\"temp\":\-\?[0-9]*' | awk -F ':' '{print $2}' | tr -d '"')
|
||||
|
||||
if [[ "${WEATHER_MAIN}" = *Snow* ]]; then
|
||||
echo "${ICON_SNOW} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
|
||||
echo "${ICON_SNOW} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
|
||||
echo ""
|
||||
elif [[ "${WEATHER_MAIN}" = *Rain* ]] || [[ "${WEATHER_MAIN}" = *Drizzle* ]]; then
|
||||
echo "${ICON_RAINY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
|
||||
echo "${ICON_RAINY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
|
||||
echo ""
|
||||
elif [[ "${WEATHER_MAIN}" = *Cloud* ]]; then
|
||||
echo "${ICON_CLOUDY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
|
||||
echo "${ICON_CLOUDY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
|
||||
echo ""
|
||||
elif [[ "${WEATHER_MAIN}" = *Clear* ]]; then
|
||||
echo "${ICON_SUNNY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
|
||||
echo "${ICON_SUNNY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
|
||||
echo ""
|
||||
elif [[ "${WEATHER_MAIN}" = *Fog* ]] || [[ "${WEATHER_MAIN}" = *Mist* ]]; then
|
||||
echo "${ICON_FOG} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
|
||||
echo "${ICON_FOG} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
|
||||
echo ""
|
||||
else
|
||||
echo "${WEATHER_MAIN} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
|
||||
echo "${WEATHER_MAIN} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [[ "${WEATHER_TEMP}" -lt "${URGENT_LOWER}" ]] || [[ "${WEATHER_TEMP}" -gt "${URGENT_HIGHER}" ]]; then
|
||||
exit 33
|
||||
fi
|
||||
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ -c /dev/video0 ]]; then
|
||||
if [[ "$(fuser /dev/video0)" != "" ]]; then
|
||||
echo "rec"
|
||||
echo "rec"
|
||||
echo ""
|
||||
else
|
||||
echo "on"
|
||||
echo "on"
|
||||
echo ""
|
||||
else
|
||||
echo "off"
|
||||
echo "off"
|
||||
echo ""
|
||||
fi
|
||||
fi
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
ACTIVE_WINDOW=$(xprop -id $(xprop -root _NET_ACTIVE_WINDOW | cut -d ' ' -f 5) WM_NAME | cut -d '"' -f 2)
|
||||
|
||||
if [[ "${ACTIVE_WINDOW}" != "" ]]; then
|
||||
echo "${ACTIVE_WINDOW}"
|
||||
echo "${ACTIVE_WINDOW}"
|
||||
echo ""
|
||||
fi
|
||||
Reference in New Issue
Block a user