laptop, large refactor and some new stuff

This commit is contained in:
Vivian 2022-08-27 23:58:28 +02:00
parent 525f4ce03b
commit 99bbbbeb1e
15 changed files with 307 additions and 492 deletions

View file

@ -0,0 +1,32 @@
{ pkgs, ... }: {
home.packages = with pkgs; [
eww-wayland
pamixer
lua
(nerdfonts.override { fonts = [ "JetBrainsMono" ]; })
];
home.file.".config/eww/eww.yuck".source = ./eww.yuck;
home.file.".config/eww/eww.scss".source = ./eww.scss;
# scripts
home.file.".config/eww/scripts/volume.sh" = {
source = ./scripts/volume.sh;
executable = true;
};
home.file.".config/eww/scripts/wifi.sh" = {
source = ./scripts/wifi.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;
};
}

View file

@ -0,0 +1,252 @@
$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;
}
.wifi {
font-size: 2rem;
color: $blue;
}
.clock {
font-weight: bold;
background-color: $base;
color: $text;
border-radius: 10px;
padding: 0.2rem;
margin: 0.5rem;
}
.date {
font-size: 1.5rem;
}
.reg-btn {
font-size: 2rem;
margin: 2px 8px;
border-radius: 10px;
}
.powerbutton {
color: $red;
}
.powerbutton:hover {
background-color: $base;
}
.powerbutton:active {
background-color: $red;
color: $mantle;
}
.battery {
font-size: 1.5rem;
color: $green;
}
.volume {
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;
border-radius: 5px;
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;
}
}
}
// battery menu
.batterywindow {
background-color: $mantle;
border-radius: 5px;
font-size: 18px;
font-weight: normal;
color: $text;
progressbar {
border-radius: 5px;
}
progressbar progress {
background-color: $green;
}
progressbar trough {
background-color: $base;
}
.batterymenu {
padding: 10px;
}
}
// Calendar
.cal {
background-color: $mantle;
border-radius: 5px;
font-size: 18px;
font-weight: normal;
.cal-in {
padding: 0px 10px 0px 10px;
color: $text;
.cal {
&.highlight {
padding: 20px;
}
padding: 5px 5px 5px 5px;
margin-left: 10px;
}
}
}
calender {
color: $text;
}
calendar:selected {
color: $mauve;
}
calendar.header {
color: $overlay0;
font-weight: bold;
}
calendar.button {
color: $base;
}
calendar.highlight {
color: $overlay0;
font-weight: bold;
}
calendar:indeterminate {
color: $text;
}

View file

@ -0,0 +1,180 @@
(defwidget bar []
(centerbox :orientation "v" :hexpand false
(box :valign "start" :hexpand false :vexpand true :orientation "v" :space-evenly false
(powerbutton)
)
(workspaces :halign "center" :vexpand true :hexpand false :orientation "v")
(box :valign "end" :hexpand false :vexpand true :orientation "v" :space-evenly false
(wifi)
(volume)
(battery)
(time)
)
)
)
;; Variables
; (defvar time false)
; (defvar cal false)
;; ━━━ 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 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
(defwidget battery []
(eventbox :onclick "eww open batterywindow --toggle"
(label :text `${
EWW_BATTERY.BAT0.status == "Charging" ? "" :
EWW_BATTERY.BAT0.capacity < 10 ? "" :
EWW_BATTERY.BAT0.capacity < 20 ? "" :
EWW_BATTERY.BAT0.capacity < 30 ? "" :
EWW_BATTERY.BAT0.capacity < 40 ? "" :
EWW_BATTERY.BAT0.capacity < 50 ? "" :
EWW_BATTERY.BAT0.capacity < 60 ? "" :
EWW_BATTERY.BAT0.capacity < 70 ? "" :
EWW_BATTERY.BAT0.capacity < 80 ? "" :
EWW_BATTERY.BAT0.capacity < 90 ? "" : ""
}`
:limit-width 10
:tooltip "${EWW_BATTERY.BAT0.status}: ${EWW_BATTERY.BAT0.capacity}%"
:class "battery"
))
)
(defwidget batterymenu []
(box :orientation "v"
:class "batterymenu"
(label :text "${EWW_BATTERY.BAT0.status}: ${EWW_BATTERY.BAT0.capacity}%")
(progress :value "${EWW_BATTERY.BAT0.capacity}" :orientation "h") ; TODO: change class (and color) on low juice
)
)
(defwindow batterywindow
:monitor 0
:geometry (geometry
:x "53px"
:y "30px"
:anchor "bottom left"
)
(batterymenu)
)
;; ━━━ VOLUME ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
(defvar volume "{}")
(defpoll volume :interval "1s" "./scripts/volume.sh")
(defwidget volume []
(eventbox :onclick "pamixer -t"
(label :text {volume.icon}
:limit-width 10
:tooltip "${volume.percent}%"
:class "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}"
:onclick "eww open calendar --toggle &"
(box :orientation "v" :hexpand false :vexpand false :space-evenly false :class "clock"
(label :class "date" :text "${hour}")
(label :class "date" :text "${minute}")
)
)
)
;; Calendar
(defpoll calendar_day :interval "20h" "date '+%d'")
(defpoll calendar_year :interval "20h" "date '+%Y'")
(defwidget cal []
(box :class "cal" :orientation "v"
(box :class "cal-in"
(calendar :class "cal"
:day calendar_day
:year calendar_year))))
(defwindow calendar
:monitor 0
:geometry (geometry :x "53px"
:y "5px"
:anchor "bottom left"
:width "270px"
:height "60px")
(cal))
;; powermenu
(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 bar
:monitor 0
:exclusive false
:geometry (geometry :height "1080px" :x "-4px" :y "0px"
:width "52px"
:anchor "top left")
:stacking "fg"
(bar))

View file

@ -0,0 +1,15 @@
#!/bin/sh
per="$(pamixer --get-volume)"
if pamixer --get-mute | grep -q true; then
icon="婢"
elif [ "$per" -gt 66 ]; then
icon="墳" # high
elif [ "$per" -gt 33 ]; then
icon="奔" # med
else
icon="奄" #low
fi
printf "{\"icon\": \"${icon}\", \"percent\": \"${per}\"}"

View file

@ -0,0 +1,16 @@
#!/bin/sh
if nmcli g | rg -q "\bconnected\b"; then
icon="󰤨"
ssid=$(nmcli -t -f name connection show --active)
if echo $ssid | rg -q "Wired"; then
status="Connected via cable"
else
status="Connected to ${ssid}"
fi
else
icon="󰤭"
status="offline"
fi
printf "{\"icon\": \"${icon}\", \"status\": \"${status}\"}"

View file

@ -0,0 +1,21 @@
#!/usr/bin/env lua
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()
box = "(box :orientation \"v\" :spacing 1 :space-evenly \"true\" "
for i = 1,10 do
if i == tonumber(active_workspace) then
local btn = "(button :class \"active\" :onclick \"hyprctl dispatch workspace "..i.." \" \"\")"
box = box .. btn
else
local btn = "(button :class \"inactive\" :onclick \"hyprctl dispatch workspace "..i.."\" \"\")"
box = box .. btn
end
end
box = box .. ")"
print(box)

View file

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