Adds polybar
This commit is contained in:
parent
56921bfdcc
commit
0f0b9089a4
12 changed files with 1090 additions and 0 deletions
127
.config/polybar/scripts/polywins/polywins.awk
Executable file
127
.config/polybar/scripts/polywins/polywins.awk
Executable file
|
|
@ -0,0 +1,127 @@
|
|||
#!/usr/bin/awk -f
|
||||
|
||||
BEGIN {
|
||||
# Setup
|
||||
active_left="%{F"active_text_color"}"
|
||||
active_right="%{F-}"
|
||||
inactive_left="%{F"inactive_text_color"}"
|
||||
inactive_right="%{F-}"
|
||||
separator="%{F"inactive_text_color"}"separator"%{F-}"
|
||||
|
||||
if (active_underline == "true") {
|
||||
active_left=active_left"%{+u}%{u"active_underline_color"}"
|
||||
active_right="%{-u}"active_right
|
||||
}
|
||||
|
||||
if (inactive_underline == "true") {
|
||||
inactive_left=inactive_left"%{+u}%{u"inactive_underline_color"}"
|
||||
inactive_right="%{-u}"inactive_right
|
||||
}
|
||||
|
||||
split(ignore_windows, ignored, ":")
|
||||
|
||||
cmd = "wmctrl -lx"
|
||||
}
|
||||
|
||||
function update_windows()
|
||||
{
|
||||
window_count = 0
|
||||
hidden_windows = 0
|
||||
|
||||
while (cmd | getline) {
|
||||
if ($2 != active_workspace && $2 != "-1") { continue }
|
||||
|
||||
is_ignored = 0
|
||||
for (window in ignored) {
|
||||
if ($3 ~ ignored[window]) {
|
||||
is_ignored = 1
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (is_ignored) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (window_count != 0) {
|
||||
# only on non-first items
|
||||
if (add_spaces == "true")
|
||||
printf " %s ", separator
|
||||
else
|
||||
printf "%s", separator
|
||||
}
|
||||
|
||||
if (window_count >= max_windows) {
|
||||
do ++hidden_windows
|
||||
while (cmd | getline)
|
||||
|
||||
printf "+%s", hidden_windows
|
||||
break
|
||||
}
|
||||
|
||||
if (show == "window_class") {
|
||||
displayed_name = $3
|
||||
sub(/.+\./, "", displayed_name)
|
||||
}
|
||||
else if (show == "window_classname") {
|
||||
displayed_name = $3
|
||||
sub(/\..+/, "", displayed_name)
|
||||
}
|
||||
else if (show == "window_title") {
|
||||
# format window title from wmctrl output
|
||||
title = ""
|
||||
|
||||
for (i = 5; i <= NF; i++) {
|
||||
title = title $i
|
||||
if (i != NF) title = title " "
|
||||
}
|
||||
|
||||
displayed_name = title
|
||||
}
|
||||
|
||||
if (char_case == "lower")
|
||||
displayed_name = tolower(displayed_name)
|
||||
else if (char_case == "upper")
|
||||
displayed_name = toupper(displayed_name)
|
||||
|
||||
if (length(displayed_name) > char_limit)
|
||||
displayed_name = substr(displayed_name, 1, char_limit)"…"
|
||||
|
||||
if ($1 == active_window)
|
||||
displayed_name=active_left displayed_name active_right
|
||||
else
|
||||
displayed_name=inactive_left displayed_name inactive_right
|
||||
|
||||
printf "%s%s%s%s%s%s%s",
|
||||
"%{A1:"on_click" raise_or_minimize "$1" "active_window":}",
|
||||
"%{A2:"on_click" close "$1":}",
|
||||
"%{A3:"on_click" slop_resize "$1":}",
|
||||
"%{A4:"on_click" increment_size "$1":}",
|
||||
"%{A5:"on_click" decrement_size "$1":}",
|
||||
displayed_name,
|
||||
"%{A}%{A}%{A}%{A}%{A}"
|
||||
|
||||
++window_count
|
||||
} close(cmd)
|
||||
|
||||
printf "\n"
|
||||
fflush(stdout)
|
||||
}
|
||||
|
||||
$1 == "_NET_CURRENT_DESKTOP" {
|
||||
active_workspace = $3
|
||||
update_windows()
|
||||
}
|
||||
|
||||
$1 == "_NET_ACTIVE_WINDOW:" && ($5 != "0x0") {
|
||||
# makes $5 long at least 10 characters if it is not already
|
||||
if (length($5) < 10)
|
||||
$5 = sprintf("0x%0" (10 - length($5)) "d%s", 0, substr($5, 3))
|
||||
|
||||
active_window = $5
|
||||
update_windows()
|
||||
}
|
||||
|
||||
$1 == "_NET_CURRENT_DESKTOP:" {
|
||||
update_windows()
|
||||
}
|
||||
72
.config/polybar/scripts/polywins/polywins.sh
Executable file
72
.config/polybar/scripts/polywins/polywins.sh
Executable file
|
|
@ -0,0 +1,72 @@
|
|||
#!/bin/sh
|
||||
# POLYWINS
|
||||
|
||||
# SETTINGS {{{ ---
|
||||
|
||||
active_text_color="#250F0B"
|
||||
active_underline="true"
|
||||
active_underline_color="#000000"
|
||||
inactive_text_color="#250F0B"
|
||||
inactive_underline="false"
|
||||
inactive_underline_color="#F1EF7D"
|
||||
separator="|"
|
||||
show="window_title" # options: window_title, window_class, window_classname
|
||||
char_limit=20 # useful with window_title
|
||||
max_windows=15 # maximum number of displayed windows
|
||||
char_case="normal" # options: normal, upper, lower
|
||||
add_spaces="true"
|
||||
resize_increment=30
|
||||
wm_border_width=0 # setting this might be required for accurate resize position
|
||||
ignore_windows="polybar:yad" # :-separated list of windows we want to ignore (bars, desktop managers, etc.)
|
||||
|
||||
# --- }}}
|
||||
|
||||
case "$1" in
|
||||
raise_or_minimize)
|
||||
if [ "$3" = "$2" ]; then
|
||||
wmctrl -ir "$2" -b toggle,hidden
|
||||
else
|
||||
wmctrl -ia "$2"
|
||||
fi
|
||||
;;
|
||||
close)
|
||||
wmctrl -ic "$2"
|
||||
;;
|
||||
slop_resize)
|
||||
wmctrl -ia "$2"
|
||||
wmctrl -ir "$2" -e "$(slop -f 0,%x,%y,%w,%h)"
|
||||
;;
|
||||
increment_size)
|
||||
wmctrl -ir "$2" -e "$(wmctrl -G -l |
|
||||
awk -v i="$resize_increment" \
|
||||
-v b="$wm_border_width" \
|
||||
-v win="$2" \
|
||||
'$1 ~ win {print "0,"$3-b*2-i/2","$4-b*2-i/2","$5+i","$6+i}')"
|
||||
;;
|
||||
decrement_size)
|
||||
wmctrl -ir "$2" -e "$(wmctrl -G -l |
|
||||
awk -v i="$resize_increment" \
|
||||
-v b="$wm_border_width" \
|
||||
-v win="$2" \
|
||||
'$1 ~ win {print "0,"$3-b*2+i/2","$4-b*2+i/2","$5-i","$6-i}')"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -n "$2" ]; then exit; fi
|
||||
|
||||
xprop -root -notype -spy _NET_ACTIVE_WINDOW _NET_CURRENT_DESKTOP _NET_CLIENT_LIST | \
|
||||
"${0%.*}.awk" \
|
||||
-v active_text_color="$active_text_color" \
|
||||
-v active_underline_color="$active_underline_color" \
|
||||
-v active_underline="$active_underline" \
|
||||
-v inactive_text_color="$inactive_text_color" \
|
||||
-v inactive_underline_color="$inactive_underline_color" \
|
||||
-v inactive_underline="$inactive_underline" \
|
||||
-v separator="$separator" \
|
||||
-v show="$show" \
|
||||
-v char_case="$char_case" \
|
||||
-v char_limit="$char_limit" \
|
||||
-v add_spaces="$add_spaces" \
|
||||
-v on_click="$0" \
|
||||
-v max_windows="$max_windows" \
|
||||
-v ignore_windows="$ignore_windows"
|
||||
Loading…
Add table
Add a link
Reference in a new issue