hell n back

This commit is contained in:
Jet Pham 2024-03-22 23:35:56 -07:00
parent 3ee6761b45
commit cac7203033
45 changed files with 2988 additions and 177 deletions

50
modules/eww/default.nix Normal file
View file

@ -0,0 +1,50 @@
{ inputs, lib, config, pkgs, ... }:
with lib;
let
cfg = config.modules.eww;
in {
options.modules.eww = { enable = mkEnableOption "eww"; };
config = mkIf cfg.enable {
# theres no programs.eww.enable here because eww looks for files in .config
# thats why we have all the home.files
# eww package
home.packages = with pkgs; [
eww
pamixer
brightnessctl
(nerdfonts.override { fonts = [ "JetBrainsMono" ]; })
];
# configuration
home.file.".config/eww/eww.scss".source = ./eww.scss;
home.file.".config/eww/eww.yuck".source = ./eww.yuck;
# scripts
home.file.".config/eww/scripts/battery.sh" = {
source = ./scripts/battery.sh;
executable = true;
};
home.file.".config/eww/scripts/wifi.sh" = {
source = ./scripts/wifi.sh;
executable = true;
};
home.file.".config/eww/scripts/brightness.sh" = {
source = ./scripts/brightness.sh;
executable = true;
};
home.file.".config/eww/scripts/workspaces.sh" = {
source = ./scripts/workspaces.sh;
executable = true;
};
home.file.".config/eww/scripts/workspaces.lua" = {
source = ./scripts/workspaces.lua;
executable = true;
};
};
}

291
modules/eww/eww.scss Normal file
View file

@ -0,0 +1,291 @@
$base: #44465c;
$blue: #3fc6de;
$surface0: #44465c;
$surface1: #44465c;
$text: #d9e0ee;
$overlay0: #6e738d;
$red: #ec6a88;
$peach: #efb993;
$yellow: #efb993;
$mauve: #b072d1;
$green: #3fdaa4;
$mantle: #292a37;
$crust: #2e303e;
$light-gray: #9699b7;
* {
all: unset; //Unsets everything so you can style everything from scratch
font-family: "JetBrainsMono"
}
.icon {
font-family: monospace;
font-size: 1.4rem;
}
button {
transition: background-color 200ms, color 200ms;
}
.active {
color: $green;
font-size: 1.4rem;
}
.inactive {
color: $base;
font-size: 1.4rem;
}
.inactive:hover {
color: $light-gray;
}
.bar {
background-color: $mantle;
border-left: 4px dotted $red;
}
.dashboard {
background-color: $mantle;
padding: 1rem;
margin-bottom: 1rem;
}
.cal-box {
padding: 1rem 1rem .2rem;
}
.cal {
padding: 0;
border-radius: 8px;
}
.calendar_box {
padding: 1rem;
calendar:selected {
color: $blue;
}
calendar.header {
color: $blue;
font-weight: bold;
}
calendar.button {
color: $blue;
}
calendar.highlight {
color: $green;
font-weight: bold;
}
calendar:indeterminate {
color: rgba(205, 219, 249, 0.3);
}
}
.sysinfo_box {
padding: 1rem;
.iconmem {
font-size: 3rem;
color: $yellow;
}
.iconcpu {
font-size: 3rem;
color: $blue;
}
.icondisk {
font-size: 3rem;
color: $green;
}
.cpubar, .membar, .diskbar {
background-color: $crust;
}
}
.slider_box {
padding: 0 1rem;
scale {
background-color: $crust;
border-radius: 100px;
margin: 0.5rem 0;
}
scale trough {
border-radius: 100px;
}
scale highlight {
padding: 8px;
margin: 8px;
border-radius: 100px;
}
.brightness_slider highlight {
background-color: $yellow;
}
.volume_slider highlight {
background-color: $blue;
}
.micvolume_slider highlight {
background-color: $green;
}
.slider_icon {
font-size: 2rem;
padding-right: 0.75rem;
}
}
.notification_box {
}
.wifi {
font-size: 2rem;
color: $blue;
}
.clock {
font-weight: bold;
background-color: $base;
color: $text;
border-radius: 10px;
padding: 0.2rem;
margin: 0.5rem;
}
.cpubar {
color: $blue;
background-color: $surface1;
margin: 4px 0;
}
.diskbar {
color: $green;
background-color: $surface1;
margin: 4px 0;
}
.membar {
color: $yellow;
background-color: $surface1;
margin: 4px 0;
}
.iconmem, .iconcpu, .icondisk {
color: $base;
font-size: 2.5rem;
}
.date {
font-size: 1.5rem;
}
.reg-btn {
font-size: 2rem;
margin: 2px 8px;
border-radius: 10px;
}
.dashbutton {
color: $mauve;
}
.dashbutton:hover {
background-color: $base;
}
.dashbutton:active {
background-color: $mauve;
color: $mantle;
}
.powerbutton {
color: $red;
}
.powerbutton:hover {
background-color: $base;
}
.powerbutton:active {
background-color: $red;
color: $mantle;
}
.launchbutton {
background-color: $blue;
color: $mantle;
margin-top: 6px;
}
.launchbutton:hover {
background-color: $mauve;
}
.launchbutton:active {
color: $mauve;
background-color: $mantle;
}
.battery {
font-size: 1.5rem;
color: $blue;
}
// Credits AlphaTechnolog
.powermenu-box {
padding: 0 2px;
margin: 7px 7px 7px 0px;
background: inherit;
.dispatcher {
border-radius: 15px;
background: $base;
color: $red;
font-size: 14px;
padding: 0 14px 0 10px;
&:hover { background-color: $surface0; }
&:active { background-color: $surface1; }
}
}
// powermenu
.powermenu-container {
background: $crust;
color: $text;
padding: 10px;
font-size: 55px;
transition: all 200ms cubic-bezier(.1,-0.00,.0,1.49);
.btn { margin: 1rem;}
// shutdown
.shutdown-btn-box .btn {
color: $red;
border-radius: 15px;
background-color: $mantle;
&:hover { background-color: $base; }
&:active { background-color: $surface1; }
}
// reboot
.reboot-btn-box .btn {
color: $mauve;
border-radius: 15px;
background-color: $mantle;
&:hover { background-color: $base; }
&:active { background-color: $surface1; }
}
// exit
.exit-btn-box .btn {
color: $yellow;
border-radius: 15px;
background-color: $mantle;
&:hover { background-color: $base; }
&:active { background-color: $surface1; }
}
}

