Skip to content

Commit

Permalink
Refactor EWW configuration and scripts for improved organization and …
Browse files Browse the repository at this point in the history
…functionality
  • Loading branch information
ryanwclark committed Dec 22, 2024
1 parent 8a3b1eb commit 6872c66
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 41 deletions.
64 changes: 28 additions & 36 deletions home/features/desktop/hyprland/eww/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,30 @@
./launch_bar.nix
];

programs = {
eww = {
enable = true;
package = pkgs.eww;
enableZshIntegration = true;
enableBashIntegration = true;
enableFishIntegration = true;
# configDir = "${config.home.homeDirectory}/.config/eww";
};
};


home.packages = with pkgs; [
pkgs.eww
];

# configuration
# # configuration
home.file.".config/eww/eww.scss".source = ./eww.scss;
home.file.".config/eww/eww.yuck".source = ./eww.yuck;
home.file.".config/eww/colors.scss".source = ./colors.scss;
home.file.".config/eww/eww_windows.yuck".source = ./eww_windows.yuck;
home.file.".config/eww/eww_widgets.yuck".source = ./eww_widgets.yuck;
home.file.".config/eww/eww_variables.yuck".source = ./eww_variables.yuck;
home.file.".config/eww/variables.yuck".source = ./variables.yuck;
home.file.".config/eww/eww_widgets.yuck".source = ./eww_widgets.yuck;
home.file.".config/eww/eww_windows.yuck".source = ./eww_windows.yuck;
home.file.".config/eww/variables.yuck".source = ./variables.yuck;

# scripts
home.file.".config/eww/actions" = {
source = ./actions;
recursive = true;
};

home.file.".config/eww/assets" = {
source = ./assets;
recursive = true;
};

home.file.".config/eww/bar" = {
source = ./bar;
recursive = true;
Expand All @@ -52,28 +48,24 @@
recursive = true;
};

home.file.".config/eww/images" = {
source = ./images;
recursive = true;
};

home.file.".config/eww/powermenu" = {
source = ./powermenu;
recursive = true;
};

# home.file.".config/eww/scripts/wifi.sh" = {
# source = ./scripts/wifi.sh;
# executable = true;
# };

# home.file.".config/eww/scripts/brightness.sh" = {
# source = ./scripts/brightness.sh;
# executable = true;
# };

# home.file.".config/eww/scripts/workspaces.sh" = {
# source = ./scripts/workspaces.sh;
# executable = true;
# };

# home.file.".config/eww/scripts/workspaces.lua" = {
# source = ./scripts/workspaces.lua;
# executable = true;
# };
}

