Add waybar module (split from hyprland)
This commit is contained in:
@ -6,7 +6,6 @@ source = ~/.config/hypr/input.conf
|
||||
source = ~/.config/hypr/monitors.conf
|
||||
source = ~/.config/hypr/polkit.conf
|
||||
source = ~/.config/hypr/translucentrules.conf
|
||||
source = ~/.config/hypr/waybar-reload.conf
|
||||
source = ~/.config/hypr/workspaces.conf
|
||||
source = ~/.config/hypr/workspacerules.conf
|
||||
|
||||
|
@ -61,6 +61,7 @@
|
||||
"nnn"
|
||||
"ranger"
|
||||
"vscode"
|
||||
"waybar"
|
||||
];
|
||||
system-modules = [
|
||||
"containers"
|
||||
|
@ -169,6 +169,10 @@ rec {
|
||||
# };
|
||||
|
||||
vscode.enable = true;
|
||||
|
||||
waybar = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
manual.manpages.enable = true;
|
||||
|
@ -25,5 +25,6 @@
|
||||
./nnn
|
||||
./ranger
|
||||
./vscode
|
||||
./waybar
|
||||
];
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
# TODO: The keys to reset the workspaces need to depend on actual workspace config
|
||||
{
|
||||
config,
|
||||
nixosConfig,
|
||||
@ -12,36 +13,7 @@ with mylib.modules; let
|
||||
in {
|
||||
options.modules.hyprland = import ./options.nix {inherit lib mylib;};
|
||||
|
||||
config = let
|
||||
# Taken from https://github.com/Ruixi-rebirth/flakes/blob/main/modules/programs/wayland/waybar/workspace-patch.nix
|
||||
hyprctl = "${pkgs.hyprland}/bin/hyprctl";
|
||||
workspaces-patch = pkgs.writeTextFile {
|
||||
name = "waybar-hyprctl.diff";
|
||||
text = ''
|
||||
diff --git a/src/modules/wlr/workspace_manager.cpp b/src/modules/wlr/workspace_manager.cpp
|
||||
index 6a496e6..a689be0 100644
|
||||
--- a/src/modules/wlr/workspace_manager.cpp
|
||||
+++ b/src/modules/wlr/workspace_manager.cpp
|
||||
@@ -511,7 +511,9 @@ auto Workspace::handle_clicked(GdkEventButton *bt) -> bool {
|
||||
if (action.empty())
|
||||
return true;
|
||||
else if (action == "activate") {
|
||||
- zext_workspace_handle_v1_activate(workspace_handle_);
|
||||
+ // zext_workspace_handle_v1_activate(workspace_handle_);
|
||||
+ const std::string command = "${hyprctl} dispatch workspace " + name_;
|
||||
+ system(command.c_str());
|
||||
} else if (action == "close") {
|
||||
zext_workspace_handle_v1_remove(workspace_handle_);
|
||||
} else {
|
||||
'';
|
||||
};
|
||||
|
||||
waybar-hyprland = pkgs.waybar.overrideAttrs (oldAttrs: {
|
||||
mesonFlags = oldAttrs.mesonFlags ++ ["-Dexperimental=true"];
|
||||
patches = (oldAttrs.patches or []) ++ [workspaces-patch];
|
||||
});
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
config = mkIf cfg.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion = nixosConfig.programs.hyprland.enable;
|
||||
@ -163,25 +135,6 @@ in {
|
||||
}
|
||||
'';
|
||||
|
||||
# TODO: I want to generate the config in ~/.config/waybar through nix again
|
||||
# to allow adding waybar options to the hyprland module (like monitor and style).
|
||||
# The goal is to set the style completely through nix...
|
||||
home.file.".config/hypr/waybar-reload.conf".text = let
|
||||
waybar-reload = pkgs.writeScript "waybar-reload" ''
|
||||
#! ${pkgs.bash}/bin/bash
|
||||
|
||||
trap "${pkgs.procps}/bin/pkill waybar" EXIT
|
||||
|
||||
while true; do
|
||||
${waybar-hyprland}/bin/waybar -c $HOME/NixFlake/config/waybar/config -s $HOME/NixFlake/config/waybar/style.css &
|
||||
${pkgs.inotifyTools}/bin/inotifywait -e create,modify $HOME/NixFlake/config/waybar/config $HOME/NixFlake/config/waybar/style.css
|
||||
${pkgs.procps}/bin/pkill waybar
|
||||
done
|
||||
'';
|
||||
in ''
|
||||
exec-once = ${waybar-reload}
|
||||
'';
|
||||
|
||||
# Set wallpaper for each configured monitor
|
||||
home.file.".config/hypr/hyprpaper.conf".text = let
|
||||
mkWallpaper = monitor: "wallpaper = ${monitor}, ${config.home.homeDirectory}/NixFlake/wallpapers/${cfg.theme}.png";
|
||||
@ -239,15 +192,6 @@ in {
|
||||
# theme =
|
||||
# extraConfig = '''';
|
||||
};
|
||||
|
||||
waybar = {
|
||||
enable = true;
|
||||
package = waybar-hyprland;
|
||||
|
||||
systemd = {
|
||||
enable = false; # Gets started by hyprland
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
73
home/modules/waybar/default.nix
Normal file
73
home/modules/waybar/default.nix
Normal file
@ -0,0 +1,73 @@
|
||||
# TODO: Generate the config modularly, like with hyprland
|
||||
# - It should especially be possible to set styling programatically, for themes
|
||||
{
|
||||
config,
|
||||
nixosConfig,
|
||||
lib,
|
||||
mylib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with mylib.modules; let
|
||||
cfg = config.modules.waybar;
|
||||
hypr = config.modules.hyprland;
|
||||
in {
|
||||
options.modules.waybar = import ./options.nix {inherit lib mylib;};
|
||||
|
||||
config = let
|
||||
# Taken from https://github.com/Ruixi-rebirth/flakes/blob/main/modules/programs/wayland/waybar/workspace-patch.nix
|
||||
hyprctl = "${pkgs.hyprland}/bin/hyprctl";
|
||||
workspaces-patch = pkgs.writeTextFile {
|
||||
name = "waybar-hyprctl.diff";
|
||||
text = ''
|
||||
diff --git a/src/modules/wlr/workspace_manager.cpp b/src/modules/wlr/workspace_manager.cpp
|
||||
index 6a496e6..a689be0 100644
|
||||
--- a/src/modules/wlr/workspace_manager.cpp
|
||||
+++ b/src/modules/wlr/workspace_manager.cpp
|
||||
@@ -511,7 +511,9 @@ auto Workspace::handle_clicked(GdkEventButton *bt) -> bool {
|
||||
if (action.empty())
|
||||
return true;
|
||||
else if (action == "activate") {
|
||||
- zext_workspace_handle_v1_activate(workspace_handle_);
|
||||
+ // zext_workspace_handle_v1_activate(workspace_handle_);
|
||||
+ const std::string command = "${hyprctl} dispatch workspace " + name_;
|
||||
+ system(command.c_str());
|
||||
} else if (action == "close") {
|
||||
zext_workspace_handle_v1_remove(workspace_handle_);
|
||||
} else {
|
||||
'';
|
||||
};
|
||||
|
||||
waybar-hyprland = pkgs.waybar.overrideAttrs (oldAttrs: {
|
||||
mesonFlags = oldAttrs.mesonFlags ++ ["-Dexperimental=true"];
|
||||
patches = (oldAttrs.patches or []) ++ [workspaces-patch];
|
||||
});
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
programs.waybar = {
|
||||
enable = true;
|
||||
package = waybar-hyprland;
|
||||
|
||||
systemd = {
|
||||
enable = false; # Gets started by hyprland
|
||||
};
|
||||
};
|
||||
|
||||
modules.hyprland.autostart = let
|
||||
waybar-reload = pkgs.writeScript "waybar-reload" ''
|
||||
#! ${pkgs.bash}/bin/bash
|
||||
|
||||
trap "${pkgs.procps}/bin/pkill waybar" EXIT
|
||||
|
||||
while true; do
|
||||
${waybar-hyprland}/bin/waybar -c $HOME/NixFlake/config/waybar/config -s $HOME/NixFlake/config/waybar/style.css &
|
||||
${pkgs.inotifyTools}/bin/inotifywait -e create,modify $HOME/NixFlake/config/waybar/config $HOME/NixFlake/config/waybar/style.css
|
||||
${pkgs.procps}/bin/pkill waybar
|
||||
done
|
||||
'';
|
||||
in [
|
||||
"${waybar-reload}"
|
||||
];
|
||||
};
|
||||
}
|
15
home/modules/waybar/options.nix
Normal file
15
home/modules/waybar/options.nix
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
lib,
|
||||
mylib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with mylib.modules; {
|
||||
enable = mkEnableOpt "Waybar";
|
||||
|
||||
monitor = mkOption {
|
||||
type = types.str;
|
||||
example = "HDMI-A-1";
|
||||
description = "What monitor to display the Waybar on";
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user