Refactor codebase to use nix modules

This commit is contained in:
Julia Lange 2024-04-14 05:40:02 -07:00
parent a4735423b4
commit ffada2703c
114 changed files with 1018 additions and 744 deletions

View file

@ -0,0 +1,11 @@
.content-box {
border: 4px solid yellow;
border-radius: 50px;
background-color: rgba(255,255,255,10);
margin: 2px;
box-shadow: 0 0 0 3px white;
}
.switch {
background: transparent;
}

View file

@ -0,0 +1 @@
(include "modules/switch.yuck")

View file

@ -0,0 +1,40 @@
(include "./widgets/components/hyprwindow.yuck")
(include "./widgets/components/hyprworkspaces.yuck")
(include "./widgets/components/internet.yuck")
(include "./widgets/components/japanesedate.yuck")
(include "./widgets/components/japaneseaudio.yuck")
(defwidget bar []
(centerbox :orientation "horizontal"
:style "padding: 0px 8px"
(box :halign "start"
:spacing 18
:space-evenly false
(hyprworkspaces)
(hyprwindow)
)
""
(box :halign "end"
:spacing 18
:space-evenly false
(eventbox :onhover "eww open preview"
:onhoverlost "eww close preview"
barplayer
)
(internet)
(japaneseaudio)
(japanesedate)
(label :style "color: #FAE3B0"
:text bartime
)
)
)
)
(defpoll bartime :interval "10s"
"date '+%H:%M'"
)
(deflisten barplayer :initial ""
"playerctl --follow metadata --format '{{ artist }} - {{ title }}' || true"
)

View file

@ -0,0 +1,5 @@
(defwidget hyprwindow []
(label :text "${hyprwindow_listener}")
)
(deflisten hyprwindow_listener :initial "" "bash $XDG_CONFIG_HOME/eww/scripts/get-window-title")

View file

@ -0,0 +1,17 @@
(defwidget hyprworkspaces []
(eventbox :onscroll "bash ~/.config/eww/scripts/change-active-workspace {} ${current_workspace}" :class "workspaces-widget"
(box :space-evenly false
:spacing 5
(for workspace in workspaces
(eventbox :onclick "hyprctl dispatch workspace ${workspace.id}"
(box :class "workspace-entry ${workspace.id == current_workspace ? "current" : ""} ${workspace.windows > 0 ? "occupied" : "empty"}"
(label :text "${workspace.id}")
)
)
)
)
)
)
(deflisten workspaces :initial "[]" "bash $XDG_CONFIG_HOME/eww/scripts/get-workspaces")
(deflisten current_workspace :initial "1" "bash $XDG_CONFIG_HOME/eww/scripts/get-active-workspace")

View file

@ -0,0 +1,8 @@
(defwidget internet []
(box :spacing 0 :space-evenly false :style "color: #f5c2e7"
network
)
)
(defpoll network :interval "30s"
"iwgetid -r")

View file

@ -0,0 +1,11 @@
(defwidget japaneseaudio []
(eventbox :onscroll "bash -c 'if [ '{}' = 'up' ]; then pamixer -i 5; else pamixer -d 5; fi'"
(box :spacing 0 :space-evenly false :style "color: #96CDFB"
volume
"音"
)
)
)
(defpoll volume :interval "1s"
"pamixer --get-volume")

View file

@ -0,0 +1,9 @@
(defwidget japanesebattery []
(box :spacing 0 :space-evenly false :style "color: #FAB387"
power
"電"
)
)
(defpoll power :interval "1m"
"cat /sys/class/power_supply/BAT1/capacity")

View file

@ -0,0 +1,9 @@
(defwidget japanesedate []
(label :style "color: #DDB6F2"
:text japanesedate_time
)
)
(defpoll japanesedate_time :interval "100s"
"bash $XDG_CONFIG_HOME/eww/scripts/japanesedate"
)

View file

@ -0,0 +1,15 @@
(defwidget powerbar []
(box
:orientation "vertical"
:spacing 8
:space-evenly false
:style "color: #FAB387"
(progress
:orientation "v"
:value {100 - power})
"電"
)
)
(defpoll power :interval "1m"
"cat /sys/class/power_supply/BAT1/capacity")

View file

@ -0,0 +1,15 @@
(defwindow switch
:monitor 1
:stacking "fg"
:focusable false
:geometry (geometry :y "60%"
:width "500px"
:height "110px"
:anchor "top center")
(border
"Example contenting")
)
(defwidget border []
(box :class "content-box"
(children)))

View file

@ -0,0 +1,21 @@
#!/bin/sh
function clamp {
min=$1
max=$2
val=$3
python -c "print(max($min, min($val, $max)))"
}
direction=$1
current=$2
if test "$direction" = "down"
then
target=$(clamp 1 10 $(($current+1)))
echo "jumping to $target"
hyprctl dispatch workspace $target
elif test "$direction" = "up"
then
target=$(clamp 1 10 $(($current-1)))
echo "jumping to $target"
hyprctl dispatch workspace $target
fi

View file

@ -0,0 +1,3 @@
#!/bin/sh
hyprctl monitors -j | jq --raw-output .[0].activeWorkspace.id
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | stdbuf -o0 grep '^workspace>>' | stdbuf -o0 awk -F '>>|,' '{print $2}'

View file

@ -0,0 +1,3 @@
#!/bin/sh
hyprctl activewindow -j | jq --raw-output .title
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | stdbuf -o0 grep '^activewindow>>' | stdbuf -o0 awk -F '>>|,' '{print $3}'

View file

@ -0,0 +1,11 @@
#!/bin/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

@ -0,0 +1,31 @@
#!/bin/sh
readarray -t dateparts <<<"$(date "+%0m月%0d日%n%u")"
echo -n "${dateparts[0]}["
case ${dateparts[1]} in
1)
echo -n "月"
;;
2)
echo -n "火"
;;
3)
echo -n "水"
;;
4)
echo -n "木"
;;
5)
echo -n "金"
;;
6)
echo -n "土"
;;
7)
echo -n "日"
;;
esac
echo "]"

View file

@ -0,0 +1,3 @@
#!/bin/sh
playerctl --follow metadata mpris:artUrl | stdbuf -o0 cut -c 8-

View file

@ -0,0 +1,13 @@
{ config, pkgs, lib, ... }:
{
options.eww = {
enable = lib.mkEnableOption "Enables eww";
};
config = lib.mkIf config.eww.enable {
programs.eww.enable = true;
programs.eww.package = pkgs.eww-wayland;
programs.eww.configDir = ./config;
};
}