-
Notifications
You must be signed in to change notification settings - Fork 2
/
polybar_trayoffset
65 lines (47 loc) · 2.18 KB
/
polybar_trayoffset
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/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.
# polybar-i3-dynamic-trayoffset A bunch of scripts able to create a "dynamic traybar" experience for Polybar in i3wm, making it behave kinda like a module.
# Copyright (C) 2020- Daltro Augusto
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
! [ -f "$HOME/.config/.trayoffset" ] && touch "$HOME/.config/.trayoffset"
POLYBAR_TRAYOFFSET=$(<"${HOME}/.config/.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/.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/.trayoffset"
;;
remove-all)
echo "" > "${HOME}/.config/.trayoffset"
;;
*)
echo -e "$SYNTAX_TEXT"
;;
esac