initial version of my new laptop setup

This commit is contained in:
Vivian 2022-08-24 18:17:29 +02:00
parent 09f38ef5bf
commit c79f514dbe
18 changed files with 709 additions and 67 deletions

View file

@ -0,0 +1,38 @@
{ pkgs, ... }: {
home.packages = with pkgs; [
eww-wayland
brightnessctl
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/battery.sh" = {
source = ./scripts/battery.sh;
executable = true;
};
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,178 @@
$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;
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;
}
}
}

View file

@ -0,0 +1,133 @@
(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 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
(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 "{}")
(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}"
(box :orientation "v" :hexpand false :vexpand false :space-evenly false :class "clock"
(button :class "date"
:onclick "" "${hour}")
(button :class "date"
:onclick "" "${minute}")
)
)
)
(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,31 @@
#!/usr/bin/env bash
bat=/sys/class/power_supply/BAT0
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
echo "{\"percent\": \"$per\", \"icon\": \"$icon\", \"charging\": \"$charging\", \"visible\": \"true\", \"status\": \"$status\"}"

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,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,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