# programs = {
# eww = {
# enable = true;
# package = pkgs.eww-wayland;
# enableZshIntegration = true;
# enableBashIntegration = true;
# enableFishIntegration = true;
# configDir = "${config.home.homeDirectory}/.config/eww";
# };
# };
3 changes: 1 addition & 2 deletions home/features/desktop/hyprland/eww/launch_bar.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ in
## Files and cmd
FILE="$HOME/.cache/eww_launch.xyz"
# EWW="$HOME/.local/bin/eww/eww -c $HOME/.config/eww"
EWW="eww -c /home/administrator/nixos-config/home/features/desktop/hyprland/eww"
EWW="$HOME/.local/bin/eww/eww -c $HOME/.config/eww"
EWW=${EWW}
## Run eww daemon if not running already
Expand Down
56 changes: 56 additions & 0 deletions home/features/desktop/hyprland/eww/scripts/workspace.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,62 @@
{
home.file.".config/eww/scripts/workspace.sh" = {
text = ''
#!/bin/sh
workspaces() {
ws1="1"
ws2="2"
ws3="3"
ws4="4"
ws5="5"
ws6="6"
# Unoccupied
un="0"
# check if Occupied
o1=$(bspc query -D -d .occupied --names | grep "$ws1" )
o2=$(bspc query -D -d .occupied --names | grep "$ws2" )
o3=$(bspc query -D -d .occupied --names | grep "$ws3" )
o4=$(bspc query -D -d .occupied --names | grep "$ws4" )
o5=$(bspc query -D -d .occupied --names | grep "$ws5" )
o6=$(bspc query -D -d .occupied --names | grep "$ws6" )
# check if Focused
f1=$(bspc query -D -d focused --names | grep "$ws1" )
f2=$(bspc query -D -d focused --names | grep "$ws2" )
f3=$(bspc query -D -d focused --names | grep "$ws3" )
f4=$(bspc query -D -d focused --names | grep "$ws4" )
f5=$(bspc query -D -d focused --names | grep "$ws5" )
f6=$(bspc query -D -d focused --names | grep "$ws6" )
ic_1=""
ic_2=""
ic_3=""
ic_4=""
ic_5=""
ic_6=""
if [ $f1 ]; then
ic_1=""
elif [ $f2 ]; then
ic_2=""
elif [ $f3 ]; then
ic_3=""
elif [ $f4 ]; then
ic_4=""
elif [ $f5 ]; then
ic_5=""
elif [ $f6 ]; then
ic_6=""
fi
echo "(box :class \"works\" :orientation \"h\" :spacing 5 :space-evenly \"false\" (button :onclick \"bspc desktop -f $ws1\" :class \"$un$o1$f1\" \"$ic_1\") (button :onclick \"bspc desktop -f $ws2\" :class \"$un$o2$f2\" \"$ic_2\") (button :onclick \"bspc desktop -f $ws3\" :class \"$un$o3$f3\" \"$ic_3\") (button :onclick \"bspc desktop -f $ws4\" :class \"$un$o4$f4\" \"$ic_4\") (button :onclick \"bspc desktop -f $ws5\" :class \"$un$o5$f5\" \"$ic_5\") (button :onclick \"bspc desktop -f $ws6\" :class \"$un$o6$f6\" \"$ic_6\"))"
}
workspaces
bspc subscribe desktop node_transfer | while read -r _ ; do
workspaces
done
'';
executable = true;
};
Expand Down
32 changes: 31 additions & 1 deletion home/features/desktop/hyprland/eww/scripts/workspace_code.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,38 @@
}:

{
home.file.".config/eww/scripts/workspace_code.sh" = {
home.file.".config/eww/scripts/workspaces.lua" = {
text = ''
#!/usr/bin/env lua
function trim(s)
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
end
aw = io.popen("hyprctl monitors | grep active | sed 's/()/(1)/g' | sort | awk 'NR>1{print $1}' RS='(' FS=')'")
active_workspace = aw:read("*a")
aw:close()
ew = io.popen("hyprctl workspaces | grep ID | sed 's/()/(1)/g' | sort | awk 'NR>1{print $1}' RS='(' FS=')'")
existing_workspaces = ew:read("*a")
ew:close()
box = "(box :orientation \"v\" :spacing 1 :space-evenly \"true\" "
for i = 1, #existing_workspaces do
local c = existing_workspaces:sub(i,i)
if tonumber(c) == tonumber(active_workspace) then
local btn = "(button :class \"active\" :onclick \"hyprctl dispatch workspace "..c.." \" \"\")"
box = box .. btn
elseif c ~= "\n" then
local btn = "(button :class \"inactive\" :onclick \"hyprctl dispatch workspace "..c.."\" \"\")"
box = box .. btn
end
end
box = box .. ")"
print(box)
'';
executable = true;
};
Expand Down
9 changes: 9 additions & 0 deletions home/features/desktop/hyprland/eww/scripts/workspaces.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
{
home.file.".config/eww/scripts/workspaces.sh" = {
text = ''
#!/bin/sh
workspaces() {
./scripts/workspaces.lua
}
workspaces
tail -f /tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/hyprland.log | grep --line-buffered "Changed to workspace" | while read -r; do
workspaces
done
'';
executable = true;
};
Expand Down
4 changes: 2 additions & 2 deletions home/features/desktop/hyprland/eww/variables.yuck
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
(defpoll pfp :interval "1s" "./scripts/pfp.sh")
(defpoll username :interval "1s" "./scripts/user.sh")

; (defpoll br_icon :interval "1s" "./scripts/brightness.sh icon")
; (defpoll br :interval "1s" "./scripts/brightness.sh br")
(defpoll br_icon :interval "1s" "./scripts/brightness.sh icon")
(defpoll br :interval "1s" "./scripts/brightness.sh br")

(defpoll bluetooth_state :interval "1s" "./scripts/bluetooth state")
(defpoll redshift_state :interval "1s" "./scripts/redshift state")
Expand Down

0 comments on commit 6872c66

Please sign in to comment.