11 | # Created: August 19, 2025
12 | # License: MIT
13 |
14 | fcconf=()
15 | # Get fzf color config
16 | # shellcheck disable=SC1090,SC2154
17 | . ~/.config/waybar/scripts/_fzf_colorizer.sh 2> /dev/null || true
18 | # If the file is missing, fzf will fall back to its default colors
19 |
20 | RED='\033[1;31m'
21 | RST='\033[0m'
22 |
23 | TIMEOUT=10
24 |
25 | ensure-on() {
26 | local status
27 | status=$(bluetoothctl show | awk '/PowerState/ {print $2}')
28 |
29 | case $status in
30 | 'off') bluetoothctl power on > /dev/null ;;
31 | 'off-blocked')
32 | rfkill unblock bluetooth
33 |
34 | local i new_status
35 | for ((i = 1; i <= TIMEOUT; i++)); do
36 | printf '\rUnblocking Bluetooth... (%d/%d)' $i $TIMEOUT
37 |
38 | new_status=$(bluetoothctl show | awk '/PowerState/ {print $2}')
39 | if [[ $new_status == 'on' ]]; then
40 | break
41 | fi
42 | sleep 1
43 | done
44 |
45 | # Bluetooth could be hard blocked
46 | if [[ $new_status != 'on' ]]; then
47 | notify-send 'Bluetooth' 'Failed to unblock' -i 'package-purge'
48 | return 1
49 | fi
50 | ;;
51 | *) return 0 ;;
52 | esac
53 |
54 | notify-send 'Bluetooth On' -i 'network-bluetooth-activated' -r 1925
55 | }
56 |
57 | get-device-list() {
58 | bluetoothctl --timeout $TIMEOUT scan on > /dev/null &
59 |
60 | local i num
61 | for ((i = 1; i <= TIMEOUT; i++)); do
62 | printf '\rScanning for devices... (%d/%d)' $i $TIMEOUT
63 | printf '\n%bPress [q] to stop%b\n\n' "$RED" "$RST"
64 |
65 | num=$(bluetoothctl devices | grep -c 'Device')
66 | printf '\rDevices: %s' "$num"
67 | printf '\033[3A'
68 |
69 | read -rs -n 1 -t 1
70 | if [[ $REPLY == [Qq] ]]; then
71 | break
72 | fi
73 | done
74 | printf '\n%bScanning stopped.%b\n\n' "$RED" "$RST"
75 |
76 | list=$(bluetoothctl devices | sed 's/^Device //')
77 | if [[ -z $list ]]; then
78 | notify-send 'Bluetooth' 'No devices found' -i 'package-broken'
79 | return 1
80 | fi
81 | }
82 |
83 | select-device() {
84 | local header
85 | header=$(printf '%-17s %s' 'Address' 'Name')
86 | local opts=(
87 | '--border=sharp'
88 | '--border-label= Bluetooth Devices '
89 | '--ghost=Search'
90 | "--header=$header"
91 | '--height=~100%'
92 | '--highlight-line'
93 | '--info=inline-right'
94 | '--pointer='
95 | '--reverse'
96 | "${fcconf[@]}"
97 | )
98 |
99 | address=$(fzf "${opts[@]}" <<< "$list" | awk '{print $1}')
100 | if [[ -z $address ]]; then
101 | return 1
102 | fi
103 |
104 | local connected
105 | connected=$(bluetoothctl info "$address" | awk '/Connected/ {print $2}')
106 | if [[ $connected == 'yes' ]]; then
107 | notify-send 'Bluetooth' 'Already connected to this device' \
108 | -i 'package-install'
109 | return 1
110 | fi
111 | }
112 |
113 | pair-and-connect() {
114 | local paired
115 | paired=$(bluetoothctl info "$address" | awk '/Paired/ {print $2}')
116 | if [[ $paired == 'no' ]]; then
117 | printf 'Pairing...'
118 | if ! timeout $TIMEOUT bluetoothctl pair "$address" > /dev/null; then
119 | notify-send 'Bluetooth' 'Failed to pair' -i 'package-purge'
120 | return 1
121 | fi
122 | fi
123 |
124 | printf '\nConnecting...'
125 | if ! timeout $TIMEOUT bluetoothctl connect "$address" > /dev/null; then
126 | notify-send 'Bluetooth' 'Failed to connect' -i 'package-purge'
127 | return 1
128 | fi
129 | notify-send 'Bluetooth' 'Successfully connected' -i 'package-install'
130 | }
131 |
132 | main() {
133 | tput civis
134 | ensure-on || exit 1
135 | get-device-list || exit 1
136 | tput cnorm
137 | select-device || exit 1
138 | pair-and-connect || exit 1
139 | }
140 |
141 | main
142 |
--------------------------------------------------------------------------------
/.github/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## 🤖 mechabar
4 |
5 | A mecha-themed, modular Waybar configuration.
6 |
7 | |  |
8 | | :--------------------------------------: |
9 |
10 |
11 | Themes
12 |
13 | Catppuccin:
14 |
15 | | Mocha (default) |
16 | | :----------------------------------------------: |
17 | |  |
18 |
19 | | Macchiato |
20 | | :------------------------------------------------------: |
21 | |  |
22 |
23 | | Frappe |
24 | | :------------------------------------------------: |
25 | |  |
26 |
27 | | Latte |
28 | | :----------------------------------------------: |
29 | |  |
30 |
31 | Feel free to open a pull request if you'd like to add themes! :^)
32 |
33 |
34 |
35 |
36 | #
37 |
38 | ### Prerequisites
39 |
40 | 1. **[Waybar](https://github.com/Alexays/Waybar)**
41 |
42 | > [!WARNING]
43 | > **Waybar v0.14.0** introduced an [issue](https://github.com/Alexays/Waybar/issues/4354) that breaks [wildcard includes](/config.jsonc#L3-L10).
44 | > [Clone the `fix/v0.14.0` branch](#clone-fix-branch) as a temporary workaround.
45 |
46 | 2. A **terminal emulator** (default: `kitty`)
47 |
48 | > [!IMPORTANT]
49 | > If you use a different terminal emulator (e.g., `ghostty`),
50 | > you need to replace all invocations of `kitty` with your terminal command:
51 | >
52 | > ```diff
53 | > - "on-click": "kitty -e ..."
54 | > + "on-click": "ghostty -e ..."
55 | > ```
56 |
57 | #
58 |
59 | ### Installation
60 |
61 | 1. Back up your current config:
62 |
63 | ```bash
64 | mv ~/.config/waybar{,.bak}
65 | ```
66 |
67 | 2. Clone the repository:
68 |
69 | ```bash
70 | git clone https://github.com/sejjy/mechabar.git ~/.config/waybar
71 | ```
72 |
73 | For **Waybar v0.14.0**:
74 |
75 | ```bash
76 | git clone -b fix/v0.14.0 https://github.com/sejjy/mechabar.git ~/.config/waybar
77 | ```
78 |
79 | 3. Run [`install.sh`](/install.sh):
80 |
81 | ```bash
82 | ~/.config/waybar/install.sh
83 | ```
84 |
85 | This makes the [scripts](/scripts/) executable and installs the following dependencies:
86 |
87 |
88 | Packages (8)
89 |
90 | | Package | Command | Description |
91 | | ---------------------- | --------------- | ------------------------------------------------------------------------------ |
92 | | `bluez` | - | Daemons for the bluetooth protocol stack
|
93 | | `bluez-utils` | `bluetoothctl` | Development and debugging utilities for the bluetooth protocol stack
|
94 | | `brightnessctl` | `brightnessctl` | Lightweight brightness control tool
|
95 | | `fzf` | `fzf` | Command-line fuzzy finder
|
96 | | `networkmanager` | `nmcli` | Network connection manager and user applications
|
97 | | `pacman-contrib` | `checkupdates` | Contributed scripts and tools for pacman systems
|
98 | | `pipewire-pulse` | - | Low-latency audio/video router and processor - PulseAudio replacement
|
99 | | `otf-commit-mono-nerd` | - | Patched font Commit Mono from nerd fonts library |
100 |
101 |
102 |
103 | #
104 |
105 | ### Customization
106 |
107 |
108 | Binds
109 |
110 | You can set keybinds to interact with modules via [scripts](/scripts/). Example:
111 |
112 | ```properties
113 | # ~/.config/hypr/hyprland.conf
114 |
115 | $mod = SUPER
116 | $term = kitty
117 | $scr = ~/.config/waybar/scripts
118 |
119 | bind = $mod, B, exec, $term -e $scr/bluetooth.sh
120 | bind = $mod, N, exec, $term -e $scr/network.sh
121 | bind = $mod, O, exec, $term -e $scr/power-menu.sh
122 | bind = $mod, U, exec, $term -e $scr/system-update.sh
123 |
124 | bindl = , XF86AudioMicMute, exec, $scr/volume.sh input mute
125 | bindl = , XF86AudioMute, exec, $scr/volume.sh output mute
126 | bindel = , XF86AudioLowerVolume, exec, $scr/volume.sh output lower
127 | bindel = , XF86AudioRaiseVolume, exec, $scr/volume.sh output raise
128 | bindel = , XF86MonBrightnessDown, exec, $scr/backlight.sh down
129 | bindel = , XF86MonBrightnessUp, exec, $scr/backlight.sh up
130 | ```
131 |
132 | #
133 |
134 |
135 |
136 |
137 | Icons
138 |
139 | You can search for icons on [Nerd Fonts: Cheat Sheet ↗](https://www.nerdfonts.com/cheat-sheet). Example:
140 |
141 | ```
142 | battery charging
143 | ```
144 |
145 | For consistency, most modules use icons from Material Design, prefixed with `nf-md`:
146 |
147 | ```
148 | nf-md battery charging
149 | ```
150 |
151 | See [Nerd Fonts wiki: Glyph Sets](https://github.com/ryanoasis/nerd-fonts/wiki/Glyph-Sets-and-Code-Points#glyph-sets) for more info.
152 |
153 | #
154 |
155 |
156 |
157 |
158 | Theme
159 |
160 | Copy your preferred theme from the [themes](/themes/) directory into `current-theme.css`. Example:
161 |
162 | ```bash
163 | cd ~/.config/waybar
164 | cp themes/catppuccin-latte.css current-theme.css
165 | ```
166 |
167 |
168 |
169 | #
170 |
171 | ### Documentation
172 |
173 | - [Waybar wiki](https://github.com/Alexays/Waybar/wiki)
174 |
175 | - Man pages:
176 |
177 | ```bash
178 | man waybar
179 | man waybar-styles
180 | man waybar-custom
181 | man waybar-
182 | man waybar--
183 | ```
184 |
185 | #
186 |
187 | ### Credits
188 |
189 | - Themes: [Catppuccin](https://github.com/catppuccin/waybar)
190 | - Original font: [Commit Mono](https://github.com/eigilnikolajsen/commit-mono)
191 | - Patched font: [CommitMono Nerd Font](https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/CommitMono)
192 |
--------------------------------------------------------------------------------