295
modules/eww/eww.yuck Normal file
View file

@ -0,0 +1,295 @@
(defwidget bar []
(centerbox :orientation "v" :hexpand false
(box :valign "start" :hexpand false :vexpand true :orientation "v" :space-evenly false
(launch)
(dashbutton)
(powerbutton)
)
(workspaces :halign "center" :vexpand true :hexpand false :orientation "v")
(box :valign "end" :hexpand false :vexpand true :orientation "v" :space-evenly false
(battery)
(wifi)
(mem :thickness 4 :icon "")
(cpu :thickness 4 :icon "")
(disk :thickness 4 :icon "")
(time)
)
)
)
(defpoll brightness :interval "999h" :initial 0 `brightnessctl -m | awk -F, '{print substr($4, 0, length($4)-1)}'`)
(defpoll volume :interval "999h" :initial 0 `pamixer --get-volume`)
(defpoll micvolume :interval "999h" :initial 0 `pamixer --get-volume --source 1`)
(defwidget dashboard []
(box :orientation "v"
(box :class "info_box" :orientation "v" :space-evenly false
(box :class "calendar_box"
(calendar :width 200 :class "cal")
)
(box :class "slider_box" :orientation "v" :vexpand false :hexpand false
(box :space-evenly false
(label :class "slider_icon" :text "")
(scale :min 1 :max 101 :width 315 :class "brightness_slider" :value brightness :onchange "brightnessctl set {}%" :height 10)
)
(box :space-evenly false
(label :class "slider_icon" :text "墳")
(scale :min 1 :max 101 :width 315 :class "volume_slider" :value volume :onchange "pamixer --set-volume $(echo {} | sed 's/[.].*$//')")
)
(box :space-evenly false
(label :class "slider_icon" :text "")
(scale :min 1 :max 101 :width 315 :class "micvolume_slider" :value micvolume :onchange "pamixer --set-volume $(echo {} | sed 's/[.].*$//') --source 1")
)
)
(box :class "sysinfo_box" :orientation "h" :vexpand true :spacing 15
(mem :thickness 12 :icon "")
(cpu :thickness 12 :icon "")
(disk :thickness 12 :icon "")
)
)
(box :class "notification_box"
)
)
)
;; Variables
(defvar time false)
(defvar cal false)
;; ━━━ WIDGETS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
;; ━━━ MEMORY ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
(defwidget dashbutton[]
(button :class "reg-btn dashbutton" :onclick "eww open dashboard --toggle" "舘")
)
;; ━━━ MEMORY ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
(defwidget mem [icon thickness]
(box :vexpand "false" :hexpand "false"
(circular-progress :value {EWW_RAM.used_mem_perc}
:class "membar"
:thickness {thickness}
:start-at 75
(label :class "iconmem" :text {icon})
)
)
)
;; ━━━ CPU ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
(defwidget cpu [icon thickness]
(box :vexpand "false" :hexpand "false"
(circular-progress :value {EWW_CPU.avg}
:class "cpubar"
:thickness {thickness}
:start-at 75
(label :class "iconcpu" :text {icon})
)
)
)
;; ━━━ DISK ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
(defwidget disk [icon thickness]
(box :vexpand "false" :hexpand "false"
(circular-progress :value {EWW_DISK["/"].used_perc}
:class "diskbar"
:thickness {thickness}
:start-at 75
(label :class "icondisk" :text {icon})
)
)
)
;; ━━━ WIFI ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
(defvar wifi "{}")
(defpoll wifi :interval "30s" "./scripts/wifi.sh")
(defwidget wifi []
(box :vexpand false :hexpand false :orientation "v"
(label :text {wifi.icon}
:limit-width 10
:tooltip {wifi.status}
:class "wifi"
)
)
)
;; ━━━ BATTERY ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
(defvar battery "{}")
(defpoll battery :interval "60s" "./scripts/battery.sh")
(defwidget battery []
(label :text {battery.icon}
:limit-width 10
:tooltip "${battery.status}: ${battery.percent}"
:class "battery"
)
)
;; ━━━ VOLUME ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
(defvar volume-level 50)
(defvar volume-muted false)
(defwindow volume
:monitor 0
:geometry (geometry :y "100px" :x "0px" :width "250px" :height "200px" :anchor "center bottom")
:windowtype "dock"
:wm-ignore true
:stacking "fg"
(box :class "volume-window"
:orientation "v"
:space-evenly "false"
(box :class "volume-widget"
:orientation "h"
:space-evenly false
:spacing 10
(label :text {volume-muted ? "" :
volume-level == 0 ? "" :
volume-level < 32 ? "" :
volume-level < 65 ? "" :
""}
:class 'volume-icon ${volume-muted ? "volume-icon-muted" : ""}'
)
(scale :class 'volume-slider ${volume-muted ? "volume-slider-muted" : ""}'
:hexpand "true"
:min 0
:max 100
:height 8
:marks true
:value volume-level
:onchange "pamixer --set-volume {}"))))
;; ━━━ TIME ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
(defpoll hour :interval "10s" "date +%H")
(defpoll minute :interval "10s" "date +%M")
(defpoll dateVar :interval "600s" "date '+%A %d.%m.%y'")
(defwidget time []
(eventbox :cursor "hand" :hexpand false :vexpand false
:tooltip "${dateVar}"
(box :orientation "v" :hexpand false :vexpand false :space-evenly false :class "clock"
(button :class "date"
:onclick "" "${hour}")
(button :class "date"
:onclick "" "${minute}")
)
)
)
(defvar bright-level 50)
(defvar bright-muted false)
(defwindow brightness
:monitor 0
:geometry (geometry :y "-60px" :x "60px" :width "300px" :height "150px" :anchor "bottom left")
:wm-ignore true
:stacking "fg"
(box :class "volume-window"
:orientation "v"
:space-evenly "false"
(box :class "volume-widget"
:orientation "h"
:space-evenly false
:spacing 10
(label :text ""
:class 'volume-icon'
)
(scale :class 'volume-slider'
:hexpand "true"
:min 0
:max 100
:height 8
:marks true
:value bright-level
:onchange "brightnessctl set {}%"))))
(defwidget launch []
(button :class "reg-btn launchbutton"
:hexpand true
:onclick "wofi --show run --xoffset=1670 --yoffset=12 --width=230px --height=984 --style=$HOME/.config/wofi.css --term=footclient --prompt=Run &" "")
)
(defwidget powerbutton []
(eventbox :cursor "hand"
(button :class "reg-btn powerbutton"
:onclick "eww open powermenu --toggle &" "")
)
)
(defwidget powermenucontent []
(box :orientation "h"
:class "powermenu-container"
(box :class "shutdown-btn-box"
:orientation "h"
(button :class "btn"
:tooltip "Shutdown"
:onclick "eww close powermenu && shutdown now"
"⏻")
)
(box :class "reboot-btn-box"
:orientation "h"
(button :class "btn"
:tooltip "Reboot"
:onclick "eww close powermenu && reboot"
"")
)
(box :class "exit-btn-box"
:orientation "h"
(button :class "btn"
:tooltip "Suspend"
:onclick "systemctl suspend"
"")
)
)
)
(defwindow powermenu
:monitor 0
:geometry (geometry :x "0%"
:y "0%"
:width "30%"
:height "15%"
:anchor "center center")
:wm-ignore true
(powermenucontent))
(deflisten workspaces_listen "./scripts/workspaces.sh")
(defwidget workspaces []
(literal :content workspaces_listen))
(defwindow dashboard
:monitor 0
:geometry (geometry
:height "1080px"
:width "350px"
:x "48px"
:y "0px"
:anchor "top left")
:stacking "fg"
:class "dashboard"
(dashboard))
(defwindow bar
:monitor 0
:exclusive false
:geometry (geometry :height "1080px" :x "-4px" :y "0px"
:width "52px"
:anchor "top left")
:stacking "fg"
(bar))

