initial commit
This commit is contained in:
64
files/configs/i3/myi3blocks/myi3battery
Executable file
64
files/configs/i3/myi3blocks/myi3battery
Executable file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
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 = ' ' . $full_text;
|
||||
} elsif ($status eq 'Charging') {
|
||||
$full_text = '⚡ ' . $full_text;
|
||||
} else {
|
||||
$full_text = '☻ ' . $full_text;
|
||||
}
|
||||
|
||||
$short_text = $full_text;
|
||||
|
||||
if ($acpi =~ /(\d\d:\d\d):/) {
|
||||
$full_text .= " ($1)";
|
||||
}
|
||||
|
||||
# print text
|
||||
print "$full_text\n";
|
||||
print "$short_text\n";
|
||||
|
||||
# consider color and urgent flag only on discharge
|
||||
if ($status eq 'Discharging') {
|
||||
|
||||
if ($percent < 20) {
|
||||
print "#FF0000\n";
|
||||
} elsif ($percent < 40) {
|
||||
print "#FFAE00\n";
|
||||
} elsif ($percent < 60) {
|
||||
print "#FFF600\n";
|
||||
} elsif ($percent < 85) {
|
||||
print "#A8FF00\n";
|
||||
}
|
||||
|
||||
if ($percent < 5) {
|
||||
exit(33);
|
||||
}
|
||||
}
|
||||
|
||||
exit(0);
|
||||
8
files/configs/i3/myi3blocks/myi3date
Executable file
8
files/configs/i3/myi3blocks/myi3date
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo $(date '+%a, %b %d %I:%M %p')
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) gsimplecal ;;
|
||||
*) ;;
|
||||
esac
|
||||
22
files/configs/i3/myi3blocks/myi3load
Executable file
22
files/configs/i3/myi3blocks/myi3load
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
readonly LOAD_AVG=$(cat /proc/loadavg | awk '{print $1,$2,$3}')
|
||||
LOAD_AVG_1m=$(echo ${LOAD_AVG} | awk '{print $1}')
|
||||
|
||||
echo "${LOAD_AVG}"
|
||||
echo "${LOAD_AVG}"
|
||||
|
||||
if (( $(echo "$LOAD_AVG_1m > 5.0" | bc -l) ))
|
||||
then
|
||||
echo "#FF6666"
|
||||
elif (( $(echo "$LOAD_AVG_1m > 2.5" | bc -l) ))
|
||||
then
|
||||
echo "#FFBF00"
|
||||
else
|
||||
echo "#33CC33"
|
||||
fi
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) gnome-terminal -- htop ;;
|
||||
*) ;;
|
||||
esac
|
||||
6
files/configs/i3/myi3blocks/myi3memory
Executable file
6
files/configs/i3/myi3blocks/myi3memory
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
MEM_STAT=$(free -m | grep Mem | awk '{print $2,$3}')
|
||||
MEM_USED_MB=${MEM_STAT##* }
|
||||
MEM_USED_GB=$(echo "scale=2;$MEM_USED_MB/1024" | bc -l)
|
||||
echo "$MEM_USED_GB GB"
|
||||
18
files/configs/i3/myi3blocks/myi3temp
Executable file
18
files/configs/i3/myi3blocks/myi3temp
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
readonly TEMP_RAW=$(sensors | grep Package | sed -n "s/.*+\(.*C\) .*/\1/p")
|
||||
|
||||
echo "${TEMP_RAW}"
|
||||
echo "${TEMP_RAW}"
|
||||
|
||||
TEMP_ROUND=${TEMP_RAW%.*}
|
||||
|
||||
if (( $(echo "$TEMP_ROUND > 80" | bc -l) ))
|
||||
then
|
||||
echo "#FF6666"
|
||||
elif (( $(echo "$TEMP_ROUND > 60" | bc -l) ))
|
||||
then
|
||||
echo "#FFBF00"
|
||||
else
|
||||
echo "#33CC33"
|
||||
fi
|
||||
59
files/configs/i3/myi3blocks/myi3weather
Executable file
59
files/configs/i3/myi3blocks/myi3weather
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
# Based on http://openweathermap.org/current
|
||||
|
||||
API_KEY="e0160e7f77434e10242b1d7bab182e19"
|
||||
|
||||
# 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=${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}" = *Thunderstorm* ]]; then
|
||||
echo "${ICON_STORM} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
|
||||
echo "${ICON_STORM} ${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
|
||||
Reference in New Issue
Block a user