Skip to content

Commit

Permalink
initial commit. readme is under work yet...
Browse files Browse the repository at this point in the history
  • Loading branch information
dacampsss committed Mar 16, 2021
1 parent 3d26ca3 commit 861446d
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 1 deletion.
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,29 @@
# polybar-dynamic-centered-tray
A bunch of scripts able to create a "dynamic traybar" experience for Polybar, making it behave kinda like a module.
Apenas alguns scripts capazes de criar a experiência de uma "traybar dinâmica" para a Polybar, fazendo-a com que se comporte *tipo* um módulo.

## Requisitos
1. Versão recente da [Polybar](https://github.com/polybar/polybar/);
2. i3wm (preferencialmente v.4.17+);
3. Instalar os scripts e o módulo corretamente.

## Instalação
1. Baixe a release mais recente ou clone este repositório com ```git clone https://github.com/daltroaugusto/polybar-dynamic-centered-tray.git```, depois navegue para a pasta extraída;
2. Execute ```sudo ./install``` (script de instalação com privilégios de superusuário), ou copie os scripts para uma pasta em seu ```$PATH```;
3. Insira o módulo ```polybar_trayoffset``` na posição em que desejar, no arquivo de configuração da Polybar:

<table>
<tbody>
<tr>
<td><img src="https://i.imgur.com/Jp2SVAv.png" /></td>
<td>
```
[module/trayoffset]
type = custom/script
interval = 1.0
exec = polybar_trayoffset echo
format = <label>
```
</td>
</tr>
</tbody>
</table>
2 changes: 2 additions & 0 deletions README_EN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# polybar-dynamic-centered-tray
A bunch of scripts able to create a "dynamic traybar" experience for Polybar, making it behave *kinda like* a module.
4 changes: 4 additions & 0 deletions install
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

install "$PWD/polybar_trayoffset" "/usr/local/bin/"
install "$PWD/watchps_tray" "/usr/local/bin/"
48 changes: 48 additions & 0 deletions polybar_trayoffset
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

# Script base que apenas insere e remove caracteres U+2000 (Unicode) no módulo, a fim de dar espaço para a traybar, que já pode ter um offset inicial configurado, a depender da intenção da rice/pessoa.
# EN: base script which just insert and remove U+2000 (Unicode) characters in the module, giving the needed offset for traybar, that may need some initial offset setted up, depending on ricing/people intentions.

# Daltro Augusto. 2021-. LGPLv2.

POLYBAR_TRAYOFFSET=$(<"${HOME}/.config/polybar/.trayoffset")
SYNTAX_TEXT="SYNTAX: [ \e[3madd [no. of spaces]\e[0m | \e[3mecho\e[0m | \e[3mremove\e[0m | \e[3mremove-all\e[0m ]"

case $1 in
add)
result="${POLYBAR_TRAYOFFSET}      "

if test -n "$2" -a "$2" -ge 1 2>/dev/null ; then
result="${POLYBAR_TRAYOFFSET}"

for((i=0; i<$2; i++)); do
result+=" "
done
fi

echo "$result" > "${HOME}/.config/polybar/.trayoffset"
;;

echo)
echo "${POLYBAR_TRAYOFFSET}"
;;

remove)
i=${POLYBAR_TRAYOFFSET}
offset=$((${#i} - 6))

if test -n "$2" -a "$2" -ge 1 2>/dev/null; then offset=$((${#i} - $2)); fi

result=${i:0:$offset}

echo "$result" > "${HOME}/.config/polybar/.trayoffset"
;;

remove-all)
echo "" > "${HOME}/.config/polybar/.trayoffset"
;;

*)
echo -e "$SYNTAX_TEXT"
;;
esac
18 changes: 18 additions & 0 deletions watchps_tray
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
# Este script é para ser hookado no arquivo i3config, usando os seletores for_window do i3wm.
# EN: script to be hooked in i3config file, with for_window i3wm's selectors.

# Daltro Augusto. 2021-. LGPLv2.

PS=$1
polybar_trayoffset add "$2"

while true
do
if [ "$(pidof "${PS}" | wc -l)" -eq 0 ]; then
polybar_trayoffset remove "$2"
break
fi

sleep 1
done

0 comments on commit 861446d

Please sign in to comment.