aboutsummaryrefslogtreecommitdiff
path: root/.config/bspwm/bspwmrc
blob: 241c65c65b1f6596dfbcba718675379c7845ed0e (plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
#! /bin/sh

################################################################################
#                ██████╗ ███████╗██████╗ ██╗    ██╗███╗   ███╗                 #
#                ██╔══██╗██╔════╝██╔══██╗██║    ██║████╗ ████║                 #
#                ██████╔╝███████╗██████╔╝██║ █╗ ██║██╔████╔██║                 #
#                ██╔══██╗╚════██║██╔═══╝ ██║███╗██║██║╚██╔╝██║                 #
#                ██████╔╝███████║██║     ╚███╔███╔╝██║ ╚═╝ ██║                 #
#                ╚═════╝ ╚══════╝╚═╝      ╚══╝╚══╝ ╚═╝     ╚═╝                 #
################################## By: srdusr ##################################

# ##############################################################################
# #                                  ENV VARS                                  #
# ##############################################################################

## Environments
export PATH="${PATH}:${HOME}/.config/bspwm/bin"

# Get the name of the primary monitor
mainmonitor=$(xrandr --query | awk '/ primary/{print $1}')

## Monitors
# If no primary monitor is identified, use the first connected monitor
if [ "$mainmonitor" = "" ]; then
    mainmonitor=$(xrandr --query | awk '/ connected/ {print $1; exit}')
fi

# Set up workspaces on the primary monitor
bspc monitor "$mainmonitor" -d 󰲡 󰲣 󰲥 󰲧 󰲩 #1 2 3 4 5

# Check the number of connected monitors
connected_monitors=$(xrandr --query | grep -c " connected")

if [ "$connected_monitors" -gt 1 ]; then
    # Get the name of the secondary monitor (exclude the primary monitor)
    secondmonitor=$(xrandr --query | awk '/ connected/ && $1 != "'"$mainmonitor"'" {print $1; exit}')

    # Set up workspaces on the secondary monitor
    bspc monitor "$secondmonitor" -d 󰲫 󰲭 󰲯 󰲱 󰿭 #6 7 8 9 10
    # Check if the secondary monitor is connected and configure the layout
    if [ "$secondmonitor" != "" ]; then
        xrandr --output "$mainmonitor" --primary --auto --output "$secondmonitor" --auto --right-of "$mainmonitor"
    fi
fi

#INTERNAL_MONITOR="LVDS-1"
#EXTERNAL_MONITOR="HDMI-1"
## on first load setup default workspaces
#if [[ "$1" = 0 ]]; then
#	if [[ $(xrandr -q | grep "${EXTERNAL_MONITOR} connected") ]]; then
#		bspc monitor "$EXTERNAL_MONITOR" -d 1 2 3 4 5
#		bspc monitor "$INTERNAL_MONITOR" -d 6 7 8 9 10
#		bspc wm -O "$EXTERNAL_MONITOR" "$INTERNAL_MONITOR"
#	else
#		bspc monitor "$INTERNAL_MONITOR" -d 1 2 3 4 5 6 7 8 9 10
#	fi
#fi

# ##############################################################################
# #                                  FUNCTIONS                                 #
# ##############################################################################

config() { bspc config "$@" & }
rule() { bspc rule -a "$@" & }
run_once() {
    if [ ! "$(pgrep -f "$1")" ]; then
        "$@" &
    fi
}

# ##############################################################################
# #                                 WINDOW RULES                               #
# ##############################################################################

## Rules
bspc rule -r *:* # remove all rules first
rule '*' --one-shot state=below private=border_width:10
rule '*:Tiled' --one-shot state=tiled rectangle=50x50+0+50
rule '*' --one-shot state=floating rectangle=50x50+0+50
#rule \* rectangle=680x700+340+40
rule '*:*:Picture-in-Picture' state=floating sticky=on layer=above
rule '*:*:Picture in picture' state=floating sticky=on layer=above
rule firefox:Toolkit focus=on state=floating sticky=on layer=above rectangle=522x320+830+280 #320x190+1030+480 #522x316-10+280
rule "https://www.youtube.com - Enhancer for YouTube™ — Mozilla Firefox" state=floating sticky=on layer=above
rule Wezterm state=floating
rule Zathura state=tiled
rule Pavucontrol state=floating rectangle=490x260+862+37
rule Blueman-manager state=floating rectangle=536x420+818+37 #490x260-9+37
rule scratchpad sticky=on state=floating # SCRATCHPAD
rule heads-up-display sticky=on state=floating rectangle=360x160+990+40 # Heads Up Display (scratchpad)
rule Onboard sticky=on state=floating rectangle=700x205+480-89 # Virtual keyboard
rule Plank layer=above border=off
rule firefox desktop='^1'
rule Spotify desktop='^5'

# ##############################################################################
# #                                AUTOSTART APPS                              #
# ##############################################################################

#"$HOME"/.scripts/bspwm_setup_monitors &
pgrep -x sxhkd >/dev/null || sxhkd &
picom -b --experimental-backends &
#xfce4-panel --disable-wm-check &
"$HOME"/.config/polybar/launch.sh &
dunst &     # notification daemon
unclutter & # Remove mouse when idle
nitrogen --force-setter=xinerama --restore &
"$HOME"/.scripts/lockscreen-wallpaper &
xss-lock -- betterlockscreen -l &

# Run polkit daemon if doesn't started.
#[ "$(pidof xfce-polkit)" != "" ] || /usr/lib/xfce-polkit/xfce-polkit &
/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 &

#rm "$HOME"/.cache/dunst.log
#rm -r "$HOME"/.cache/dunst/
#rm "$HOME"/.cache/eww-control-center.lock
pkill eww
eww daemon
#eww open notification-popup
#"$HOME"/.local/bin/eww open bar &
#xdo lower -N eww-bar
#"$(which eww)" -c "$HOME"/.config/eww --restart open bar &
#pkill hotspots
#hotspots &
#pkill logs.sh
#logs.sh &

# Volume and brightness indicator (xob)
# Activate virtual environment
source "$HOME"/.virtualenvs/bin/activate
run_once "$HOME"/.config/xob/launch.sh &
## Deactivate virtual environment
deactivate

#wmname LG3D # Fixes Java applications
#export QT_QPA_PLATFORMTHEME="qt5ct" # Use qt5ct to set Qt theme
pkill low-bat-notifier
low-bat-notifier &
pkill plank.sh
plank.sh &
#run_once signal-desktop --start-in-tray & #--use-tray-icon
#run_once onboard --not-show-in=DESKTOPS &

declare -a restart=(plank flameshot clipit redshift blueman-applet)
for i in "${restart[@]}"; do
    pgrep -x "$i" | xargs kill
    sleep 0.5
    eval "$i" &
done

if [[ ! $(pidof stalonetray) ]]; then
    stalonetray &
    sleep 0.5
    xdo hide -N stalonetray
    touch "/tmp/syshide.lock"
fi


# ##############################################################################
# #                            CONFIGURATION                                   #
# ##############################################################################

## Config
PANEL_HEIGHT=30
config top_padding "$PANEL_HEIGHT"
config honor_size_hints true
config automatic_scheme alternate
config initial_polarity second_child
config pointer_modifier mod1
#config pointer_modifier mod2
config pointer_action1 move
config pointer_action2 resize_side
config pointer_action3 resize_corner
config focus_follows_pointer false
config remove_disabled_monitors true
config remove_unplugged_monitors true
config merge_overlapping_monitors true
config border_width 2
config window_gap 10
config split_ratio 0.52
config borderless_monocle true
config gapless_monocle true
config swallow_first_click false
#config pointer_action1 resize_side
#config pointer_action1 resize_corner
#config pointer_action3 move
config normal_border_color "#404040"
config focused_border_color "#000000"
config active_border_color "#000000"
config presel_feedback_color "#BF616A"
#config normal_border_color "#282828"
#config active_border_color "#ebdbb2"
#config focused_border_color "#fe8019"


# ##############################################################################
# #                                 MISCELLANEOUS                              #
# ##############################################################################

## Fullscreen
bspc subscribe node_state | while read -r _ _ _ _ state flag; do
    if [[ "$state" != fullscreen ]]; then continue; fi
    if [[ "$flag" == on ]]; then
        xdo lower -N Plank
        #"$(which eww)" -c "$HOME"/.config/eww close-all
    else
        xdo raise -N Plank
        #"$(which eww)" -c "$HOME"/.config/eww open bar
    fi
done &

## Title-bar
pkill -9 title-bar && pkill -9 lemonbar
# Check if title-bar is already running
if ! pgrep -x "title-bar" >/dev/null; then
    # Create a lock file
    lockfile="/tmp/title-bar.lock"

    # Check if the lock file exists
    if [ ! -e "$lockfile" ]; then
        # Create the lock file
        touch "$lockfile"

        # Start bspc subscribe in the background
        bspc subscribe | while read; do
            if ! pgrep -x "title-bar" >/dev/null; then
                bash "$HOME/.scripts/title-bar" &
            fi
        done &

        # Remove the lock file when the script exits
        trap 'rm -f "$lockfile"' EXIT
    else
        echo "title-bar is already running."
    fi
fi

#config external_rules_command ~/.config/bspwm/scripts/external_rules.sh