-
-
Notifications
You must be signed in to change notification settings - Fork 149
/
ob-button-set.sh
executable file
·62 lines (47 loc) · 2.31 KB
/
ob-button-set.sh
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
#!/usr/bin/env sh
# Desc: Set-up Openbox button or toggle decoration.
# Author: Harry Kurn <[email protected]>
# URL: https://github.com/owl4ce/dotfiles/tree/ng/.config/openbox/joyful-desktop/ob-button-set.sh
# SPDX-License-Identifier: ISC
# shellcheck disable=SC3044
export LANG='POSIX'
exec >/dev/null 2>&1
. "${HOME}/.joyfuld"
case "${1}" in
'') BUTTON="$(for LS in "$OB_BUTTON_STYLE_DIR"/*; do
[ ! -d "$LS" ] || echo "${LS##*/}"
done \
| rofi -theme-str '@import "action.rasi"' \
-no-show-icons \
-no-lazy-grab \
-no-plugins \
-dmenu \
-mesg 'Select Window Button-Style')"
[ -n "$BUTTON" ] || exit ${?}
# https://gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html#:~:text=expand_aliases
[ -z "$BASH" ] || shopt -s expand_aliases
joyd_cross_variables
ln -fnrs "${OB_BUTTON_STYLE_DIR}/${BUTTON}"/*.'xbm' "${OBT_D}/"
sed -e "/^ob_button_style.${CHK_THEME}.${CHK_MODE}[ ]*/s|\".*\"$|\"${BUTTON}\"|" -i "$THEME_FILE"
;;
s*) if [ "$CHK_OB_BUTTON_LOC" != 'left' ]; then
sed -e '/^[ ]*<titleLayout>/s|>[A-Z]*<|>CIML<|' -i "$OB_CONFIG"
sed -e "/^ob_button_location.${CHK_THEME}.${CHK_MODE}[ ]*/s|\"[a-z]*\"$|\"left\"|" -i "$THEME_FILE"
elif [ "$CHK_OB_BUTTON_LOC" != 'right' ]; then
sed -e '/^[ ]*<titleLayout>/s|>[A-Z]*<|>LIMC<|' -i "$OB_CONFIG"
sed -e "/^ob_button_location.${CHK_THEME}.${CHK_MODE}[ ]*/s|\"[a-z]*\"$|\"right\"|" -i "$THEME_FILE"
fi
;;
d*) CHK_OB_DECOR_LINE="$(grep -m1 -Fno '<application class="*" type="normal">' "$OB_CONFIG")" \
CHK_OB_DECOR_LINE="$((${CHK_OB_DECOR_LINE%%:*}+1))"
CHK_OB_DECOR_STAT="$(sed -e "${CHK_OB_DECOR_LINE}s|^[ ]*<decor>\(.*\)</decor>$|\1|p" -n "$OB_CONFIG")"
if [ "$CHK_OB_DECOR_STAT" != 'yes' ]; then
sed -e "${CHK_OB_DECOR_LINE}s|<decor>[a-z]*</decor>$|<decor>yes</decor>|" -i "$OB_CONFIG"
elif [ "$CHK_OB_DECOR_STAT" != 'no' ]; then
sed -e "${CHK_OB_DECOR_LINE}s|<decor>[a-z]*</decor>$|<decor>no</decor>|" -i "$OB_CONFIG"
fi
ARGS='--restart'
;;
esac
openbox --reconfigure ${ARGS} &
exit ${?}