feat: eww workspaces

This commit is contained in:
hesam-init 2024-06-28 09:56:54 +03:30
parent 2a1ec8967b
commit dccad1e64e
12 changed files with 564 additions and 476 deletions

View file

@ -12,7 +12,7 @@ declare -A PACKAGES=(
["BASE_PACKAGES"]="inetutils v4l2loopback bind-utils zellij bat dust aria2 fzf neofetch bat zsh fish-shell brightnessctl bluez cronie git stow eza dbus seatd elogind polkit NetworkManager gnome-keyring polkit-gnome pipewire wireplumber inotify-tools xorg gnome-keyring polkit-gnome mtpfs ffmpeg libnotify" ["BASE_PACKAGES"]="inetutils v4l2loopback bind-utils zellij bat dust aria2 fzf neofetch bat zsh fish-shell brightnessctl bluez cronie git stow eza dbus seatd elogind polkit NetworkManager gnome-keyring polkit-gnome pipewire wireplumber inotify-tools xorg gnome-keyring polkit-gnome mtpfs ffmpeg libnotify"
["DEVEL_PACKAGES"]="glib pango-devel gdk-pixbuf-devel libdbusmenu-gtk3-devel glib-devel gtk+3-devel gtk-layer-shell-devel base-devel startup-notification-devel cairo-devel xcb-util-devel xcb-util-cursor-devel xcb-util-xrm-devel xcb-util-wm-devel" ["DEVEL_PACKAGES"]="glib pango-devel gdk-pixbuf-devel libdbusmenu-gtk3-devel glib-devel gtk+3-devel gtk-layer-shell-devel base-devel startup-notification-devel cairo-devel xcb-util-devel xcb-util-cursor-devel xcb-util-xrm-devel xcb-util-wm-devel"
["AMD_DRIVERS"]="opencv Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers-32bit mesa-vulkan-radeon mesa-vulkan-radeon-32bit vulkan-loader vulkan-loader-32bit libspa-vulkan libspa-vulkan-32bit amdvlk mesa-dri mesa-vaapi" ["AMD_DRIVERS"]="opencv Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers-32bit mesa-vulkan-radeon mesa-vulkan-radeon-32bit vulkan-loader vulkan-loader-32bit libspa-vulkan libspa-vulkan-32bit amdvlk mesa-dri mesa-vaapi"
["HYPRLAND_PACKAGES"]="eww nerd-fonts-symbols-ttf Waybar avizo dunst swaybg mpvpaper grim jq slurp cliphist wl-clipboard swayidle pavucontrol nemo eog pavucontrol evince xorg-server-xwayland xdg-desktop-portal-gtk xdg-desktop-portal-wlr xdg-utils qt5-x11extras qt5-wayland qt6-wayland" ["HYPRLAND_PACKAGES"]="socat eww nerd-fonts-symbols-ttf Waybar avizo dunst swaybg mpvpaper grim jq slurp cliphist wl-clipboard swayidle pavucontrol nemo eog pavucontrol evince xorg-server-xwayland xdg-desktop-portal-gtk xdg-desktop-portal-wlr xdg-utils qt5-x11extras qt5-wayland qt6-wayland"
["SYSTEM_APPS"]="alacritty octoxbps blueman wifish wpa_gui glow" ["SYSTEM_APPS"]="alacritty octoxbps blueman wifish wpa_gui glow"
) )

View file

