mirror of
https://github.com/Foltik/dotfiles
synced 2025-01-05 15:58:03 -05:00
Add i3blocks config
This commit is contained in:
parent
63e2ac17a2
commit
5d4d45506d
19
config/i3blocks/laptop/blocks/audio
Executable file
19
config/i3blocks/laptop/blocks/audio
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Left click
|
||||
if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then
|
||||
pactl set-sink-volume 0 +5%
|
||||
# Middle click
|
||||
elif [[ "${BLOCK_BUTTON}" -eq 2 ]]; then
|
||||
pactl set-sink-mute 0 toggle
|
||||
# Right click
|
||||
elif [[ "${BLOCK_BUTTON}" -eq 3 ]]; then
|
||||
pactl set-sink-volume 0 -5%
|
||||
fi
|
||||
|
||||
volume=$(pactl list sinks | grep '^[[:space:]]Volume:' | \
|
||||
head -n $(( $SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,')
|
||||
|
||||
echo "${volume}%"
|
||||
echo "${volume}%"
|
||||
echo ""
|
98
config/i3blocks/laptop/blocks/bandwidth
Executable file
98
config/i3blocks/laptop/blocks/bandwidth
Executable file
@ -0,0 +1,98 @@
|
||||
#!/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
|
||||
echo $(echo "scale=0;${1}/${ONE_MB}" | bc -l)"mb"
|
||||
elif [[ "${1}" -ge "${TEN_MB}" ]]; then
|
||||
echo $(echo "scale=1;${1}/${ONE_MB}" | bc -l)"mb"
|
||||
elif [[ "${1}" -ge "${ONE_MB}" ]]; then
|
||||
echo $(echo "scale=2;${1}/${ONE_MB}" | bc -l)"mb"
|
||||
elif [[ "${1}" -ge "${ONE_KB}" ]]; then
|
||||
echo $(echo "scale=0;${1}/${ONE_KB}" | bc -l)"kb"
|
||||
else
|
||||
echo "${1}""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 33
|
||||
fi
|
37
config/i3blocks/laptop/blocks/battery
Executable file
37
config/i3blocks/laptop/blocks/battery
Executable file
@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
BATTERY=$(echo "${BLOCK_INSTANCE}" | awk -F ';' '{print $1}')
|
||||
OPT=$(echo "${BLOCK_INSTANCE}" | awk -F ';' '{print $2}')
|
||||
BATTERY_INFO=$(acpi -b | grep "Battery ${BATTERY}")
|
||||
BATTERY_STATE=$(echo "${BATTERY_INFO}" | grep -wo "Full\|Charging\|Discharging")
|
||||
BATTERY_POWER=$(echo "${BATTERY_INFO}" | grep -o '[0-9]\+%' | tr -d '%')
|
||||
BATTERY_REMAINING=$(acpi -b | grep remaining | awk '{print $5}')
|
||||
|
||||
URGENT_VALUE=10
|
||||
if [[ "${BATTERY_STATE}" = "Charging" ]]; then
|
||||
if [[ "${OPT}" = "rem" ]]; then
|
||||
echo "${BATTERY_POWER}%+ ${BATTERY_REMAINING}"
|
||||
echo "${BATTERY_POWER}%+ ${BATTERY_REMAINING}"
|
||||
else
|
||||
echo "${BATTERY_POWER}%+"
|
||||
echo "${BATTERY_POWER}%+"
|
||||
fi
|
||||
echo ""
|
||||
elif [[ "${BATTERY_STATE}" = "Discharging" ]]; then
|
||||
if [[ "${OPT}" = "rem" ]]; then
|
||||
echo "${BATTERY_POWER}%- ${BATTERY_REMAINING}"
|
||||
echo "${BATTERY_POWER}%- ${BATTERY_REMAINING}"
|
||||
else
|
||||
echo "${BATTERY_POWER}%-"
|
||||
echo "${BATTERY_POWER}%-"
|
||||
fi
|
||||
echo ""
|
||||
else
|
||||
echo "${BATTERY_POWER}%"
|
||||
echo "${BATTERY_POWER}%"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [[ "${BATTERY_POWER}" -le "${URGENT_VALUE}" ]]; then
|
||||
exit 33
|
||||
fi
|
20
config/i3blocks/laptop/blocks/bluetooth
Executable file
20
config/i3blocks/laptop/blocks/bluetooth
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Left click
|
||||
if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then
|
||||
sudo bluetooth on
|
||||
# Middle click
|
||||
elif [[ "${BLOCK_BUTTON}" -eq 2 ]]; then
|
||||
sudo bluetooth toggle
|
||||
# Right click
|
||||
elif [[ "${BLOCK_BUTTON}" -eq 3 ]]; then
|
||||
sudo bluetooth off
|
||||
fi
|
||||
|
||||
STATUS=$(bluetooth | grep -wo 'on')
|
||||
|
||||
if [[ "${STATUS}" = "on" ]]; then
|
||||
echo "on"
|
||||
echo "on"
|
||||
echo ""
|
||||
fi
|
57
config/i3blocks/laptop/blocks/brightness
Executable file
57
config/i3blocks/laptop/blocks/brightness
Executable file
@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
|
||||
# One of the following: xrandr, xbacklight, kernel
|
||||
METHOD="xbacklight"
|
||||
|
||||
# Left click
|
||||
if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then
|
||||
xbacklight -inc 5
|
||||
# Right click
|
||||
elif [[ "${BLOCK_BUTTON}" -eq 3 ]]; 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
|
||||
exit
|
||||
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
|
||||
exit
|
||||
fi
|
||||
|
||||
echo "${percent}%"
|
||||
echo "${percent}%"
|
||||
echo ""
|
||||
|
||||
if [[ "${percent}" -le "${URGENT_VALUE}" ]]; then
|
||||
exit 33
|
||||
fi
|
20
config/i3blocks/laptop/blocks/cmus
Executable file
20
config/i3blocks/laptop/blocks/cmus
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
INFO_CMUS=$(cmus-remote -Q 2>/dev/null)
|
||||
if [[ $? -eq 0 ]]; then
|
||||
INFO_TITLE=$(echo "${INFO_CMUS}" | sed -n -e 's/^.*title//p' | head -n 1)
|
||||
INFO_ALBUM=$(echo "${INFO_CMUS}" | sed -n -e 's/^.*album//p' | head -n 1)
|
||||
INFO_ARTIST=$(echo "${INFO_CMUS}" | sed -n -e 's/^.*artist//p' | head -n 1)
|
||||
else
|
||||
exit
|
||||
fi
|
||||
|
||||
if [[ "${INFO_ARTIST}" ]] && [[ "${INFO_TITLE}" ]]; then
|
||||
OUT_TEXT="${INFO_ARTIST} - ${INFO_TITLE}"
|
||||
elif [[ "${INFO_TITLE}" ]]; then
|
||||
OUT_TEXT="${INFO_TITLE}"
|
||||
fi
|
||||
|
||||
echo "${OUT_TEXT}"
|
||||
echo "${OUT_TEXT}"
|
||||
exit
|
36
config/i3blocks/laptop/blocks/countdown
Executable file
36
config/i3blocks/laptop/blocks/countdown
Executable file
@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
END_DATE="${BLOCK_INSTANCE}"
|
||||
|
||||
URGENT_VALUE=86400
|
||||
|
||||
if [[ "${END_DATE}" = "" ]]; then
|
||||
END_DATE=$(date --date "next Friday" "+%m/%d/%Y %H:%M:%S")
|
||||
fi
|
||||
|
||||
END_DATE=$(date --date="${END_DATE}" '+%s')
|
||||
CUR_DATE=$(date "+%s")
|
||||
DIFF_DATE=$((END_DATE - CUR_DATE))
|
||||
DIFF=""
|
||||
|
||||
if [[ "${DIFF_DATE}" -le 0 ]]; then
|
||||
echo "${END_DATE}"
|
||||
echo "${END_DATE}"
|
||||
echo ""
|
||||
exit 33
|
||||
fi
|
||||
|
||||
if [[ "${DIFF_DATE}" -ge 86400 ]]; then
|
||||
DIFF="[$((DIFF_DATE / 86400))] "
|
||||
#DIFF_DATE=$((DIFF_DATE % 86400))
|
||||
fi
|
||||
|
||||
DIFF+=$(date -u -d "@${DIFF_DATE}" +"%H:%M:%S")
|
||||
|
||||
echo "${DIFF}"
|
||||
echo "${DIFF}"
|
||||
echo ""
|
||||
|
||||
if [[ "${DIFF_DATE}" -le "${URGENT_VALUE}" ]]; then
|
||||
exit 33
|
||||
fi
|
48
config/i3blocks/laptop/blocks/cpu
Executable file
48
config/i3blocks/laptop/blocks/cpu
Executable file
@ -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
|
8
config/i3blocks/laptop/blocks/datetime
Executable file
8
config/i3blocks/laptop/blocks/datetime
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
FORMAT="${BLOCK_INSTANCE:-%H:%M}"
|
||||
DATETIME=$(date "+${FORMAT}")
|
||||
|
||||
echo "${DATETIME}"
|
||||
echo "${DATETIME}"
|
||||
echo ""
|
41
config/i3blocks/laptop/blocks/disk
Executable file
41
config/i3blocks/laptop/blocks/disk
Executable file
@ -0,0 +1,41 @@
|
||||
#!/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/>.
|
||||
|
||||
DIR="${BLOCK_INSTANCE:-$HOME}"
|
||||
ALERT_LOW="${1:-10}" # color will turn red under this value (default: 10%)
|
||||
|
||||
df -h -P -l "$DIR" | awk -v alert_low=$ALERT_LOW '
|
||||
/\/.*/ {
|
||||
# full text
|
||||
print $4
|
||||
|
||||
# short text
|
||||
print $4
|
||||
|
||||
use=$5
|
||||
|
||||
# no need to continue parsing
|
||||
exit 0
|
||||
}
|
||||
|
||||
END {
|
||||
gsub(/%$/,"",use)
|
||||
if (100 - use < alert_low) {
|
||||
# color
|
||||
print "#FF0000"
|
||||
}
|
||||
}
|
||||
'
|
68
config/i3blocks/laptop/blocks/display
Executable file
68
config/i3blocks/laptop/blocks/display
Executable file
@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
|
||||
xrandrOut=$(xrandr)
|
||||
|
||||
hdmiName=$(echo "${xrandrOut}" | grep -i 'HDMI' | awk '{print $1}')
|
||||
vgaName=$(echo "${xrandrOut}" | grep -i 'VGA' | awk '{print $1}')
|
||||
edpName=$(echo "${xrandrOut}" | grep -i 'EDP' | awk '{print $1}')
|
||||
|
||||
activeDisplays=$(echo "${xrandrOut}" | grep " connected" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/" | tr -s '\n' ' ')
|
||||
displayFile='/tmp/.displays'
|
||||
|
||||
if [[ -f "${displayFile}" ]]; then
|
||||
oldDisplays=$(cat "${displayFile}")
|
||||
else
|
||||
oldDisplays=""
|
||||
fi
|
||||
|
||||
if [[ "${oldDisplays}" != "${activeDisplays}" ]]; then
|
||||
change="yes"
|
||||
else
|
||||
change="no"
|
||||
fi
|
||||
|
||||
# External, HDMI + VGA
|
||||
if [[ "$activeDisplays" =~ "${hdmiName}" && "$activeDisplays" =~ "${vgaName}" ]]; then
|
||||
if [[ "${change}" = "yes" ]]; then
|
||||
$(xrandr --output "${edpName}" --off)
|
||||
$(xrandr --output "${vgaName}" --auto)
|
||||
$(xrandr --output "${hdmiName}" --primary --auto)
|
||||
fi
|
||||
echo "VGA1 & HDMI"
|
||||
echo "VGA1 & HDMI"
|
||||
echo ""
|
||||
# External, HDMI
|
||||
elif [[ "$activeDisplays" =~ "${hdmiName}" ]]; then
|
||||
if [[ "${change}" = "yes" ]]; then
|
||||
$(xrandr --output "${edpName}" --off)
|
||||
$(xrandr --output "${vgaName}" --off)
|
||||
$(xrandr --output "${hdmiName}" --primary --auto)
|
||||
fi
|
||||
echo "HDMI"
|
||||
echo "HDMI"
|
||||
echo ""
|
||||
# External, VGA
|
||||
elif [[ "$activeDisplays" =~ "${vgaName}" ]]; then
|
||||
if [[ "${change}" = "yes" ]]; then
|
||||
$(xrandr --output "${edpName}" --off)
|
||||
$(xrandr --output "${vgaName}" --primary --auto)
|
||||
$(xrandr --output "${hdmiName}" --off)
|
||||
fi
|
||||
echo "VGA"
|
||||
echo "VGA"
|
||||
echo
|
||||
# Only one internal
|
||||
elif [[ "$activeDisplays" =~ "${edpName}" ]]; then
|
||||
if [[ "${change}" = "yes" ]]; then
|
||||
$(xrandr --output "${edpName}" --primary --auto)
|
||||
$(xrandr --output "${vgaName}" --off)
|
||||
$(xrandr --output "${hdmiName}" --off)
|
||||
fi
|
||||
echo "eDP"
|
||||
echo "eDP"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [[ "${change}" = "yes" ]]; then
|
||||
echo "${activeDisplays}" > "${displayFile}"
|
||||
fi
|
31
config/i3blocks/laptop/blocks/feed
Executable file
31
config/i3blocks/laptop/blocks/feed
Executable file
@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
|
||||
# WARNING: This has a LIMIT of 32 characters for now!
|
||||
# If your URL is longer you should use an URL shortener
|
||||
# Caused by https://github.com/vivien/i3blocks/blob/01a4f4a9ca1e3d0b3c95d1d62000ad8506bdff1a/include/block.h#L50
|
||||
# Example: https://goo.gl/
|
||||
FEED_URL="${BLOCK_INSTANCE:-https://www.archlinux.org/feeds/news/}"
|
||||
|
||||
if [[ "${FEED_URL}" = "" ]]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# Follows redirects!
|
||||
FEED_CONTENT=$(curl ${FEED_URL} -s -L)
|
||||
FEED_TITLE=$(echo "${FEED_CONTENT}" | grep -v "xmlns:atom" | grep -o '<title>.*</title>' | head -n 1 | sed 's/\(<title>\|<\/title>\)//g')
|
||||
FEED_LINK=$(echo "${FEED_CONTENT}" | grep -v "xmlns:atom" | grep -o '<link>.*</link>' | head -n 1 | sed 's/\(<link>\|<\/link>\)//g')
|
||||
|
||||
if [[ "${FEED_TITLE}" = *404* ]]; then
|
||||
echo "${FEED_URL}"
|
||||
echo "${FEED_URL}"
|
||||
echo ""
|
||||
exit 33
|
||||
fi
|
||||
|
||||
if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then
|
||||
xdg-open "${FEED_LINK}"
|
||||
fi
|
||||
|
||||
echo "${FEED_TITLE}"
|
||||
echo "${FEED_TITLE}"
|
||||
echo ""
|
28
config/i3blocks/laptop/blocks/firewall
Executable file
28
config/i3blocks/laptop/blocks/firewall
Executable file
@ -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
|
1
config/i3blocks/laptop/blocks/i3blocks
Submodule
1
config/i3blocks/laptop/blocks/i3blocks
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 70dca64822e4e0c3ecc62436bd48f7af6e6e65d5
|
9
config/i3blocks/laptop/blocks/ip-address
Executable file
9
config/i3blocks/laptop/blocks/ip-address
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
IP_ADDRESS=$(ip route get 1 | awk '{print $NF;exit}')
|
||||
|
||||
if [[ "${IP_ADDRESS}" != "" ]]; then
|
||||
echo "${IP_ADDRESS}"
|
||||
echo "${IP_ADDRESS}"
|
||||
echo ""
|
||||
fi
|
27
config/i3blocks/laptop/blocks/keymap
Executable file
27
config/i3blocks/laptop/blocks/keymap
Executable file
@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
KEYMAP_DIRECTORY='/usr/share/kbd/keymaps'
|
||||
|
||||
# Aprrently localectl status does not update on keymap change. However, setxkbmap does.
|
||||
XKB_OUTPUT=$(setxkbmap -query)
|
||||
VC_KEYMAP=$(echo "${XKB_OUTPUT}" | grep "layout" | awk -F ':' '{print $2}' | tr -d ' ')
|
||||
VC_VARIANT=$(echo "${XKB_OUTPUT}" | grep "variant" | awk -F ':' '{print $2}' | tr -d ' ')
|
||||
|
||||
# Keymap has not been specific, so it's not configured properly
|
||||
if [[ "${VC_KEYMAP}" == "" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
KEYMAP_FILE="${VC_KEYMAP}*"
|
||||
|
||||
if [[ "${VC_VARIANT}" != "" ]]; then
|
||||
KEYMAP_FILE="${KEYMAP_FILE}${VC_VARIANT}*"
|
||||
fi
|
||||
|
||||
KEYMAP_NAME=$(basename $(dirname $(find ${KEYMAP_DIRECTORY} -name "${KEYMAP_FILE}")))
|
||||
|
||||
if [[ "${KEYMAP_NAME}" ]]; then
|
||||
echo "${KEYMAP_NAME}"
|
||||
echo "${KEYMAP_NAME}"
|
||||
echo ""
|
||||
fi
|
25
config/i3blocks/laptop/blocks/keystate
Executable file
25
config/i3blocks/laptop/blocks/keystate
Executable file
@ -0,0 +1,25 @@
|
||||
#!/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}')
|
||||
scrollLock=$(echo "${lockLine}" | awk -F ' ' '{print $12}')
|
||||
|
||||
if [[ "${TYPE}" == "caps" ]]; then
|
||||
checkLock="${capsLock}"
|
||||
elif [[ "${TYPE}" == "num" ]]; then
|
||||
checkLock="${numLock}"
|
||||
elif [[ "${TYPE}" == "scroll" ]]; then
|
||||
checkLock="${scrollLock}"
|
||||
else
|
||||
exit
|
||||
fi
|
||||
|
||||
if [[ "${checkLock}" == "on" ]]; then
|
||||
echo "on"
|
||||
echo "on"
|
||||
echo ""
|
||||
fi
|
26
config/i3blocks/laptop/blocks/launcher
Executable file
26
config/i3blocks/laptop/blocks/launcher
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
CONFIG_FILE="${BLOCK_INSTANCE:-~/.config/i3/config}"
|
||||
CONFIG_FILE=${CONFIG_FILE/\~/$HOME}
|
||||
|
||||
LAUNCH_CMD=$(cat "${CONFIG_FILE}" | grep -v "^#" | grep -wi 'rofi\|dmenu' | awk -F 'exec ' '{print $2}')
|
||||
LAUNCH_NAME=$(echo "${LAUNCH_CMD}" | awk -F ' ' '{print $1}')
|
||||
|
||||
VARIABLES=$(cat "${CONFIG_FILE}" | grep -E 'set\ \$' | awk -F ' ' '{$1 = "";print $0}')
|
||||
|
||||
while read varPair; do
|
||||
varName=$(echo "${varPair}" | awk -F ' ' '{print $1}')
|
||||
varValue=$(echo "${varPair}" | awk -F ' ' '{print $2}')
|
||||
#echo "Replacing ${varName} with ${varValue}"
|
||||
LAUNCH_CMD=$(echo ${LAUNCH_CMD} | sed "s|$varName|$varValue|g")
|
||||
done <<< "$(echo -e "$VARIABLES")"
|
||||
|
||||
#echo "${LAUNCH_CMD}" && exit
|
||||
|
||||
echo "${LAUNCH_NAME}"
|
||||
echo "${LAUNCH_NAME}"
|
||||
echo ""
|
||||
|
||||
if [[ "${BLOCK_BUTTON}" -gt 0 ]]; then
|
||||
eval ${LAUNCH_CMD} &
|
||||
fi
|
19
config/i3blocks/laptop/blocks/load
Executable file
19
config/i3blocks/laptop/blocks/load
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
INSTANCE="${BLOCK_INSTANCE:-1}"
|
||||
|
||||
URGENT_VALUE=90
|
||||
|
||||
LOAD=$(cat /proc/loadavg | awk -F ' ' '{print $'"${INSTANCE}"'}')
|
||||
if [[ "${LOAD}" != "" ]]; then
|
||||
LOAD_PERC=$(echo "scale=0; ${LOAD} * 100" | bc -l)
|
||||
LOAD_PERC=${LOAD_PERC%.*}
|
||||
|
||||
echo "${LOAD}"
|
||||
echo "${LOAD}"
|
||||
echo ""
|
||||
|
||||
if [[ "${LOAD_PERC}" -ge "${URGENT_VALUE}" ]]; then
|
||||
exit 33
|
||||
fi
|
||||
fi
|
10
config/i3blocks/laptop/blocks/locale
Executable file
10
config/i3blocks/laptop/blocks/locale
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
LOCALE_INFO=$(localectl)
|
||||
LOCALE_NAME=$(echo "${LOCALE_INFO}" | grep "System Locale" | awk -F '=' '{print $2}' | cut -c 1-2)
|
||||
|
||||
if [[ "${LOCALE_NAME}" ]]; then
|
||||
echo "${LOCALE_NAME}"
|
||||
echo "${LOCALE_NAME}"
|
||||
echo ""
|
||||
fi
|
59
config/i3blocks/laptop/blocks/mail
Executable file
59
config/i3blocks/laptop/blocks/mail
Executable file
@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Requires https://www.google.com/settings/security/lesssecureapps for gmail.
|
||||
|
||||
CONFIG_FILE="${BLOCK_INSTANCE}"
|
||||
CONFIG_FILE=${CONFIG_FILE/\~/$HOME}
|
||||
|
||||
# Config file needs the following settings:
|
||||
#MAIL_SERVER="imap.domain.tld:993"
|
||||
#MAIL_USER="user@domain.tld"
|
||||
#MAIL_PASSWORD="secret"
|
||||
#MAIL_FOLDER="INBOX"
|
||||
|
||||
if [[ ! -f "${CONFIG_FILE}" ]]; then
|
||||
echo "${CONFIG_FILE}"
|
||||
exit 33
|
||||
fi
|
||||
|
||||
source "${CONFIG_FILE}"
|
||||
|
||||
MAIN_DOMAIN=$(expr match "${MAIL_SERVER}" '.*\.\(.*\..*\)' | awk -F ':' '{print $1}')
|
||||
|
||||
# Add https so xdg knows that it's a website
|
||||
if [[ "${MAIN_DOMAIN}" != http* ]]; then
|
||||
MAIN_DOMAIN="https://${MAIN_DOMAIN}"
|
||||
fi
|
||||
|
||||
# Left click
|
||||
if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then
|
||||
xdg-open "${MAIN_DOMAIN}"
|
||||
fi
|
||||
|
||||
MAIL_FILE="/tmp/.mail"
|
||||
URGENT_VALUE="100"
|
||||
|
||||
GET_UNREAD=$(cat<<EOF
|
||||
? LOGIN "${MAIL_USER}" "${MAIL_PASSWORD}"
|
||||
? STATUS "${MAIL_FOLDER}" (unseen)
|
||||
? LOGOUT
|
||||
EOF
|
||||
)
|
||||
|
||||
echo "${GET_UNREAD}" | openssl s_client -connect "${MAIL_SERVER}" -crlf -ign_eof > "${MAIL_FILE}" 2>/dev/null
|
||||
UNREAD_COUNT=$(cat "${MAIL_FILE}" | grep -i "UNSEEN" | grep -oE "[0-9]*" | head -n 1)
|
||||
|
||||
# For security reasons
|
||||
rm "${MAIL_FILE}"
|
||||
|
||||
if [[ "${UNREAD_COUNT}" = "" ]]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
echo "${UNREAD_COUNT}"
|
||||
echo "${UNREAD_COUNT}"
|
||||
echo ""
|
||||
|
||||
if [[ "${UNREAD_COUNT}" -ge URGENT_VALUE ]]; then
|
||||
exit 33
|
||||
fi
|
75
config/i3blocks/laptop/blocks/memory
Executable file
75
config/i3blocks/laptop/blocks/memory
Executable file
@ -0,0 +1,75 @@
|
||||
#!/bin/bash
|
||||
|
||||
# First argument is source (mem/swap), second is output value
|
||||
# Check /proc/meminfo for possible instances
|
||||
INSTANCE="${BLOCK_INSTANCE:-mem;free}"
|
||||
|
||||
SOURCE=$(echo "${INSTANCE}" | awk -F ';' '{print $1}')
|
||||
DISPLAY=$(echo "${INSTANCE}" | awk -F ';' '{print $2}')
|
||||
|
||||
if [[ "${SOURCE}" = "mem" ]]; then
|
||||
URGENT_VALUE=90
|
||||
elif [[ "${SOURCE}" = "swap" ]]; then
|
||||
URGENT_VALUE=50
|
||||
fi
|
||||
|
||||
if [[ "${DISPLAY}" = "" ]]; then
|
||||
DISPLAY="free"
|
||||
fi
|
||||
|
||||
ONE_KB=1024
|
||||
ONE_MB=$(echo "${ONE_KB}*1024" | bc -l)
|
||||
ONE_GB=$(echo "${ONE_MB}*1024" | bc -l)
|
||||
ONE_TB=$(echo "${ONE_GB}*1024" | bc -l)
|
||||
|
||||
# Grep the value and remove KB so we can calculate with it later
|
||||
#MEMINFO=$(cat /proc/meminfo | grep "${INSTANCE}" | awk -F ':' '{print $2}' | tr -d ' kB')
|
||||
MEMORY_INFOS=$(cat /proc/meminfo)
|
||||
SOURCE_TOTAL=$(echo "${MEMORY_INFOS}" | grep -i "${SOURCE}total" | awk -F ':' '{print $2}' | tr -d ' kB')
|
||||
|
||||
if [[ "${SOURCE_TOTAL}" -le 0 ]]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
if [[ "${SOURCE}" = "mem" ]]; then
|
||||
SOURCE_FREE_KEY="available"
|
||||
elif [[ "${SOURCE}" = "swap" ]]; then
|
||||
SOURCE_FREE_KEY="free"
|
||||
fi
|
||||
|
||||
SOURCE_FREE=$(echo "${MEMORY_INFOS}" | grep -i "${SOURCE}${SOURCE_FREE_KEY}" | awk -F ':' '{print $2}' | tr -d ' kB')
|
||||
SOURCE_USED=$(echo "scale=0; ${SOURCE_TOTAL}-${SOURCE_FREE}" | bc -l)
|
||||
SOURCE_PERC=$(echo "scale=0; (${SOURCE_USED}*100)/${SOURCE_TOTAL}" | bc -l)
|
||||
|
||||
if [[ "${DISPLAY}" = "free" ]]; then
|
||||
MEMINFO="${SOURCE_FREE}"
|
||||
elif [[ "${DISPLAY}" = "used" ]]; then
|
||||
MEMINFO="${SOURCE_USED}"
|
||||
elif [[ "${DISPLAY}" = "total" ]]; then
|
||||
MEMINFO="${SOURCE_TOTAL}"
|
||||
elif [[ "${DISPLAY}" = "perc" ]]; then
|
||||
MEMINFO="${SOURCE_PERC}%"
|
||||
fi
|
||||
|
||||
if [[ "${DISPLAY}" != "perc" ]]; then
|
||||
# Convert KB meminfo to bytes
|
||||
MEMINFO=$(echo "${MEMINFO}*${ONE_KB}" | bc -l)
|
||||
|
||||
if [[ "${MEMINFO}" -ge "${ONE_TB}" ]]; then
|
||||
MEMINFO=$(echo "scale=3;${MEMINFO}/${ONE_TB}" | bc -l)"tb"
|
||||
elif [[ "${MEMINFO}" -ge "${ONE_GB}" ]]; then
|
||||
MEMINFO=$(echo "scale=2;${MEMINFO}/${ONE_GB}" | bc -l)"gb"
|
||||
elif [[ "${MEMINFO}" -ge "${ONE_MB}" ]]; then
|
||||
MEMINFO=$(echo "scale=1;${MEMINFO}/${ONE_MB}" | bc -l)"mb"
|
||||
else
|
||||
MEMINFO=$(echo "scale=0;${MEMINFO}/${ONE_KB}" | bc -l)"kb"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "${MEMINFO}"
|
||||
echo "${MEMINFO}"
|
||||
echo ""
|
||||
|
||||
if [[ "${SOURCE_PERC}" -gt "${URGENT_VALUE}" ]]; then
|
||||
exit 33
|
||||
fi
|
26
config/i3blocks/laptop/blocks/microphone
Executable file
26
config/i3blocks/laptop/blocks/microphone
Executable file
@ -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
|
23
config/i3blocks/laptop/blocks/network
Executable file
23
config/i3blocks/laptop/blocks/network
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
device="${BLOCK_INSTANCE:-wlan0}"
|
||||
status=$(cat /sys/class/net/${device}/operstate)
|
||||
|
||||
URGENT_VALUE=20
|
||||
|
||||
if [[ "${status}" == "up" ]]; then
|
||||
if [[ -d "/sys/class/net/${device}/wireless" ]]; then
|
||||
quality=$(grep ${device} /proc/net/wireless | awk '{ print int($3 * 100 / 70) }')
|
||||
echo "${quality}%"
|
||||
echo "${quality}%"
|
||||
echo ""
|
||||
|
||||
if [[ "${quality}" -le "${URGENT_VALUE}" ]]; then
|
||||
exit 33
|
||||
fi
|
||||
else
|
||||
echo "on"
|
||||
echo "on"
|
||||
echo ""
|
||||
fi
|
||||
fi
|
185
config/i3blocks/laptop/blocks/notifier
Executable file
185
config/i3blocks/laptop/blocks/notifier
Executable file
@ -0,0 +1,185 @@
|
||||
#!/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
|
||||
|
||||
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}"
|
13
config/i3blocks/laptop/blocks/packages
Executable file
13
config/i3blocks/laptop/blocks/packages
Executable file
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
URGENT_VALUE=25
|
||||
PACKAGE_COUNT=$(pacman -Qu | wc -l)
|
||||
|
||||
if [[ "${PACKAGE_COUNT}" -gt 0 ]]; then
|
||||
echo "${PACKAGE_COUNT}" # full-text
|
||||
echo "${PACKAGE_COUNT}" # short-text
|
||||
echo ""
|
||||
if [[ "${PACKAGE_COUNT}" -gt "${URGENT_VALUE}" ]]; then
|
||||
exit 33
|
||||
fi
|
||||
fi
|
39
config/i3blocks/laptop/blocks/playerctl
Executable file
39
config/i3blocks/laptop/blocks/playerctl
Executable file
@ -0,0 +1,39 @@
|
||||
#!/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)
|
||||
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
|
17
config/i3blocks/laptop/blocks/process
Executable file
17
config/i3blocks/laptop/blocks/process
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
PROG="${BLOCK_INSTANCE:-i3}"
|
||||
|
||||
PROG_REGEX="["$(echo "${PROG}" | cut -c 1)"]"$(echo "${PROG}" | cut -c 2-)" "
|
||||
PROCESS=$(ps -eo pid,cmd | grep -w ${PROG_REGEX})
|
||||
|
||||
if [[ "${PROCESS}" ]]; then
|
||||
echo "ok"
|
||||
echo "ok"
|
||||
echo ""
|
||||
else
|
||||
echo "na"
|
||||
echo "na"
|
||||
echo ""
|
||||
exit 33
|
||||
fi
|
69
config/i3blocks/laptop/blocks/scroll
Executable file
69
config/i3blocks/laptop/blocks/scroll
Executable file
@ -0,0 +1,69 @@
|
||||
#!/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
|
||||
# which are wide and that you need to scroll.
|
||||
#
|
||||
# Example:
|
||||
# command=~/.i3-blocks/blocks/scroll $BLOCK_NAME
|
||||
# markup=pango
|
||||
# interval=repeat
|
||||
|
||||
PROG="${1}"
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
BLOCK_PATH="${SCRIPT_DIR}/${PROG}"
|
||||
|
||||
INTERVAL=0.17
|
||||
MAX_LENGTH=25
|
||||
ADD_STR=" | "
|
||||
ADD_LENGTH=${#ADD_STR}
|
||||
|
||||
if [[ -f "${BLOCK_PATH}" ]]; then
|
||||
BLOCK_OUT=$(bash "${BLOCK_PATH}")
|
||||
OUT_TEXT=$(echo "${BLOCK_OUT}" | tail -n 1)
|
||||
elif [[ "${PROG}" != "" ]]; then
|
||||
OUT_TEXT=$(${PROG})
|
||||
if [[ $? -ne 0 ]]; then
|
||||
sleep 1
|
||||
echo "${PROG}"
|
||||
echo "${PROG}"
|
||||
exit 33
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "${OUT_TEXT}" ]]; then
|
||||
CHECK_SUM=$(echo "${PROG}-${BLOCK_INSTANCE}" | md5sum | awk '{print $1}')
|
||||
|
||||
TMP_FILE="/tmp/.scroll-${CHECK_SUM}"
|
||||
|
||||
if [[ -f "${TMP_FILE}" ]]; then
|
||||
SCROLL_POS=$(cat "${TMP_FILE}")
|
||||
else
|
||||
SCROLL_POS=0
|
||||
fi
|
||||
|
||||
TEXT_LENGTH=${#OUT_TEXT}
|
||||
MAX_OFFSET=$((TEXT_LENGTH +ADD_LENGTH -1))
|
||||
|
||||
if [[ "${TEXT_LENGTH}" -lt "${MAX_LENGTH}" ]]; then
|
||||
MAX_LENGTH="${TEXT_LENGTH}"
|
||||
fi
|
||||
|
||||
if [[ "${SCROLL_POS}" -gt "${MAX_OFFSET}" ]]; then
|
||||
SCROLL_POS=0
|
||||
fi
|
||||
|
||||
TEXT_LINE="${OUT_TEXT}${ADD_STR}${OUT_TEXT}${ADD_STR}${OUT_TEXT}"
|
||||
TEXT_LINE=${TEXT_LINE:$SCROLL_POS:$MAX_LENGTH}
|
||||
|
||||
echo "<span font_family='monospace'>${TEXT_LINE}</span>"
|
||||
echo "<span font_family='monospace'>${TEXT_LINE}</span>"
|
||||
|
||||
SCROLL_POS=$((SCROLL_POS +1))
|
||||
|
||||
echo "${SCROLL_POS}" > "${TMP_FILE}"
|
||||
sleep "${INTERVAL}"
|
||||
else
|
||||
sleep 1
|
||||
fi
|
38
config/i3blocks/laptop/blocks/space
Executable file
38
config/i3blocks/laptop/blocks/space
Executable file
@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
INSTANCE="${BLOCK_INSTANCE}"
|
||||
URGENT_VALUE=90
|
||||
|
||||
if [[ "${INSTANCE}" = "" ]]; then
|
||||
INSTANCE="$HOME;free"
|
||||
fi
|
||||
|
||||
DISPLAY=$(echo "${INSTANCE}" | awk -F ';' '{print $2}')
|
||||
INSTANCE=$(echo "${INSTANCE}" | awk -F ';' '{print $1}')
|
||||
|
||||
if [[ "${DISPLAY}" = "" ]]; then
|
||||
DISPLAY="free"
|
||||
fi
|
||||
|
||||
SPACE_VARS=$(df -h "${INSTANCE}" | tail -n 1 | awk '{$1="";$6="";print $0}')
|
||||
PERC_SPACE=$(echo "${SPACE_VARS}" | awk -F ' ' '{print $4}' | tr -d '%')
|
||||
|
||||
if [[ "${DISPLAY}" = "max" ]]; then
|
||||
VALUE=$(echo "${SPACE_VARS}" | awk -F ' ' '{print $1}')
|
||||
elif [[ "${DISPLAY}" = "used" ]]; then
|
||||
VALUE=$(echo "${SPACE_VARS}" | awk -F ' ' '{print $2}')
|
||||
elif [[ "${DISPLAY}" = "free" ]]; then
|
||||
VALUE=$(echo "${SPACE_VARS}" | awk -F ' ' '{print $3}')
|
||||
elif [[ "${DISPLAY}" = "perc" ]]; then
|
||||
VALUE="${PERC_SPACE}%"
|
||||
fi
|
||||
|
||||
if [[ "${VALUE}" ]]; then
|
||||
echo "${VALUE}"
|
||||
echo "${VALUE}"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [[ "${PERC_SPACE}" -gt "${URGENT_VALUE}" ]]; then
|
||||
exit 33
|
||||
fi
|
18
config/i3blocks/laptop/blocks/ssid
Executable file
18
config/i3blocks/laptop/blocks/ssid
Executable file
@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
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
|
||||
fi
|
35
config/i3blocks/laptop/blocks/temperature
Executable file
35
config/i3blocks/laptop/blocks/temperature
Executable file
@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
TEMP_DEVICE="${BLOCK_INSTANCE:-Core}"
|
||||
TEMP_OUTPUT=$(sensors | grep "${TEMP_DEVICE}")
|
||||
|
||||
IS_URGENT=0
|
||||
|
||||
TOTAL_TEMP=0
|
||||
TOTAL_COUNT=0
|
||||
while read RESULT_LINE; do
|
||||
TOTAL_COUNT=$((TOTAL_COUNT +1))
|
||||
CURRENT_TEMP=$(echo "${RESULT_LINE}" | grep -o -E "[\+\-]?[0-9]*.[0-9]*°C" | sed -n '1p' | tr -d '+°C')
|
||||
URGENT_VALUE=$(echo "${RESULT_LINE}" | grep -o -E "[\+\-]?[0-9]*.[0-9]*°C" | sed -n '2p' | tr -d '+°C')
|
||||
|
||||
TOTAL_TEMP=$(echo "scale=2;${TOTAL_TEMP}+${CURRENT_TEMP}" | bc -l)
|
||||
IS_CRITICAL=$(echo "scale=0;${CURRENT_TEMP}-${URGENT_VALUE} >= 0" | bc -l)
|
||||
|
||||
if [[ "${IS_CRITICAL}" -eq 1 ]]; then
|
||||
IS_URGENT=1
|
||||
fi
|
||||
done <<< "$(echo -e "$TEMP_OUTPUT")"
|
||||
|
||||
AVERAGE_TEMP=$(echo "scale=0;${TOTAL_TEMP}/${TOTAL_COUNT}" | bc -l)
|
||||
|
||||
if [[ "${TOTAL_COUNT}" -gt 1 ]]; then
|
||||
AVERAGE_TEMP="~ ${AVERAGE_TEMP}"
|
||||
fi
|
||||
|
||||
echo "${AVERAGE_TEMP}°C"
|
||||
echo "${AVERAGE_TEMP}°C"
|
||||
echo ""
|
||||
|
||||
if [[ "${IS_URGENT}" -eq 1 ]]; then
|
||||
exit 33
|
||||
fi
|
32
config/i3blocks/laptop/blocks/trash
Executable file
32
config/i3blocks/laptop/blocks/trash
Executable file
@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
TRASH_DIRECTORY="${BLOCK_INSTANCE}"
|
||||
|
||||
if [[ "${TRASH_DIRECTORY}" = "" ]]; then
|
||||
TRASH_DIRECTORY="${XDG_DATA_HOME:-${HOME}/.local/share}/Trash"
|
||||
fi
|
||||
|
||||
# Left click
|
||||
if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then
|
||||
xdg-open "${TRASH_DIRECTORY}/files"
|
||||
# Right click
|
||||
elif [[ "${BLOCK_BUTTON}" -eq 3 ]]; then
|
||||
# Delete all files permanently (unlink them)
|
||||
rm -r "${TRASH_DIRECTORY}/files"
|
||||
rm -r "${TRASH_DIRECTORY}/info"
|
||||
# Create new directory
|
||||
mkdir "${TRASH_DIRECTORY}/files"
|
||||
mkdir "${TRASH_DIRECTORY}/info"
|
||||
fi
|
||||
|
||||
TRASH_COUNT=$(ls -U -1 "${TRASH_DIRECTORY}/files" | wc -l)
|
||||
|
||||
URGENT_VALUE=100
|
||||
|
||||
echo "${TRASH_COUNT}"
|
||||
echo "${TRASH_COUNT}"
|
||||
echo ""
|
||||
|
||||
if [[ "${TRASH_COUNT}" -ge "${URGENT_VALUE}" ]]; then
|
||||
exit 33
|
||||
fi
|
15
config/i3blocks/laptop/blocks/usb
Executable file
15
config/i3blocks/laptop/blocks/usb
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
DEVICE_NAME="${BLOCK_INSTANCE:-Keyboard}"
|
||||
|
||||
DEVICE_INFO=$(lsusb | grep -i "${DEVICE_NAME}")
|
||||
|
||||
if [[ "${DEVICE_INFO}" != "" ]]; then
|
||||
echo "on"
|
||||
echo "on"
|
||||
echo ""
|
||||
else
|
||||
echo "na"
|
||||
echo "na"
|
||||
echo ""
|
||||
fi
|
9
config/i3blocks/laptop/blocks/user
Executable file
9
config/i3blocks/laptop/blocks/user
Executable file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
echo "${USER}"
|
||||
echo "${USER}"
|
||||
echo ""
|
||||
|
||||
if [[ $(id -u) -eq 0 ]]; then
|
||||
exit 33
|
||||
fi
|
9
config/i3blocks/laptop/blocks/vpn
Executable file
9
config/i3blocks/laptop/blocks/vpn
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
VPNC_FILE='/var/run/vpnc.pid'
|
||||
|
||||
if [[ -e "${VPNC_FILE}" ]]; then
|
||||
echo "on"
|
||||
echo "on"
|
||||
echo ""
|
||||
fi
|
55
config/i3blocks/laptop/blocks/weather
Executable file
55
config/i3blocks/laptop/blocks/weather
Executable file
@ -0,0 +1,55 @@
|
||||
#!/bin/bash
|
||||
# Based on http://openweathermap.org/current
|
||||
|
||||
API_KEY="44db6a862fba0b067b1930da0d769e98"
|
||||
|
||||
# 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}" = *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
|
17
config/i3blocks/laptop/blocks/webcam
Executable file
17
config/i3blocks/laptop/blocks/webcam
Executable file
@ -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
|
9
config/i3blocks/laptop/blocks/window
Normal file
9
config/i3blocks/laptop/blocks/window
Normal file
@ -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
|
102
config/i3blocks/laptop/config
Normal file
102
config/i3blocks/laptop/config
Normal file
@ -0,0 +1,102 @@
|
||||
# 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
|
||||
# background
|
||||
# border
|
||||
# command
|
||||
# full_text
|
||||
# instance
|
||||
# interval
|
||||
# label
|
||||
# min_width
|
||||
# name
|
||||
# separator
|
||||
# separator_block_width
|
||||
# short_text
|
||||
# signal
|
||||
# urgent
|
||||
|
||||
# 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.
|
||||
command=~/.config/i3blocks/blocks/$BLOCK_NAME
|
||||
separator_block_width=15
|
||||
markup=none
|
||||
|
||||
# Volume indicator
|
||||
#
|
||||
# The first parameter sets the step (and units to display)
|
||||
# The second parameter overrides the mixer selection
|
||||
# See the script for details.
|
||||
[audio]
|
||||
label=
|
||||
interval=1
|
||||
|
||||
# Memory usage
|
||||
#
|
||||
# The type defaults to "mem" if the instance is not specified.
|
||||
[memory]
|
||||
label=
|
||||
instance=mem;used
|
||||
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=
|
||||
#instance=$HOME
|
||||
interval=10
|
||||
|
||||
# Network Usage
|
||||
#[bandwidth]
|
||||
#separator=false
|
||||
#instance=wlp4s0;in
|
||||
#label=
|
||||
#interval=5
|
||||
#
|
||||
#[bandwidth]
|
||||
#instance=wlp4s0;out
|
||||
#label=
|
||||
#interval=5
|
||||
|
||||
[tab]
|
||||
|
||||
[cpu]
|
||||
label=
|
||||
interval=1
|
||||
separator=false
|
||||
|
||||
[temperature]
|
||||
instance=Core
|
||||
label=
|
||||
interval=5
|
||||
|
||||
# Battery indicator
|
||||
#
|
||||
# The battery instance defaults to 0.
|
||||
[battery]
|
||||
separator=false
|
||||
label= 1:
|
||||
instance=0
|
||||
interval=5
|
||||
|
||||
[battery]
|
||||
label=2:
|
||||
instance=1;rem
|
||||
interval=5
|
||||
|
||||
# Date Time
|
||||
#
|
||||
[time]
|
||||
command=date '+%F %I:%M:%S'
|
||||
interval=1
|
15
configure.sh
15
configure.sh
@ -58,9 +58,6 @@ install_i3() {
|
||||
|
||||
### Configuration Files
|
||||
lnh "Installing General Configuration Files"
|
||||
# i3
|
||||
lnf
|
||||
cp -v config/i3/laptop/config ~/.config/i3/config
|
||||
# Compton
|
||||
lnf
|
||||
cp -v config/compton/config ~/.config/compton/config
|
||||
@ -80,8 +77,10 @@ install_i3() {
|
||||
|
||||
### Install Service Files
|
||||
lnh "Installing Services"
|
||||
# Suspend locker
|
||||
lnf
|
||||
sudo cp -v config/systemd/system/suspend@.service /etc/systemd/system/
|
||||
# Auto locker
|
||||
lnf
|
||||
sudo cp -v config/systemd/user/locker.service /etc/systemd/user
|
||||
sudo systemctl daemon-reload
|
||||
@ -110,6 +109,16 @@ install_i3() {
|
||||
}
|
||||
|
||||
install_i3_laptop() {
|
||||
lnh "Installing Laptop Configuration Files"
|
||||
# i3blocks
|
||||
lnf
|
||||
cp -v config/i3blocks/laptop/config ~/.config/i3blocks/config
|
||||
lnf
|
||||
mkdir ~/.config/i3blocks/blocks
|
||||
lnfb
|
||||
cp -v config/i3blocks/laptop/config/blocks/* ~/.config/i3blocks/blocks/
|
||||
lnfbe
|
||||
|
||||
}
|
||||
|
||||
echo "Select a Window Manager"
|
||||
|
Loading…
Reference in New Issue
Block a user