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"
["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"
["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"
)

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

View file

@ -14,6 +14,7 @@
:wm-ignore false
(barstruct))
(defwidget barstruct []
(box
:orientation "h"
@ -66,25 +67,57 @@
:hexpand false
(stray)
(sliders)
(battery)
(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 []
(eventbox
: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
:class "workspaces widget"
:orientation "v"
:class "workspaces"
:space-evenly false
(for workspace in {workspacejson}
:orientation "v"
(for workspace in {workspacesdata}
(button
:onclick "swaymsg -t command workspace number ${workspace.name}"
:onclick "hyprctl dispatch workspace ${workspace.id}"
(box
:hexpand false
:width 10
:height { workspace.focused ? 60 : !workspace.empty ? 40 : 30}
:class { workspace.focused ? "workspacethingactive" : "workspacething"}))))))
:height { workspace.id == current_workspace ? 60 : 35 }
: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 []
(box

View file

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

View file

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

View file

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

View file

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