sway on nvidia + ironbar

This commit is contained in:
atagen 2023-08-10 14:50:31 +10:00
parent 362d12714c
commit 481e682fbf
16 changed files with 830 additions and 655 deletions

View file

@ -5,15 +5,11 @@
...
}: let
dependencies = with pkgs; [
config.wayland.windowManager.hyprland.package
cfg.package
bash
bc
blueberry
bluez
coreutils
dbus
dunst
findutils
gawk
gnome.gnome-control-center
@ -23,7 +19,6 @@
jaq
light
networkmanager
pavucontrol
playerctl
procps
pulseaudio
@ -35,7 +30,6 @@
wget
wireplumber
wlogout
fuzzel
swaynotificationcenter
];
@ -49,10 +43,10 @@
done
'';
cfg = config.programs.eww-hyprland;
cfg = config.programs.eww-custom;
in {
options.programs.eww-hyprland = {
enable = lib.mkEnableOption "eww Hyprland config";
options.programs.eww-custom = {
enable = lib.mkEnableOption "eww config";
package = lib.mkOption {
type = with lib.types; nullOr package;
@ -63,7 +57,7 @@ in {
autoReload = lib.mkOption {
type = lib.types.bool;
default = false;
default = true;
defaultText = lib.literalExpression "false";
description = "Whether to restart the eww daemon and windows on change.";
};
@ -73,10 +67,8 @@ in {
default = null;
defaultText = lib.literalExpression "null";
description = ''
SCSS file with colors defined in the same way as Catppuccin colors are,
SCSS file with colors defined in the same arbitrary and stupid way as Cringepuccin colors are,
to be used by eww.
Defaults to Catppuccin Mocha.
'';
};
};

View file

@ -2,7 +2,7 @@
(box
(button
:class "module"
{current_win.title}
"${current_win.title}""
)
)
)

View file

@ -1,18 +1,7 @@
#!/usr/bin/env bash
limit=128
socat -u UNIX-CLIENT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock STDOUT |
while read line; do
if [[ "$line" == activewindow\>\>* ]]; then
windowtitle="$(echo $line | cut -d',' -f 2)"
apptitle="$(echo $line | cut -d',' -f 1 | cut -d'>' -f 3 | rev | cut -d'.' -f -1 | rev)"
combined="$windowtitle - $apptitle"
if [[ "${#combined}" -lt $limit ]]; then
echo '{"title": "'$combined'"}'
else
clipto=$((limit-${#apptitle}))
echo '{"title": "'"${windowtitle:0:$clipto} - $apptitle"'"}'
fi
fi
done
swaymsg -m -t subscribe '[ "window" ]' | while read line; do
title=$(printf $line | gojq -r ."container.name" | cut -c -$limit)
echo '{ "title": "'$title'" }'
done

View file

@ -8,17 +8,14 @@ dimmed=("#f5c2e7" "#f9e2af" "#94e2d5" "#b4befe")
empty="#313244"
# get initial focused workspace
focusedws=$(hyprctl -j monitors | jaq -r '.[] | select(.focused == true) | .activeWorkspace.id')
# whatever
# focusedws=$(swaymsg -t get_workspaces -r | )
declare -A o=([1]=0 [2]=0 [3]=0 [4]=0)
declare -A monitormap
declare -A workspaces
# set color for each workspace
status() {
if [ "${o[$1]}" -eq 1 ]; then
mon=${monitormap[${workspaces[$1]}]}
if [ "$focusedws" -eq "$1" ]; then
echo -n "#ffd292"
# echo -n "${colors[$mon]}"
@ -32,67 +29,31 @@ status() {
fi
}
# handle workspace create/destroy
workspace_event() {
o[$1]=$2
while read -r k v; do workspaces[$k]="$v"; done < <(hyprctl -j workspaces | gojq -r '.[]|"\(.id) \(.monitor)"')
}
# handle monitor (dis)connects
monitor_event() {
while read -r k v; do monitormap["$k"]=$v; done < <(hyprctl -j monitors | gojq -r '.[]|"\(.name) \(.id) "')
}
# get all apps titles in a workspace
applist() {
ws="$1"
apps=$(hyprctl -j clients | jaq -jr '.[] | select(.workspace.id == '"$ws"') | .title + "\\n"')
echo -En "${apps%"\n"}"
}
# generate the json for eww
generate() {
echo -n '['
for i in {1..4}; do
echo -n ''"$([ "$i" -eq 1 ] || echo ,)" '{ "number": "'"$i"'", "color": "'"$(status "$i")"'" }' #, "tooltip": "'$(applist "$i")'" }'
echo -n ''"$([ "$i" -eq 1 ] || echo ,)" '{ "number": "'"$i"'", "color": "'"$(status "$i")"'" }'
done
echo ']'
}
# setup
# add monitors
monitor_event
# add workspaces
while read -r k v; do workspaces[$k]="$v"; done < <(hyprctl -j workspaces | gojq -r '.[]|"\(.id) \(.monitor)"')
# check occupied workspaces
for num in "${!workspaces[@]}"; do
o[$num]=1
done
# generate initial widget
generate
# main loop
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | rg --line-buffered "workspace|mon(itor)?" | while read -r line; do
case ${line%>>*} in
"workspace")
focusedws=${line#*>>}
swaymsg -m -t subscribe '[ "workspace" ]' | jq -r '.change+" "+.current.name' | while read -r line; do
case ${line%' '*} in
"focus")
focusedws=${line#*' '}
;;
"focusedmon")
focusedws=${line#*,}
"init")
workspace_event "${line#*' '}" 1
;;
"createworkspace")
workspace_event "${line#*>>}" 1
;;
"destroyworkspace")
workspace_event "${line#*>>}" 0
;;
"monitor"*)
monitor_event
"empty")
workspace_event "${line#*' '}" 0
;;
esac
generate