cat microphone
------------------------------------------------------------------------------------------------------------------------------
#!/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 ""
-----------------------------------------------------------------------------------------------------------------------------
[microphone]
label=
interval=once
signal=2
-----------------------------------------------------------------------------------------------------------------------------
webcam
device=${BLOCK_INSTANCE:-/dev/video0}
if [[ -c "${device}" ]]; then
if [[ "$(fuser /dev/video0)" != "" ]]; then
echo "rec"
echo "rec"
echo ""
else
echo "off"
echo "off"
echo ""
fi
fi
[webcam]
label=
instance=/dev/video0
interval=5
-----------------------------------------------------------------------------------------------------------------------------
cat keystate
#!/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 ""
[keystate]
label=
instance=caps
interval=once
signal=5
[keystate]
label=
instance=num
interval=once
signal=5
-----------------------------------------------------------------------------------------------------------------------------
ssid
#!/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
[ssid]
label=
interval=60
-----------------------------------------------------------------------------------------------------------------------------
network
#!/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
[network]
label=
instance=wlan0
interval=10
-----------------------------------------------------------------------------------------------------------------------------
vpn
#!/bin/bash
VPNC_FILE='/var/run/vpnc.pid'
if [[ -e "${VPNC_FILE}" ]]; then
echo "on"
echo "on"
echo ""
[vpn]
label=
interval=once
-----------------------------------------------------------------------------------------------------------------------------
bluetooth
#!/bin/bash
STATUS=$(bluetooth | grep -wo 'on')
if [[ "${STATUS}" = "on" ]]; then
echo "on"
echo "on"
echo ""
fi
[bluetooth]
label=
interval=once
-----------------------------------------------------------------------------------------------------------------------------
backlight
#!/bin/sh
case $BLOCK_BUTTON in
4) brightnessctl s 1%+ >> /dev/null;;
5) brightnessctl s 1%- >> /dev/null;;
esac
BNESS="$(brightnessctl get)"
MAX="$(brightnessctl max)"
PERC="$((BNESS*100/MAX))"
BLIGHT=${PERC%.*}
ICON=""
echo $ICON $BLIGHT
[backlight]
interval=once
signal=3
-----------------------------------------------------------------------------------------------------------------------------
user
#!/bin/bash
echo "${USER}"
echo "${USER}"
echo ""
if [[ $(id -u) -eq 0 ]]; then
exit 33
fi
[user]
label=
interval=once
-----------------------------------------------------------------------------------------------------------------------------
battery
#!/bin/sh
case $BLOCK_BUTTON in
3) notify-send "$(acpi)";;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
# Loop through all attached batteries and format the info
for battery in /sys/class/power_supply/BAT?*; do
# If non-first battery, print a space separator.
[ -n "${capacity+x}" ] && printf " "
# Sets up the status and capacity
capacity="$(cat "$battery/capacity" 2>&1)"
case "$(cat "$battery/status" 2>&1)" in
"Full") status="" ;;
"Discharging") status="" ;;
"Charging") status="" ;;
"Not charging") status="🛑" ;;
"Unknown") status="♻️" ;;
*) exit 1 ;;
esac
# Will make a warn variable if discharging and low
[ "$status" = "" ] && [ "$capacity" -le 25 ] && warn="❗"
if [ "$capacity" -gt "95" ] && [ "$status" = "" ] ; then
status=""
elif [ "$capacity" -gt "75" ] && [ "$status" = "" ]; then
status=""
elif [ "$capacity" -gt "50" ] && [ "$status" = "" ]; then
status=""
elif [ "$capacity" -gt "25" ] && [ "$status" = "" ] ; then
status=""
elif [ "$capacity" -gt "10" ] && [ "$status" = "" ]; then
status=""
fi
# Prints the info
printf "%s%s%d%%" "$status" "$warn" "$capacity" ; unset warn
done && printf "\\n"
[battery]
interval=1
-----------------------------------------------------------------------------------------------------------------------------
set $refresh_vol pkill -RTMIN+1 i3blocks
set $refresh_mic pkill -RTMIN+2 i3blocks
set $refresh_bri pkill -RTMIN+3 i3blocks
set $refresh_keyind pkill -RTMIN+3 i3blocks
bindsym XF86AudioRaiseVolume exec --no-startup-id amixer sset Master 5%+ && $refresh_vol
bindsym XF86AudioLowerVolume exec --no-startup-id amixer sset Master 5%- && $refresh_vol
bindsym XF86AudioMute exec --no-startup-id amixer sset Master toggle && $refresh_vol
#dont have hardware mic keys so
bindsym Control+XF86AudioMute exec amixer -q sset Capture toggle && $refresh_mic
bindsym Control+XF86AudioRaiseVolume exec amixer -q sset Capture 5%+ && $refresh_mic
bindsym Control+XF86AudioLowerVolume execamixer -q sset Capture 5%+ && $refresh_mic
bindsym XF86AudioPause exec playerctl play-pause
bindsym XF86MonBrightnessUp exec brightnessctl s 2%+ && $refresh_bri
bindsym XF86MonBrightnessDown exec brightnessctl s 2%- && $refresh_bri
bindsym Control+XF86MonBrightnessUp exec brightnessctl s 10%+ && $refresh_bri
bindsym Control+XF86MonBrightnessDown exec brightnessctl s 10%- && $refresh_bri
##fat border for float with rt clk and kill with middle
bindsym --border button2 kill
bindsym --border button3 floating toggle
#bindsym --border button1 floating enable
bindsym --release Caps_Lock exec $refresh_keyind
bindsym --release Num_Lock exec $refresh_keyind
Comments
Post a Comment