i3status add headphones battery wrapper
This commit is contained in:
parent
da64c088f7
commit
cfdb0952ca
3
Makefile
3
Makefile
@ -67,12 +67,13 @@ gpg:
|
||||
echo -e "default-cache-ttl 1\nmax-cache-ttl 1" > ~/.gnupg/gpg-agent.conf; echo RELOADAGENT | gpg-connect-agent
|
||||
|
||||
i3:
|
||||
@echo "sudo pacman -S nitrogen picom compton ttf-font-awesome xdotool xclip maim"
|
||||
@echo "sudo pacman -S nitrogen picom jq compton ttf-font-awesome xdotool xclip maim"
|
||||
test -d ~/.config/i3 || \
|
||||
mkdir -p ~/.config/i3
|
||||
mkdir -p ~/.config/i3status
|
||||
ln -s $(PWD)/sub/i3/config ~/.config/i3/config
|
||||
ln -s $(PWD)/sub/i3/statusconfig ~/.config/i3status/config
|
||||
ln -s $(PWD)/functions/i3status_wrapper.sh ~/.local/bin/i3status_wrapper.sh
|
||||
|
||||
bat:
|
||||
test -d ~/.config/bat || \
|
||||
|
||||
56
functions/i3status_wrapper.sh
Executable file
56
functions/i3status_wrapper.sh
Executable file
@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# The idea is to define "holder" modules in i3status config and then replace them
|
||||
|
||||
# In order to make this example work you need to add
|
||||
# order += "tztime holder__headphones"
|
||||
# and
|
||||
# tztime holder__headphones {
|
||||
# format = "holder__headphones"
|
||||
# }
|
||||
# in i3staus config
|
||||
|
||||
# Don't forget that i3status config should contain:
|
||||
# general {
|
||||
# output_format = i3bar
|
||||
# }
|
||||
#
|
||||
# and i3 config should contain:
|
||||
# bar {
|
||||
# status_command exec /path/to/this/script.sh
|
||||
# }
|
||||
|
||||
# Make sure jq is installed
|
||||
|
||||
# You can easily add multiple custom modules using additional "holders"
|
||||
|
||||
function update_holder {
|
||||
|
||||
local instance="$1"
|
||||
local replacement="$2"
|
||||
echo "$json_array" | jq --argjson arg_j "$replacement" "(.[] | (select(.instance==\"$instance\"))) |= \$arg_j"
|
||||
}
|
||||
|
||||
function remove_holder {
|
||||
|
||||
local instance="$1"
|
||||
echo "$json_array" | jq "del(.[] | (select(.instance==\"$instance\")))"
|
||||
}
|
||||
|
||||
function headphones {
|
||||
|
||||
battery_status="$(bluetoothctl info 14:0A:29:0A:6A:2F | grep "Battery Percentage" | awk -F '[()]' '{ print "🎧"$2"%" }')"
|
||||
|
||||
local json="{ \"full_text\": \"$battery_status\", \"color\": \"#FFFFFF\"}"
|
||||
|
||||
json_array=$(update_holder holder__headphones "$json")
|
||||
|
||||
}
|
||||
|
||||
i3status | (read line; echo "$line"; read line ; echo "$line" ; read line ; echo "$line" ; while true
|
||||
do
|
||||
read line
|
||||
json_array="$(echo $line | sed -e 's/^,//')"
|
||||
headphones
|
||||
echo ",$json_array"
|
||||
done)
|
||||
@ -198,7 +198,7 @@ bindsym $mod+r mode "resize"
|
||||
# Start i3bar to display a workspace bar (plus the system information i3status
|
||||
# finds out, if available)
|
||||
bar {
|
||||
status_command i3status
|
||||
status_command exec ~/.local/bin/i3status_wrapper.sh
|
||||
tray_output DP-0
|
||||
}
|
||||
|
||||
|
||||
@ -7,8 +7,9 @@
|
||||
# If the above line is not correctly displayed, fix your editor first!
|
||||
|
||||
general {
|
||||
colors = true
|
||||
interval = 5
|
||||
colors = true
|
||||
interval = 5
|
||||
output_format = i3bar
|
||||
}
|
||||
|
||||
order += "ipv6"
|
||||
@ -20,38 +21,40 @@ order += "disk /home"
|
||||
order += "memory"
|
||||
order += "cpu_usage"
|
||||
order += "cpu_temperature 0"
|
||||
order += "tztime holder__headphones"
|
||||
order += "volume master"
|
||||
order += "tztime local"
|
||||
|
||||
wireless _first_ {
|
||||
format_up = " (%quality at %essid) %ip"
|
||||
format_down = " down"
|
||||
format_up = " (%quality at %essid) %ip"
|
||||
format_down = " down"
|
||||
}
|
||||
|
||||
ethernet _first_ {
|
||||
format_up = " %ip"
|
||||
format_down = " down"
|
||||
format_up = " %ip"
|
||||
format_down = " down"
|
||||
}
|
||||
|
||||
battery all {
|
||||
format = " %status %percentage %remaining"
|
||||
format = " %status %percentage %remaining"
|
||||
}
|
||||
|
||||
disk "/" {
|
||||
format = "/ %used/%total"
|
||||
format = "/ %used/%total"
|
||||
}
|
||||
|
||||
disk "/home" {
|
||||
format = " %used/%total"
|
||||
format = " %used/%total"
|
||||
}
|
||||
|
||||
load {
|
||||
format = "%1min"
|
||||
format = "%1min"
|
||||
}
|
||||
|
||||
memory {
|
||||
format = "%used/%available"
|
||||
threshold_degraded = "1G"
|
||||
format_degraded = "MEMORY < %available"
|
||||
format = "%used/%available"
|
||||
threshold_degraded = "1G"
|
||||
format_degraded = "MEMORY < %available"
|
||||
}
|
||||
|
||||
cpu_usage {
|
||||
@ -65,5 +68,18 @@ cpu_temperature 0 {
|
||||
}
|
||||
|
||||
tztime local {
|
||||
format = " %Y-%m-%d %H:%M:%S"
|
||||
format = " %Y-%m-%d %H:%M:%S"
|
||||
}
|
||||
|
||||
volume master {
|
||||
format = " %volume" # шаблон громкости в активном состоянии
|
||||
format_muted = " %volume" # шаблон громкости в состоянии muted (без звука)
|
||||
device = "default"
|
||||
mixer = "Master"
|
||||
mixer_idx = 0
|
||||
}
|
||||
|
||||
|
||||
tztime holder__headphones {
|
||||
format = "holder__headphones"
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user