38
modules/eww/scripts/battery.sh Executable file
View file

@ -0,0 +1,38 @@
#!/bin/sh
bat=/sys/class/power_supply/BAT1/
per="$(cat "$bat/capacity")"
status="$(cat "$bat/status")"
if [ "$per" -gt "90" ]; then
icon=""
elif [ "$per" -gt "80" ]; then
icon=""
elif [ "$per" -gt "70" ]; then
icon=""
elif [ "$per" -gt "60" ]; then
icon=""
elif [ "$per" -gt "50" ]; then
icon=""
elif [ "$per" -gt "40" ]; then
icon=""
elif [ "$per" -gt "30" ]; then
icon=""
elif [ "$per" -gt "20" ]; then
icon=""
elif [ "$per" -gt "10" ]; then
icon=""
elif [ "$per" -gt "0" ]; then
icon=""
else
icon=""
fi
if [ -s /sys/class/power_supply/BAT1/capacity ]; then
echo "{\"percent\": \"$per\", \"icon\": \"$icon\", \"charging\": \"$charging\", \"visible\": \"true\", \"status\": \"$status\"}"
else
echo "{\"visible\": \"false\" }"
fi

View file

@ -0,0 +1,13 @@
#!/bin/sh
if eww windows | grep -q "\*brightness"; then
eww update bright-level="$(brightnessctl -m -d intel_backlight | awk -F, '{print substr($4, 0, length($4)-1)}' | tr -d '%')"
else
eww close volume
eww open brightness
eww update bright-level="$(brightnessctl -m -d intel_backlight | awk -F, '{print substr($4, 0, length($4)-1)}' | tr -d '%')"
sleep 2
sleep 1
eww close brightness
fi