@ -1,3 +1,13 @@
.widget {
padding: 5px 5px;
border-radius: 5px;
background-color: $surface0;
margin: 5px 2px;
color: $white0;
// border-style: solid;
// border-color: $white0;
// border-width: 2px;
}
.barwidget { .barwidget {
background-color: $base; background-color: $base;
@ -19,24 +29,30 @@
} }
.workspaces { .workspaces {
padding: 5px; @extend .widget;
* {
transition: all cubic-bezier(0.165, 0.84, 0.44, 1) 500ms;
} }
.workspaces label { .workspace {
font-size: 18; margin: 6px;
padding-right: 5px; border-radius: 4px;
padding: 2px 5px 2px 0px;
} }
.widget { .workspacething {
padding: 5px 5px; background-color: $surface2;
border-radius: 5px; }
background-color: $surface0;
margin: 5px 2px; .workspacethingactive {
color: $white0; background-color: $accent;
// border-style: solid; }
// border-color: $white0;
// border-width: 2px; .label {
// font-size: 18;
// padding-right: 5px;
// padding: 2px 5px 2px 0px;
}
} }
.clock label { .clock label {
@ -142,19 +158,5 @@
} }
.lightning { .lightning {
color: $surface0 color: $surface0;
}
.workspacething, .workspacethingactive {
transition: 500ms;
border-radius: 5;
margin: 6px;
}
.workspacething {
background-color: $surface2;
}
.workspacethingactive {
background-color: $accent;
} }

View file

@ -14,6 +14,7 @@
:wm-ignore false :wm-ignore false
(barstruct)) (barstruct))
(defwidget barstruct [] (defwidget barstruct []
(box (box
:orientation "h" :orientation "h"
@ -66,25 +67,57 @@
:hexpand false :hexpand false
(stray) (stray)
(sliders) (sliders)
(battery)
(clock) (clock)
; (battery)
)) ))
(defvar show_no_of_windows false)
(deflisten workspacesdata :initial "[]" "./scripts/workspaces get-all-workspaces")
(defpoll current_workspace :initial "0" :interval "50ms" "./scripts/workspaces get-active-workspace")
(defwidget workspaces [] (defwidget workspaces []
(eventbox (eventbox
:cursor "pointer" :cursor "pointer"
:onscroll "./scripts/workspaces change {} ${current_workspace}"
:onhover "eww update show_no_of_windows=true"
:onhoverlost "eww update show_no_of_windows=false"
(box (box
:class "workspaces widget" :class "workspaces"
:orientation "v"
:space-evenly false :space-evenly false
(for workspace in {workspacejson} :orientation "v"
(for workspace in {workspacesdata}
(button (button
:onclick "swaymsg -t command workspace number ${workspace.name}" :onclick "hyprctl dispatch workspace ${workspace.id}"
(box (box
:hexpand false :hexpand false
:width 10 :width 10
:height { workspace.focused ? 60 : !workspace.empty ? 40 : 30} :height { workspace.id == current_workspace ? 60 : 35 }
:class { workspace.focused ? "workspacethingactive" : "workspacething"})))))) :class "workspace ${workspace.id == current_workspace ? "workspacethingactive" : "workspacething"}"
)
)
)
)
)
)
; (defwidget workspaces []
; (eventbox
; :cursor "pointer"
; (box
; :class "workspaces widget"
; :orientation "v"
; :space-evenly false
; (for workspace in {workspacejson}
; (button
; :onclick "swaymsg -t command workspace number ${workspace.name}"
; (box
; :hexpand false
; :width 10
; :height { workspace.focused ? 60 : !workspace.empty ? 40 : 30}
; :class { workspace.focused ? "workspacethingactive" : "workspacething"}))))))
(defwidget home [] (defwidget home []
(box (box

View file

@ -1 +1 @@
@import "./themes/oxocarbon.scss" @import "./themes/oxocarbon.scss";

View file

@ -5,7 +5,6 @@
:width 10 :width 10
:height 54 :height 54
:anchor "bottom center") :anchor "bottom center")
:stacking "overlay"
:monitor 0 :monitor 0
(dockstruct)) (dockstruct))

View file

