treewide: preliminary Wayland!

This commit is contained in:
LavaDesu 2024-01-17 15:33:46 +07:00
parent 67798937bb
commit 2602b8bc1c
Signed by: cilly
GPG key ID: 6500251E087653C9
11 changed files with 197 additions and 11 deletions

View file

@ -50,6 +50,7 @@ in {
./user/direnv.nix
./user/dunst.nix
./user/eww.nix
./user/eww-wayland.nix
./user/git.nix
./user/gpg.nix
./user/kitty.nix
@ -63,6 +64,7 @@ in {
./user/picom.nix
./user/polybar.nix
./user/rofi.nix
./user/rofi-wayland.nix
./user/sessionVariables.nix
./user/spicetify.nix
./user/sxhkd.nix

View file

@ -3,7 +3,7 @@
enable = true;
settings = {
default_session = {
command = "${pkgs.greetd.tuigreet}/bin/tuigreet --remember --asterisks --time --cmd 'zsh -c \"source $HOME/.config/zsh/.zshrc && startx\"'";
command = "${pkgs.greetd.tuigreet}/bin/tuigreet --remember --asterisks --time --cmd 'zsh -c \"source $HOME/.config/zsh/.zshrc && Hyprland > $XDG_RUNTIME_DIR/Hyprland.out\"'";
user = "greeter";
};
};

View file

@ -0,0 +1,7 @@
{ pkgs, ... }: {
home.packages = with pkgs; [ socat ];
programs.eww = {
enable = true;
configDir = ../../res/eww-wayland;
};
}

View file

@ -0,0 +1,8 @@
{ config, pkgs, ... }: {
programs.rofi = {
enable = true;
package = pkgs.rofi-wayland;
theme = "theme";
};
xdg.configFile."rofi/theme.rasi".source = ../../res/theme.rasi;
}

View file

@ -1,5 +1,5 @@
self: super: {
eww = super.eww.overrideAttrs (old: rec {
eww = (super.eww.override { withWayland = true; }).overrideAttrs (old: rec {
patches = old.patches ++ [
# Use normal scroll events instead of smooth scroll ( due to https://bugzilla.gnome.org/show_bug.cgi?id=675959 )
./patches/eww.patch

72
res/eww-wayland/eww.scss Normal file
View file

@ -0,0 +1,72 @@
$background: #1a1b26;
$accent: #9d7cd8;
$foreground: #c0caf5;
* {
all: unset;
}
window {
background: transparent;
}
.bar {
margin: 5px 20px 0px 20px;
}
.widget {
background: $background;
color: $foreground;
font-family: "Noto Sans";
font-weight: 600;
font-size: 15px;
padding: 5px 15px;
border-radius: 50px;
}
.time {
.base {
font-weight: 700;
}
.extension {
font-weight: 500;
color: rgba($foreground, .7);
}
}
.workspaces {
padding: 5px 10px;
font-size: 22px;
button {
padding: 0px 2px;
}
.empty, .occupied {
color: $accent;
}
}
.widget.line-workspaces {
color: transparent;
padding: 0;
border-radius: 0;
font-size: 0;
button {
padding: 0 13px;
}
.empty {
background-color: $background;
}
.occupied {
background-color: $accent;
}
.focused {
background-color: $foreground;
}
}

67
res/eww-wayland/eww.yuck Normal file
View file

@ -0,0 +1,67 @@
(defwindow mainbar :monitor 0
:geometry (geometry :x "0%"
:y "0%"
:width "100%"
:height "30px"
:anchor "top center")
:stacking "fg"
:exclusive false
:focusable false
(bar))
(defvar time-extended false) ; for :run-while property of below variable
; when this turns true, the polling starts and
; var gets updated with given interval
(defpoll ptime :interval "1s"
:run-while !time-extended
`date +%H:%M`)
(defpoll petimea :interval "1s"
:run-while time-extended
`date "+%A, %d %B %Y "`)
(defpoll petimeb :interval "1s"
:run-while time-extended
`date "+:%S"`)
(deflisten ltitle "./scripts/title.sh")
(deflisten lworkspaces :initial "[]" "./scripts/workspaces.sh")
(deflisten lcurrent_workspace :initial "1" "./scripts/active-workspace.sh")
(defwidget bar []
(eventbox :onscroll "./scripts/scroll.sh {}"
(centerbox :orientation "h"
:class "bar"
(workspaces)
(title)
(time))))
(defwidget workspaces []
(box :class "widget workspaces"
:halign "start"
:valign "center"
:vexpand true
:hexpand true
(for workspace in lworkspaces
(eventbox :cursor "hand"
(button :class "${workspace.id == lcurrent_workspace ? "focused" : (workspace.windows > 0 ? "occupied" : "empty")}"
:onclick "hyprctl dispatch workspace ${workspace.id}"
"${workspace.id == lcurrent_workspace ? "" : (workspace.windows > 0 ? "" : "")}")))))
(defwidget title []
(literal :content ltitle))
(defwidget time_extension [text]
(label :text text
:class "extension"))
(defwidget time []
(button :onclick `eww update time-extended=${time-extended ? "false" : "true"}`
(box :orientation "horizontal"
:space-evenly false
:halign "end"
:class "widget time"
(time_extension :text {time-extended ? petimea : ""})
(label :text ptime
:class "base")
(time_extension :text {time-extended ? petimeb : ""}))))

View file

@ -0,0 +1,6 @@
#!/usr/bin/env sh
hyprctl monitors -j | jq '.[] | select(.focused) | .activeWorkspace.id'
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - |
stdbuf -o0 awk -F '>>|,' -e '/^workspace>>/ {print $2}' -e '/^focusedmon>>/ {print $3}'

View file

@ -0,0 +1,17 @@
#!/usr/bin/env sh
out () {
if [ -z "$1" ]; then
echo ""
else
echo "(box :class \"widget title\" :halign \"center\" :valign \"center\" :vexpand true :hexpand true (label :text \"$1\"))"
fi
}
init=$(hyprctl activewindow -j | jq --raw-output .title)
out "$init"
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | stdbuf -o0 awk -F '>>|,' '/^activewindow>>/{print $3}' | while read -r line ; do
trunc=$(echo $line | cut -c-85)
out "$trunc"
done

View file

@ -0,0 +1,11 @@
#!/usr/bin/env sh
spaces (){
WORKSPACE_WINDOWS=$(hyprctl workspaces -j | jq 'map({key: .id | tostring, value: .windows}) | from_entries')
seq 1 10 | jq --argjson windows "${WORKSPACE_WINDOWS}" --slurp -Mc 'map(tostring) | map({id: ., windows: ($windows[.]//0)})'
}
spaces
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | while read -r line; do
spaces
done

View file

@ -2,7 +2,7 @@
programs.zsh.enable = true;
users.users.rin = {
isNormalUser = true;
extraGroups = [ "adbusers" "audio" "corectrl" "libvirtd" "video" "wheel" ];
extraGroups = [ "adbusers" "audio" "corectrl" "libvirtd" "networkmanager" "video" "wheel" ];
shell = pkgs.zsh;
uid = 1001;
passwordFile = config.age.secrets.passwd.path;
@ -33,18 +33,14 @@
kitty
mpv
obs
rofi
spicetify
rofi-wayland
dunst
eww
picom
xorg
sxhkd
bspwm
eww-wayland
];
services.mpris-proxy.enable = true;
home.file.".local/bin/ipc-bridge.exe".source = builtins.fetchurl {
url = "https://github.com/0e4ef622/wine-discord-ipc-bridge/releases/download/v0.0.1/winediscordipcbridge.exe";
sha256 = "1swn9spxpq6blm74kjmfz4ipq6a8qjzccvb2msb25pf5b1z7jnns";