Skip to content

Commit

Permalink
feat: enable bluetooth indicator in waybar
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsgruk committed Dec 4, 2023
1 parent bb61981 commit 8a6d41c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
27 changes: 26 additions & 1 deletion home/common/desktop/waybar/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,30 @@ let
"battery"
"pulseaudio"
"pulseaudio#source"
"bluetooth"
"custom/power"
]
else [
"tray"
"pulseaudio"
"pulseaudio#source"
"bluetooth"
"custom/power"
];

bluetoothToggle = pkgs.writeShellApplication {
name = "bluetooth-toggle";
runtimeInputs = with pkgs; [ gnugrep bluez ];
text = ''
if [[ "$(bluetoothctl show | grep -Po "Powered: \K(.+)$")" =~ no ]]; then
bluetoothctl power on
bluetoothctl discoverable on
else
bluetoothctl power off
fi
'';
};

inherit ((import ../rofi/lib.nix { inherit lib; })) toRasi;
inherit ((import ../rofi/powermenu { inherit config lib desktop pkgs theme; })) rofi-power;
in
Expand Down Expand Up @@ -121,6 +136,15 @@ in
tooltip-format = "{source_volume}% / {desc}";
};

"bluetooth" = {
format-on = "";
format-connected = "{device_alias} ";
format-off = "!";
format-disabled = "!";
on-click-right = "${pkgs.blueberry}/bin/blueberry";
on-click = "${bluetoothToggle}/bin/bluetooth-toggle";
};

"custom/power" = {
format = "";
on-click = "${lib.getExe rofi-power} ${desktop}";
Expand All @@ -134,5 +158,6 @@ in
};

# This is a hack to ensure that hyprctl ends up in the PATH for the waybar service on hyprland
systemd.user.services.waybar.Service.Environment = lib.mkForce "PATH=${lib.makeBinPath [pkgs."${desktop}"]}";
systemd.user.services.waybar.Service.Environment = lib.mkForce
"PATH=${lib.makeBinPath [pkgs."${desktop}"]}";
}
5 changes: 5 additions & 0 deletions home/common/desktop/waybar/theme.nix
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
#custom-media,
#tray,
#mode,
#bluetooth,
#custom-power,
#custom-menu,
#idle_inhibitor" = {
Expand Down Expand Up @@ -101,5 +102,9 @@
"#temperature.critical" = {
color = mkLiteral "${theme.colours.red}";
};

"#bluetooth.off" = {
color = mkLiteral "${theme.colours.red}";
};
};
}

0 comments on commit 8a6d41c

Please sign in to comment.