This commit is contained in:
Nickolaj Jepsen 2024-08-28 16:08:36 +00:00
parent c69ed34507
commit d68c699a7a
18 changed files with 644 additions and 203 deletions

View file

@ -0,0 +1,112 @@
$anim: .2s cubic-bezier(0.4, 0.0, 0.2, 1);
$anim-slow: .4s cubic-bezier(0.4, 0.0, 0.2, 1);
$background: #1C1C1C;
$background-alt: #2b2b2b;
$foreground: #C5C5C5;
$accent: #CF6A4C;
* {
all: unset; //Unsets everything so you can style everything from scratch
font-family: Hack Nerd Regular;
color: $foreground;
font-size: 16px
}
.bar {
background-color: $background;
border-bottom: 2px solid $accent;
padding: 0 12px;
}
.workspace-entry {
border: 2px solid $foreground;
border-radius: 50%;
min-width: 10px;
min-height: 10px;
margin: 5px 5px;
transition: background-color $anim, opacity $anim, border $anim;
opacity: .2;
&.has-windows {
opacity: 1;
}
&.active {
opacity: 1;
background-color: $foreground;
border-color: $foreground
}
}
.datetime {
.time {
font-weight: bold;
margin-right: 15px;
}
}
.side-bar {
padding: 0 5px;
opacity: .4;
background-color: transparent;
transition: background-color $anim-slow, opacity $anim-slow, border $anim-slow;
border-bottom: 2px solid transparent;
&.active {
opacity: 1;
background-color: $background;
border-bottom: 2px solid $accent;
}
.workspace-entry {
margin: 5px 2px;
}
&.left-bar {
&.active {
border-left: 2px solid $accent;
}
border-left: 2px solid transparent;
border-bottom-left-radius: 12px;
}
&.right-bar {
&.active {
border-right: 2px solid $accent;
}
border-right: 2px solid transparent;
border-bottom-right-radius: 12px;
}
}
.scale {
trough {
background-color: $background-alt;
border-radius: 10px;
min-height: 5px;
min-width: 80px;
highlight {
background-color: $accent;
border-radius: 10px;
}
}
}
.music {
.music-control {
font-size: 10px;
}
.music-timer {
font-size: 12px;
}
.scale {
margin: 0 10px;
}
padding: 0 15px;
margin: 0 15px;
border-right: 2px solid #CF6A4C;
border-left: 2px solid #CF6A4C;
}

View file

@ -0,0 +1,98 @@
; WINDOWS
(defwindow primary
:monitor 0
:stacking "fg"
:exclusive true
:geometry (geometry :x "0%"
:y "0%"
:width "100%"
:height "20px"
:anchor "top center")
(primary_bar))
(defwindow left
:monitor 1
:stacking "fg"
:exclusive false
:geometry (geometry :x "0%"
:y "0%"
:width "100%"
:height "20px"
:anchor "top center")
(left_bar))
(defwindow right
:monitor 2
:stacking "fg"
:exclusive false
:geometry (geometry :x "0%"
:y "0%"
:width "100%"
:height "20px"
:anchor "top center")
(right_bar))
; VARIABLES
(defpoll battery :interval "1s" "scripts/battery-level")
(deflisten workspaces :initial "{}" "bash ~/.config/eww/scripts/get-workspaces")
(deflisten current_workspace :initial "1" "bash ~/.config/eww/scripts/get-active-workspace")
(deflisten current_monitor :initial "DP-1" "bash ~/.config/eww/scripts/get-active-monitor")
(deflisten window :initial "..." "sh ~/.config/eww/scripts/get-window-title")
(deflisten volume :initial "{}" "sh ~/.config/eww/scripts/volume")
(defpoll time :interval "10s" "date '+%H:%M'")
(defpoll date :interval "10s" "date '+%Y-%m-%d'")
; BARS
(defwidget primary_bar []
(box :class "bar primary-bar ${current_monitor == 'DP-1' ? 'active' : ''}"
(box :class "primary-left" :space-evenly false :halign "start"
(datetime)
(workspaces :ids "[\"1\",\"2\",\"3\",\"4\",\"5\"]"))
(label :halign "center" :text "${window}")
(controls :halign "end")))
(defwidget left_bar []
(box :class "bar side-bar left-bar ${current_monitor == 'HDMI-A-1' ? 'active' : ''}" :halign "end"
(workspaces :ids "[\"6\",\"7\"]")))
(defwidget right_bar []
(box :class "bar side-bar right-bar ${current_monitor == 'DP-3' ? 'active' : ''}" :halign "start"
(workspaces :ids "[\"8\",\"9\"]")))
; WIDGETS
(defwidget workspaces [ids]
(box :space-evenly false :spacing 10 :class "workspaces"
(for id in ids
(eventbox :onclick "hyprctl dispatch workspace ${id}"
(box :class "workspace-entry ${current_workspace == id ? 'active' : 'inactive'} ${(workspaces?.[id]?.windows?:0) >= 1 ? 'has-windows' : 'no-windows'}")))))
(defwidget datetime []
(box :space-evenly false :class "datetime" :spacing 10
(label :class "date" :text "${date}")
(label :class "time" :text "${time}")))
(defwidget controls []
(box :space-evenly false :class "controls" :halign "end"
(metric :icon {volume?.["icon"]?:""}
:value {volume?.["audio"] != "1" ? 0 : volume?.["percent"]}
:onchange "~/.config/eww/scripts/volume setvol SINK {}"
:onclick "~/.config/eww/scripts/volume mute SINK")))
(defwidget metric [value ?icon ?onchange ?onclick]
(box :space-evenly false :class "metric" :spacing 10 :halign "end" :visible {(value?:-1) != -1}
(scale :class "scale"
:min 0
:max 101
:flipped true
:orientation 'h'
:active {(onchange?:"") != ""}
:onchange {onchange}
:value {value?:0})
(eventbox :active {(onclick?:"") != ""} :onclick {onclick}
(box
(label :width 1 :visible {icon != ""} :class "icon" :text {icon})
(label :width 35 :class "label" :text "${value}%")))))