@ -1,11 +1,11 @@
@import './colors.scss'; @import "./colors.scss";
@import './bar/bar.scss'; @import "./bar/bar.scss";
// @import './bottom_bar/bar.scss'; // @import "./bottom_bar/bar.scss";
@import './control_panel/control_panel.scss'; @import "./control_panel/control_panel.scss";
@import './dashboard/dashboard.scss'; @import "./dashboard/dashboard.scss";
@import './dock/dock.scss'; @import "./dock/dock.scss";
@import './desktop/desktop.scss'; @import "./desktop/desktop.scss";
@import './notification/notification.scss'; @import "./notification/notification.scss";
* { * {
all: unset; all: unset;
@ -27,6 +27,7 @@ tooltip {
scale { scale {
all: unset; all: unset;
trough { trough {
background-color: $surface2; background-color: $surface2;
border-radius: 24px; border-radius: 24px;
@ -53,11 +54,11 @@ button {
transition-duration: 0.5s; transition-duration: 0.5s;
border-radius: 5px; border-radius: 5px;
} }
button:hover { button:hover {
background-color: $surface2; background-color: $surface2;
} }
calendar { calendar {
all: unset; all: unset;
background-color: $surface0; background-color: $surface0;

View file

@ -77,14 +77,13 @@ elif [ "$1" = "control" ]; then
elif [ "$1" = "dashboard" ]; then elif [ "$1" = "dashboard" ]; then
dashboard dashboard
elif [ "$1" = "colourpick" ]; then elif [ "$1" = "colourpick" ]; then
COLOUR=$(grim -g "$(slurp -p)" -t ppm - | convert - -format '%[pixel:p{0,0}]' txt:- | awk -F ' ' 'NR==2 {print $3}') hyprpicker -a
wl-copy "$COLOUR" notify-send -a colourpicker -i ~/.config/eww/image/eyedropper.png -t 3000 "Colour copied to clipboard"
notify-send -a colourpicker -i ~/.config/eww/carbonmonoxide/image/eyedropper.png -t 3000 "$COLOUR" "Colour copied to clipboard"
elif [ "$1" = "scrop" ]; then elif [ "$1" = "scrop" ]; then
# control # control
# sleep 0.5 # sleep 0.5
grim -g "$(slurp)" - | wl-copy grim -g "$(slurp)" - | wl-copy
notify-send -a screenshot -i ~/.config/eww/carbonmonoxide/image/screenshot.png -t 3000 "Screenshot Taken" "Image copied to clipboard" notify-send -a screenshot -i ~/.config/eww/image/screenshot.png -t 3000 "Screenshot Taken" "Image copied to clipboard"
elif [ "$1" = "sscreen" ]; then elif [ "$1" = "sscreen" ]; then
# control # control
grim - | wl-copy grim - | wl-copy

View file

@ -0,0 +1,54 @@
#!/bin/bash
SOCKET="/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock"
spaces() {
local workspace_windows=$(hyprctl workspaces -j | jq 'map({key: .id | tostring, value: .windows}) | from_entries')
seq 1 5 | jq --argjson windows "$workspace_windows" --slurp -Mc 'map(tostring) | map({id: ., windows: ($windows[.]//0)})'
}
clamp() {
python -c "print(max($1, min($3, $2)))"
}
get_workspaces() {
spaces
socat -u UNIX-CONNECT:"$SOCKET" - | while read -r; do
spaces
done
}
get_active_workspace() {
hyprctl monitors -j | jq '.[] | select(.focused) | .activeWorkspace.id'
socat -u UNIX-CONNECT:"$SOCKET" - | stdbuf -o0 awk -F '>>|,' '/^workspace>>/ {print $2} /^focusedmon>>/ {print $3}'
}
change_workspace() {
local direction=$1 current=$2 target
if [[ "$direction" == "down" ]]; then
target=$(clamp 1 9 $((current + 1)))
elif [[ "$direction" == "up" ]]; then
target=$(clamp 1 9 $((current - 1)))
else
echo "Invalid direction" >&2
return 1
fi
echo "Jumping to $target"
hyprctl dispatch workspace "$target"
}
main() {
case $1 in
get-all-workspaces) get_workspaces ;;
get-active-workspace) get_active_workspace ;;
change) change_workspace "$2" "$3" ;;
*)
echo "Usage: $0 {gw|ga|c <direction> <current>}" >&2
exit 1
;;
esac
}
main "$@"