18
modules/eww/scripts/volume.sh Executable file
View file

@ -0,0 +1,18 @@
#!/bin/sh
if eww windows | rg -q "\*volume"; then
eww update volume-level=$(pamixer --get-volume)
eww update volume-muted=$(pamixer --get-mute)
eww update volume-hidden=false
else
eww close brightness
eww open volume
eww update volume-level=$(pamixer --get-volume)
eww update volume-muted=$(pamixer --get-mute)
eww update volume-hidden=false
sleep 2
eww update volume-hidden=true
sleep 1
eww close volume
fi

12
modules/eww/scripts/wifi.sh Executable file
View file

@ -0,0 +1,12 @@
#!/bin/sh
if iwctl station wlan0 show | grep -q "connected"; then
icon=""
ssid=Amadeus
status="Connected to ${ssid}"
else
icon="睊"
status="offline"
fi
echo "{\"icon\": \"${icon}\", \"status\": \"${status}\"}"

View file

@ -0,0 +1,30 @@
#!/usr/bin/env lua
function trim(s)
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
end
aw = io.popen("hyprctl monitors | grep active | sed 's/()/(1)/g' | sort | awk 'NR>1{print $1}' RS='(' FS=')'")
active_workspace = aw:read("*a")
aw:close()
ew = io.popen("hyprctl workspaces | grep ID | sed 's/()/(1)/g' | sort | awk 'NR>1{print $1}' RS='(' FS=')'")
existing_workspaces = ew:read("*a")
ew:close()
box = "(box :orientation \"v\" :spacing 1 :space-evenly \"true\" "
for i = 1, #existing_workspaces do
local c = existing_workspaces:sub(i,i)
if tonumber(c) == tonumber(active_workspace) then
local btn = "(button :class \"active\" :onclick \"hyprctl dispatch workspace "..c.." \" \"\")"
box = box .. btn
elseif c ~= "\n" then
local btn = "(button :class \"inactive\" :onclick \"hyprctl dispatch workspace "..c.."\" \"\")"
box = box .. btn
end
end
box = box .. ")"
print(box)

View file

@ -0,0 +1,9 @@
#!/bin/sh
workspaces() {
./scripts/workspaces.lua
}
workspaces
tail -f /tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/hyprland.log | grep --line-buffered "Changed to workspace" | while read -r; do
workspaces
done