View file

@ -0,0 +1,2 @@
#!/bin/sh
cat /sys/class/power_supply/BAT0/capacity

View file

@ -0,0 +1,2 @@
#!/bin/sh
cat /sys/class/power_supply/BAT0/status

View file

@ -0,0 +1,21 @@
#! /bin/bash
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,6 @@
#!/usr/bin/env bash
hyprctl monitors -j | jq '.[] | select(.focused) | .name'
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - |
stdbuf -o0 awk -F '>>|,' -e '/^focusedmon>>/ {print $2}'

View file

@ -0,0 +1,6 @@
#!/usr/bin/env bash
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,3 @@
#!/bin/sh
hyprctl activewindow -j | jq --raw-output .title | sed 's/\(.\{120\}\).*/\1.../'
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | stdbuf -o0 awk -F '>>|,' '/^activewindow>>/{print $3}' | sed 's/\(.\{120\}\).*/\1.../'

View file

@ -0,0 +1,10 @@
#!/bin/bash
spaces (){
hyprctl workspaces -j | jq 'map({key: .id | tostring, value: .}) | from_entries' -Mc
}
spaces
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | while read -r line; do
spaces
done

View file

@ -0,0 +1,95 @@
#!/usr/bin/env bash
# FROM HERE: https://github.com/end-4/dots-hyprland/blob/6c09531bc2d168e79b2a76f0174b297a3b66b9b0/.config/eww/scripts/volume
cd ~/.config/eww
volicons=("" "󰖀" "󰕾")
XDG_CACHE_HOME="$HOME/.cache"
lock=0
vol() {
wpctl get-volume @DEFAULT_AUDIO_$1@ | awk '{print int($2*100)}'
}
ismuted() {
wpctl get-volume @DEFAULT_AUDIO_"$1"@ | rg -i muted
echo $?
}
setvol() {
wpctl set-volume @DEFAULT_AUDIO_"$1"@ "$(awk -v n="$2" 'BEGIN{print (n / 100)}')"
}
setmute() {
wpctl set-mute @DEFAULT_AUDIO_"$1"@ toggle
}
if [ "$1" = "--once" ]; then
lvl=$(awk -v n="$(vol "SINK")" 'BEGIN{print int(n/34)}')
ismuted=$(ismuted "SINK")
if [ "$ismuted" = 1 ]; then
icon="${volicons[$lvl]}"
else
icon="󰝟"
fi
audio=1
if [ "$(wpctl status | grep 'MUTED')" == "" ]; then
audio=1
else
audio=0
fi
echo '{"icon":"'"$icon"'","audio":"'"$audio"'","percent":"'"$(vol "SINK")"'","microphone":"'"$(vol "SOURCE")"'"}'
exit 0
fi
if [ "$1" = "mute" ]; then
if [ "$2" != "SOURCE" ] && [ "$2" != "SINK" ]; then
echo "Can only mute SINK or SOURCE"; exit 1
fi
setmute "$2"
elif [ "$1" = "setvol" ]; then
if [ "$2" != "SOURCE" ] && [ "$2" != "SINK" ]; then
echo "Can only set volume for SINK or SOURCE"; exit 1
elif [ "$3" -lt 1 ] || [ "$3" -gt 100 ]; then
echo "Volume must be between 1 and 100"; exit 1
fi
setvol "$2" "$3"
else
# initial values
lvl=$(awk -v n="$(vol "SINK")" 'BEGIN{print int(n/34)}')
ismuted=$(ismuted "SINK")
if [ "$ismuted" = 1 ]; then
icon="${volicons[$lvl]}"
else
icon="󰝟"
fi
audio=1
if [ "$(wpctl status | grep 'MUTED')" == "" ]; then
audio=1
else
audio=0
fi
echo '{"icon":"'"$icon"'","audio":"'"$audio"'","percent":"'"$(vol "SINK")"'","microphone":"'"$(vol "SOURCE")"'"}'
# event loop
pactl subscribe | rg --line-buffered "on sink" | while read -r _; do
lvl=$(awk -v n="$(vol "SINK")" 'BEGIN{print int(n/34)}')
ismuted=$(ismuted "SINK")
if [ "$ismuted" = 1 ]; then
icon="${volicons[$lvl]}"
else
icon="󰝟"
fi
audio=1
if [ "$(wpctl status | grep 'MUTED')" == "" ]; then
audio=1
else
audio=0
fi
echo '{"icon":"'"$icon"'","audio":"'"$audio"'","percent":"'"$(vol "SINK")"'","microphone":"'"$(vol "SOURCE")"'"}'
done
fi

View file

@ -0,0 +1,15 @@
{
pkgs,
config,
...
}: {
home.file."${config.xdg.configHome}/eww" = {
source = ./config;
recursive = true;
};
home.packages = with pkgs; [
socat
eww
];
}