Add scripts that create the output for status bar clicks.
This commit is contained in:
94
i3/i3/scripts/status.d/battery.bash
Normal file
94
i3/i3/scripts/status.d/battery.bash
Normal file
@@ -0,0 +1,94 @@
|
||||
#!/bin/bash
|
||||
|
||||
# shitty. this is used for both creating a part of the status conkyrc AND for
|
||||
# creating nice output if you click on the status bar
|
||||
# what i done depends on the first paramter
|
||||
|
||||
PATH_WARN_1="$HOME/.i3/logs/batwarn1"
|
||||
PATH_WARN_2="$HOME/.i3/logs/batwarn2"
|
||||
|
||||
THRESHOLD1=25
|
||||
THRESHOLD2=5
|
||||
|
||||
acpi_output=$(acpi -b)
|
||||
percent="$(echo "$acpi_output" | cut -d "," -f 2 | cut -d " " -f 2 | cut -d "%" -f 1)"
|
||||
if [[ $percent == 100 ]] ; then
|
||||
status="Full"
|
||||
else
|
||||
status="$(echo "$acpi_output" | cut -d "," -f 1 | cut -d " " -f 3)"
|
||||
fi
|
||||
time="$(echo "$acpi_output" | cut -d "," -f 3 | cut -d " " -f 2)"
|
||||
shortstatus="$(echo $status | cut -c 1)"
|
||||
|
||||
pretty() {
|
||||
(
|
||||
echo "Status:|$status"
|
||||
echo "Charge:|${percent}%"
|
||||
if [[ $percent != 100 ]] ; then
|
||||
echo "Time left:|$time"
|
||||
fi
|
||||
) | column -t --separator="|"
|
||||
}
|
||||
|
||||
charging() {
|
||||
[[ "$shortstatus" == "C" ]]
|
||||
}
|
||||
|
||||
discharging() {
|
||||
[[ "$shortstatus" == "D" ]]
|
||||
}
|
||||
|
||||
threshold1() {
|
||||
[[ $percent -le $THRESHOLD1 ]]
|
||||
}
|
||||
|
||||
threshold2() {
|
||||
[[ $percent -le $THRESHOLD2 ]]
|
||||
}
|
||||
|
||||
conky() {
|
||||
if discharging ; then
|
||||
if threshold2 ; then
|
||||
if [[ ! -f "$PATH_WARN_2" ]] ; then
|
||||
echo > "$PATH_WARN_2"
|
||||
notify-send --icon dialog-warning "Battery below 5%"
|
||||
fi
|
||||
elif threshold1 ; then
|
||||
if [[ ! -f "$PATH_WARN_1" ]] ; then
|
||||
echo > "$PATH_WARN_1"
|
||||
notify-send --icon dialog-warning "Battery below 25%"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if charging ; then
|
||||
[[ -f "$PATH_WARN_1" ]] && rm "$PATH_WARN_1"
|
||||
[[ -f "$PATH_WARN_2" ]] && rm "$PATH_WARN_2"
|
||||
#if [[ $percent -gt 25 ]] ; then
|
||||
# [[ -f "$PATH_WARN_1" ]] && rm "$PATH_WARN_1"
|
||||
#elif [[ $percent -gt 5 ]] ; then
|
||||
# [[ -f "$PATH_WARN_2" ]] && rm "$PATH_WARN_2"
|
||||
#fi
|
||||
|
||||
fi
|
||||
|
||||
if threshold2 ; then
|
||||
color="#FF0000" # red
|
||||
elif threshold1 ; then
|
||||
color="#FFFF00" # yellow
|
||||
else
|
||||
color="#FFFFFF" # white
|
||||
fi
|
||||
|
||||
|
||||
|
||||
echo "{ \"full_text\" : \" "${shortstatus} ${percent}% \" , \"color\" : \"$color\" , \"name\" : \"battery\" },
|
||||
}
|
||||
|
||||
if [[ "$1" == "conky" ]] ; then
|
||||
conky
|
||||
else
|
||||
pretty
|
||||
fi
|
||||
|
||||
|
||||
8
i3/i3/scripts/status.d/conky_pacman.bash
Normal file
8
i3/i3/scripts/status.d/conky_pacman.bash
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
updates=$(pacman -Quq | wc -l)
|
||||
if [[ $updates == 0 ]] ; then
|
||||
echo "no updates"
|
||||
else
|
||||
echo "$updates updates"
|
||||
fi
|
||||
6
i3/i3/scripts/status.d/pacman.bash
Normal file
6
i3/i3/scripts/status.d/pacman.bash
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Total packages: $(pacman -Qq | wc -l)"
|
||||
echo ""
|
||||
echo "Updates available:"
|
||||
echo "$(pacman -Qu | column -t)"
|
||||
35
i3/i3/scripts/status.d/sysinfo.bash
Normal file
35
i3/i3/scripts/status.d/sysinfo.bash
Normal file
@@ -0,0 +1,35 @@
|
||||
columnate() {
|
||||
column -t --separator="|"
|
||||
}
|
||||
|
||||
freeoutput="$(free -m)"
|
||||
memtotal=$(echo "$freeoutput" | head -2 | tail -1 | tr -s " " | cut -d " " -f 2)
|
||||
memused=$(echo "$freeoutput" | head -3 | tail -1 | tr -s " " | cut -d " " -f 3)
|
||||
|
||||
|
||||
(echo "Current user:|$(whoami)"
|
||||
echo "Hostname:|$(hostname)"
|
||||
echo "Uptime:|$(uptime --pretty | cut -d " " -f 2-)"
|
||||
echo "Kernel:|$(uname -r)"
|
||||
echo "Packages:|$(pacman -Qq | wc -l)") | columnate
|
||||
echo ""
|
||||
echo "CPU:"
|
||||
(echo "Name:|$(lscpu | grep "Model name:" | tr -s " " | cut -d " " -f 3-)"
|
||||
echo "Architecture:|$(uname -m)"
|
||||
echo "Temp:|$(sensors -u | grep "temp1_input" | cut -d ":" -f 2 | cut -d "." -f 1 | cut -c 2-)°C"
|
||||
echo "Load:|$(uptime | tr -s " " | cut -d " " -f 10 | tr -d ",")") | columnate
|
||||
echo ""
|
||||
echo "MEM:"
|
||||
echo "${memused}MB / ${memtotal}MB ($(( $memused * 100 / $memtotal ))% used)"
|
||||
echo ""
|
||||
echo "PROCS:"
|
||||
(echo "x x cpu% mem% x x x x x x command" ; ps aux | sort -nrk 3 | tr -s " " | cut -d " " -f -11 | uniq -uf 10 | head -10) | cut -d " " -f 3,4,11 | column -t
|
||||
echo ""
|
||||
echo "STORAGE:"
|
||||
df -hT --type=btrfs --type=ext4 --total
|
||||
echo ""
|
||||
echo "SWAP:"
|
||||
if [[ -z "$(swapon)" ]] ; then
|
||||
echo "none"
|
||||
fi
|
||||
|
||||
55
i3/i3/scripts/status.d/wireless.bash
Normal file
55
i3/i3/scripts/status.d/wireless.bash
Normal file
@@ -0,0 +1,55 @@
|
||||
#!/bin/bash
|
||||
INTERFACE="wlp2s0"
|
||||
TIMEFORMAT="+%F %R"
|
||||
|
||||
iwconfig_output="$(iwconfig $INTERFACE)"
|
||||
|
||||
columnize() {
|
||||
column -t --separator="|"
|
||||
}
|
||||
|
||||
essid=$(echo "$iwconfig_output" | sed -n "1p" | awk -F '"' '{print $2}')
|
||||
mode=$(echo "$iwconfig_output" | sed -n "1p" | awk -F " " '{print $3}')
|
||||
freq=$(echo "$iwconfig_output" | sed -n "2p" | awk -F " " '{print $2}' | cut -d":" -f2)
|
||||
mac=$(echo "$iwconfig_output" | sed -n "2p" | awk -F " " '{print $6}')
|
||||
qual=$(echo "$iwconfig_output" | sed -n "6p" | awk -F " " '{print $2}' | cut -d"=" -f2)
|
||||
lvl=$(echo "$iwconfig_output" | sed -n "6p" | awk -F " " '{print $4}' | cut -d"=" -f2)
|
||||
rate=$(echo "$iwconfig_output" | sed -n "3p" | awk -F "=" '{print $2}' | cut -d" " -f1)
|
||||
|
||||
ip=$(ip addr show $INTERFACE | grep "[[:space:]]*inet" | head -n 1 | tr -s " " | cut -d " " -f 3 | cut -d "/" -f 1)
|
||||
|
||||
vnstat_output="$(vnstat --dumpdb)"
|
||||
txhour=$(echo "$vnstat_output" | grep "^h;0;" | cut -d ";" -f 5)
|
||||
rxhour=$(echo "$vnstat_output" | grep "^h;0;" | cut -d ";" -f 4)
|
||||
txtoday=$(echo "$vnstat_output" | grep "^d;0;" | cut -d ";" -f 5)
|
||||
rxtoday=$(echo "$vnstat_output" | grep "^d;0;" | cut -d ";" -f 4)
|
||||
txtotal=$(echo "$vnstat_output" | grep "^totaltx;" | cut -d ";" -f 2)
|
||||
rxtotal=$(echo "$vnstat_output" | grep "^totalrx;" | cut -d ";" -f 2)
|
||||
vnstat_created="$(date --date=@$(echo "$vnstat_output" | grep "^created;" | cut -d ";" -f 2) "$TIMEFORMAT")"
|
||||
vnstat_last_update="$(date --date=@$(echo "$vnstat_output" | grep "^updated;" | cut -d ";" -f 2) "$TIMEFORMAT")"
|
||||
|
||||
echo "Interface $INTERFACE:"
|
||||
(
|
||||
echo "IP:|$ip"
|
||||
echo "ESSID:|$essid"
|
||||
echo "Mode:|$mode"
|
||||
echo "Frequency:|$freq"
|
||||
echo "MAC address:|$mac"
|
||||
echo "Quality:|$qual"
|
||||
echo "Signal level:|$lvl dBm"
|
||||
echo "Bitrate:|$rate Mb/s"
|
||||
) | columnize
|
||||
echo ""
|
||||
echo "Usage:"
|
||||
(
|
||||
echo "Hourly up:|${txhour} KiB"
|
||||
echo "Hourly down:|${rxhour} KiB"
|
||||
echo "Daily up:|${txtoday} MiB"
|
||||
echo "Daily down:|${rxtoday} MiB"
|
||||
echo "Total up:|${txtotal} MiB"
|
||||
echo "Total down:|${rxtotal} MiB"
|
||||
echo ""
|
||||
echo "Database created at:|$vnstat_created"
|
||||
echo "Last update at:|$vnstat_last_update"
|
||||
) | columnize
|
||||
|
||||
Reference in New Issue
Block a user