sway on nvidia + ironbar

This commit is contained in:
atagen 2023-08-10 14:50:31 +10:00
parent 362d12714c
commit 481e682fbf
16 changed files with 830 additions and 655 deletions

58
home/dots/ironbar.corn Normal file
View file

@ -0,0 +1,58 @@
let {
$workspaces = {
type = "workspaces"
all_monitors = false
}
$focused = { type = "focused" }
$mpris = {
type = "music"
player_type = "mpris"
on_click_middle = "playerctl play-pause"
on_scroll_up = "playerctl volume +5"
on_scroll_down = "playerctl volume -5"
}
$sys_info = {
type = "sys_info"
interval.memory = 30
interval.cpu = 1
interval.temps = 5
interval.disks = 300
interval.networks = 3
format = [
" {cpu_percent}% | {temp_c:k10temp_Tccd1}°C"
" {memory_used} / {memory_total} GB ({memory_percent}%)"
"| {swap_used} / {swap_total} GB ({swap_percent}%)"
" {disk_used:/} / {disk_total:/} GB ({disk_percent:/}%)"
"李 {net_down:enp39s0} / {net_up:enp3s0} Mbps"
"猪 {load_average:1} | {load_average:5} | {load_average:15}"
" {uptime}"
]
}
$tray = { type = "tray" }
$clock = { type = "clock" }
$button = { type = "button" name="power-btn" label = "" on_click = "!wlogout" }
$left = [ $workspaces ]
$center = [ $focused ]
$right = [ $mpris $sys_info $button $clock ]
}
in {
anchor_to_edges = true
position = "top"
height = 16
icon_theme = "Papirus-Dark"
start = $left
center = $center
end = $right
}

201
home/dots/ironbar.css Normal file
View file

@ -0,0 +1,201 @@
@define-color color_bg #BG;
@define-color color_bg_dark #DARKBG;
@define-color color_border #BORDER;
@define-color color_border_active #ACTIVEBORDER;
@define-color color_text #TEXT;
@define-color color_urgent #URGENT;
/* -- base styles -- */
* {
font-family: #FONT, sans-serif;
font-size: #SZFONTpx;
border: none;
border-radius: 0;
}
box, menubar, button {
background-color: @color_bg;
background-image: none;
}
button, label {
color: @color_text;
}
button:hover {
background-color: @color_bg_dark;
}
#bar {
border-top: 1px solid @color_border;
}
.popup {
border: 1px solid @color_border;
padding: 1em;
}
/* -- clipboard -- */
.clipboard {
margin-left: 5px;
font-size: 1.1em;
}
.popup-clipboard .item {
padding-bottom: 0.3em;
border-bottom: 1px solid @color_border;
}
/* -- clock -- */
.clock {
font-weight: bold;
margin-left: 5px;
}
.popup-clock .calendar-clock {
color: @color_text;
font-size: 2.5em;
padding-bottom: 0.1em;
}
.popup-clock .calendar {
background-color: @color_bg;
color: @color_text;
}
.popup-clock .calendar .header {
padding-top: 1em;
border-top: 1px solid @color_border;
font-size: 1.5em;
}
.popup-clock .calendar:selected {
background-color: @color_border_active;
}
/* -- launcher -- */
.launcher .item {
margin-right: 4px;
}
.launcher .item:not(.focused):hover {
background-color: @color_bg_dark;
}
.launcher .open {
border-bottom: 1px solid @color_text;
}
.launcher .focused {
border-bottom: 2px solid @color_border_active;
}
.launcher .urgent {
border-bottom-color: @color_urgent;
}
.popup-launcher {
padding: 0;
}
.popup-launcher .popup-item:not(:first-child) {
border-top: 1px solid @color_border;
}
/* -- music -- */
.music:hover * {
background-color: @color_bg_dark;
}
.popup-music .album-art {
margin-right: 1em;
}
.popup-music .icon-box {
margin-right: 0.4em;
}
.popup-music .title .icon, .popup-music .title .label {
font-size: 1.7em;
}
.popup-music .controls *:disabled {
color: @color_border;
}
.popup-music .volume .slider slider {
border-radius: 100%;
}
.popup-music .volume .icon {
margin-left: 4px;
}
.popup-music .progress .slider slider {
border-radius: 100%;
}
/* -- script -- */
.script {
padding-left: 10px;
}
/* -- sys_info -- */
.sysinfo {
margin-left: 10px;
}
.sysinfo .item {
margin-left: 5px;
}
/* -- tray -- */
.tray {
margin-left: 10px;
}
/* -- workspaces -- */
.workspaces .item.focused {
box-shadow: inset 0 -3px;
background-color: @color_bg_dark;
}
.workspaces .item:hover {
box-shadow: inset 0 -3px;
}
/* -- custom: power menu -- */
.popup-power-menu #header {
font-size: 1.4em;
padding-bottom: 0.4em;
margin-bottom: 0.6em;
border-bottom: 1px solid @color_border;
}
.popup-power-menu .power-btn {
border: 1px solid @color_border;
padding: 0.6em 1em;
}
.popup-power-menu #buttons > *:nth-child(1) .power-btn {
margin-right: 1em;
}

View file

@ -10,17 +10,17 @@
palette-hex = pkgs.lib.nix-rice.palette.toRgbHex pkgs.rice.palette;
palette-shex = pkgs.lib.nix-rice.palette.toRGBShortHex pkgs.rice.palette;
in {
imports = [
inputs.hyprland.homeManagerModules.default
./programs/eww/default.nix
];
home.stateVersion = "22.11";
imports = [
inputs.ironbar.homeManagerModules.default
# ./programs/eww/default.nix
];
home.packages = with pkgs;
[
thunderbird
clementine
strawberry
inkscape
xfce.thunar
feh
@ -40,7 +40,6 @@ in {
slurp
swaybg
wlogout
wf-recorder
libnotify
xorg.xrdb
swayidle
@ -51,17 +50,14 @@ in {
kooha
nyxt
xplr
culr
swayosd
fuzzel
kdeconnect
# syncthing
keepassxc
git-credential-keepassxc
direnv
mpv
@ -88,43 +84,229 @@ in {
services.udiskie.enable = true;
wayland.windowManager.hyprland = {
programs.ironbar = with pkgs.rice; {
enable = true;
systemdIntegration = true;
nvidiaPatches = true;
xwayland = {
enable = true;
hidpi = false;
config = {
anchor_to_edges = true;
position = "top";
height = fonts.sans.size;
icon_theme = icons.name;
start = [
{ type = "workspaces"; all_monitors = true; }
{ type = "sys_info";
interval.memory = 30;
interval.cpu = 1;
format = [
" {cpu_percent}%"
" {memory_used} / {memory_total} GB"
];
}
];
center = [
{ type = "focused"; icon_size = 12; }
];
end = [
{ type = "music";
player_type = "mpris";
on_click_middle = "playerctl play-pause";
on_scroll_up = "playerctl volume +5";
on_scroll_down = "playerctl volume -5";
}
{ type = "clock"; }
];
};
recommendedEnvironment = true;
extraConfig = with pkgs.rice; (builtins.replaceStrings
style = with palette-hex; (builtins.replaceStrings
[
"#BGIMAGE"
"#GTKTHEME"
"#FONT"
"#ICONTHEME"
"#ACTIVEBORDER"
"#BG"
"#DARKBG"
"#BORDER"
"#THICK"
"#ROUND"
"#GAPSIN"
"#GAPSOUT"
"#ACTIVEBORDER"
"#TEXT"
"#URGENT"
"#FONT"
"#SZFONT"
]
[
"${bg.image}"
gtk-theme.name
util.bg
normal.black
normal.yellow
bright.yellow
util.fg
normal.red
fonts.sans.name
icons.name
palette-shex.bright.yellow
palette-shex.util.bg
(builtins.toString borders.thickness)
(builtins.toString borders.rounding)
(builtins.toString borders.gaps_in)
(builtins.toString borders.gaps_out)
(builtins.toString fonts.sans.size)
]
(builtins.readFile dots/hyprland/hyprland.conf));
(builtins.readFile dots/ironbar.css));
};
wayland.windowManager.sway = {
enable = true;
package = pkgs.sway;
config = with pkgs.rice; {
bars = [];
# reintroduces flicker
# output = {
# "*" = {
# adaptive_sync = "on";
# };
# };
focus = {
mouseWarping = "container";
wrapping = "no";
};
fonts = with fonts; {
names = [sans.name emoji.name];
size = 10.0;
};
gaps = {
inner = borders.gaps_in;
outer = borders.gaps_out;
smartGaps = true;
smartBorders = "no_gaps";
};
window = {
border = borders.thickness;
hideEdgeBorders = "smart";
titlebar = false;
};
workspaceAutoBackAndForth = false;
input = {
"*" = {
accel_profile = "flat";
pointer_accel = "0.0";
xkb_options = "caps:escape";
};
};
startup = [
{command = "mullvad connect";}
{command = "swaybg -i $HOME/.nix/wallpaper.png -m fill";}
{command = "ckb-next -c -b";}
{command = "xrdb -l ~/.Xresources";}
{command = "swayosd --max-volume 100";}
{command = "keepassxc";}
{command = "swaync";}
];
terminal = "kitty";
modifier = "Mod4";
keybindings = {
"Mod4+Return" = "exec kitty";
"Mod4+d" = "exec fuzzel";
"Mod4+e" = "exec thunar";
"Mod4+f" = "exec firefox";
"Mod4+Shift+e" = "exec wlogout";
"Mod4+n" = "exec swaync-client -t";
"Mod4+Space" = "floating toggle; move absolute position center";
"Mod4+c" = "focus floating; move absolute position center";
"Mod4+Shift+Space" = "fullscreen toggle";
"Mod4+a" = "focus parent";
"Mod4+Shift+a" = "focus child";
"Mod4+h" = "focus left";
"Mod4+j" = "focus down";
"Mod4+k" = "focus up";
"Mod4+l" = "focus right";
"Mod4+Shift+h" = "move left";
"Mod4+Shift+j" = "move down";
"Mod4+Shift+k" = "move up";
"Mod4+Shift+l" = "move right";
"Mod4+1" = "workspace 1";
"Mod4+Shift+1" = "move container to workspace 1";
"Mod4+2" = "workspace 2";
"Mod4+Shift+2" = "move container to workspace 2";
"Mod4+3" = "workspace 3";
"Mod4+Shift+3" = "move container to workspace 3";
"Mod4+4" = "workspace 4";
"Mod4+Shift+4" = "move container to workspace 4";
"Mod4+r" = "mode resize";
"Mod4+Shift+minus" = "move scratchpad";
"Mod4+minus" = "scratchpad show";
"Mod4+Shift+q" = "kill";
"Mod4+Shift+v" = "split horizontal";
"Mod4+v" = "split vertical";
"XF86AudioMute" = "exec swayosd --output-volume mute-toggle";
"XF86AudioRaiseVolume" = "exec swayosd --output-volume raise";
"XF86AudioLowerVolume" = "exec swayosd --output-volume lower";
"XF86AudioStop" = "exec playerctl stop";
"XF86AudioPlay" = "exec playerctl play-pause";
"XF86AudioPrev" = "exec playerctl previous";
"XF86AudioNext" = "exec playerctl next";
};
menu = "fuzzel";
colors = with palette-hex; {
background = util.bg;
focused = {
background = util.bg;
border = bright.yellow;
childBorder = bright.yellow;
indicator = normal.blue;
text = util.fg;
};
focusedInactive = {
background = normal.black;
border = normal.yellow;
childBorder = normal.yellow;
indicator = normal.blue;
text = normal.white;
};
placeholder = {
background = util.bg;
border = bright.green;
childBorder = bright.green;
indicator = normal.blue;
text = util.fg;
};
unfocused = {
background = normal.black;
border = util.bg;
childBorder = util.bg;
indicator = normal.blue;
text = normal.white;
};
urgent = {
background = normal.red;
border = normal.red;
childBorder = normal.red;
indicator = normal.red;
text = normal.blue;
};
};
};
systemd.enable = true;
wrapperFeatures = {
base = true;
gtk = true;
};
xwayland = true;
};
# extraConfig = with pkgs.rice; (builtins.replaceStrings
# [
# "#BGIMAGE"
# "#GTKTHEME"
# "#FONT"
# "#ICONTHEME"
# "#ACTIVEBORDER"
# "#BORDER"
# "#THICK"
# "#ROUND"
# "#GAPSIN"
# "#GAPSOUT"
# ]
# [
# "${bg.image}"
# gtk-theme.name
# fonts.sans.name
# icons.name
# palette-shex.bright.yellow
# palette-shex.util.bg
# (builtins.toString borders.thickness)
# (builtins.toString borders.rounding)
# (builtins.toString borders.gaps_in)
# (builtins.toString borders.gaps_out)
# ]
# (builtins.readFile dots/hyprland/hyprland.conf));
programs.starship = {
enable = true;
settings = {
@ -135,65 +317,54 @@ in {
};
};
programs.eww-hyprland = {
enable = true;
package = pkgs.eww-git;
colors = with palette-hex; (builtins.replaceStrings
[
"#BLACK"
"#BLCKA"
"#RED"
"#RDA"
"#GREEN"
"#GRNA"
"#YELLOW"
"#YLWA"
"#BLUE"
"#BLUA"
"#MAGENTA"
"#MGNA"
"#CYAN"
"#CYNA"
"#WHITE"
"#WHTA"
"#FG"
"#BG"
]
[
normal.black
bright.black
normal.red
bright.red
normal.green
bright.green
normal.yellow
bright.yellow
normal.blue
bright.blue
normal.magenta
bright.magenta
normal.cyan
bright.cyan
normal.white
bright.white
util.fg
util.bg
] (builtins.readFile dots/eww/colors.scss));
};
# programs.eww-custom = {
# enable = true;
# package = pkgs.eww-wayland;
# colors = with palette-hex; (builtins.replaceStrings
# [
# "#BLACK"
# "#BLCKA"
# "#RED"
# "#RDA"
# "#GREEN"
# "#GRNA"
# "#YELLOW"
# "#YLWA"
# "#BLUE"
# "#BLUA"
# "#MAGENTA"
# "#MGNA"
# "#CYAN"
# "#CYNA"
# "#WHITE"
# "#WHTA"
# "#FG"
# "#BG"
# ]
# [
# normal.black
# bright.black
# normal.red
# bright.red
# normal.green
# bright.green
# normal.yellow
# bright.yellow
# normal.blue
# bright.blue
# normal.magenta
# bright.magenta
# normal.cyan
# bright.cyan
# normal.white
# bright.white
# util.fg
# util.bg
# ] (builtins.readFile dots/eww/colors.scss));
# };
systemd.user.startServices = "sd-switch";
systemd.user.services."hyprland-system76" = {
Unit = {
Description = "the hyprland process scheduler hook";
Requires = ["dbus.service"];
};
Install = {
WantedBy = ["graphical-session.target" "default.target"];
};
Service = {
ExecStart = ''${pkgs.hyprland-system76-scheduler-integration}/bin/hyprland-system76-scheduler-hook.sh'';
};
};
xdg.enable = true;
xresources.properties = with palette-hex; {
@ -263,9 +434,6 @@ in {
"${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}"
];
# home.sessionVariables = {
# GTK_THEME = pkgs.rice.gtk.name;
# };
programs.wlogout = {
enable = true;
layout = builtins.fromJSON (builtins.readFile dots/wlogout/layout);
@ -556,24 +724,24 @@ in {
editor.lsp.display-messages = true;
};
languages = {
language = [{
name = "rust";
config = {
cargo = {
buildScripts = {
language = [
{
name = "rust";
config = {
cargo = {
buildScripts = {
enable = true;
};
};
procMacro = {
enable = true;
};
check = {
command = "clippy"; # as i walk through the valley of the sha
};
};
procMacro = {
enable = true;
};
check = {
command = "clippy"; # as i walk through the valley of the sha
};
};
}];
}
];
};
};

View file

@ -1,5 +1,4 @@
inputs: _: prev: {
hyprland-s76 = prev.callPackage ./hyprland-system76-scheduler-integration.nix {};
wlogout_style_base = dots/wlogout/style.css;
wlogout_style = prev.runCommandLocal "wlogout_style_base" {wlogpath = lib.strings.escape ["/"] "${pkgs.wlogout}";} ''
cp ${wlogout_style_base} $out

View file

@ -5,15 +5,11 @@
...
}: let
dependencies = with pkgs; [
config.wayland.windowManager.hyprland.package
cfg.package
bash
bc
blueberry
bluez
coreutils
dbus
dunst
findutils
gawk
gnome.gnome-control-center
@ -23,7 +19,6 @@
jaq
light
networkmanager
pavucontrol
playerctl
procps
pulseaudio
@ -35,7 +30,6 @@
wget
wireplumber
wlogout
fuzzel
swaynotificationcenter
];
@ -49,10 +43,10 @@
done
'';
cfg = config.programs.eww-hyprland;
cfg = config.programs.eww-custom;
in {
options.programs.eww-hyprland = {
enable = lib.mkEnableOption "eww Hyprland config";
options.programs.eww-custom = {
enable = lib.mkEnableOption "eww config";
package = lib.mkOption {
type = with lib.types; nullOr package;
@ -63,7 +57,7 @@ in {
autoReload = lib.mkOption {
type = lib.types.bool;
default = false;
default = true;
defaultText = lib.literalExpression "false";
description = "Whether to restart the eww daemon and windows on change.";
};
@ -73,10 +67,8 @@ in {
default = null;
defaultText = lib.literalExpression "null";
description = ''
SCSS file with colors defined in the same way as Catppuccin colors are,
SCSS file with colors defined in the same arbitrary and stupid way as Cringepuccin colors are,
to be used by eww.
Defaults to Catppuccin Mocha.
'';
};
};

View file

@ -2,7 +2,7 @@
(box
(button
:class "module"
{current_win.title}
"${current_win.title}""
)
)
)

View file

@ -1,18 +1,7 @@
#!/usr/bin/env bash
limit=128
socat -u UNIX-CLIENT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock STDOUT |
while read line; do
if [[ "$line" == activewindow\>\>* ]]; then
windowtitle="$(echo $line | cut -d',' -f 2)"
apptitle="$(echo $line | cut -d',' -f 1 | cut -d'>' -f 3 | rev | cut -d'.' -f -1 | rev)"
combined="$windowtitle - $apptitle"
if [[ "${#combined}" -lt $limit ]]; then
echo '{"title": "'$combined'"}'
else
clipto=$((limit-${#apptitle}))
echo '{"title": "'"${windowtitle:0:$clipto} - $apptitle"'"}'
fi
fi
done
swaymsg -m -t subscribe '[ "window" ]' | while read line; do
title=$(printf $line | gojq -r ."container.name" | cut -c -$limit)
echo '{ "title": "'$title'" }'
done

View file

@ -8,17 +8,14 @@ dimmed=("#f5c2e7" "#f9e2af" "#94e2d5" "#b4befe")
empty="#313244"
# get initial focused workspace
focusedws=$(hyprctl -j monitors | jaq -r '.[] | select(.focused == true) | .activeWorkspace.id')
# whatever
# focusedws=$(swaymsg -t get_workspaces -r | )
declare -A o=([1]=0 [2]=0 [3]=0 [4]=0)
declare -A monitormap
declare -A workspaces
# set color for each workspace
status() {
if [ "${o[$1]}" -eq 1 ]; then
mon=${monitormap[${workspaces[$1]}]}
if [ "$focusedws" -eq "$1" ]; then
echo -n "#ffd292"
# echo -n "${colors[$mon]}"
@ -32,67 +29,31 @@ status() {
fi
}
# handle workspace create/destroy
workspace_event() {
o[$1]=$2
while read -r k v; do workspaces[$k]="$v"; done < <(hyprctl -j workspaces | gojq -r '.[]|"\(.id) \(.monitor)"')
}
# handle monitor (dis)connects
monitor_event() {
while read -r k v; do monitormap["$k"]=$v; done < <(hyprctl -j monitors | gojq -r '.[]|"\(.name) \(.id) "')
}
# get all apps titles in a workspace
applist() {
ws="$1"
apps=$(hyprctl -j clients | jaq -jr '.[] | select(.workspace.id == '"$ws"') | .title + "\\n"')
echo -En "${apps%"\n"}"
}
# generate the json for eww
generate() {
echo -n '['
for i in {1..4}; do
echo -n ''"$([ "$i" -eq 1 ] || echo ,)" '{ "number": "'"$i"'", "color": "'"$(status "$i")"'" }' #, "tooltip": "'$(applist "$i")'" }'
echo -n ''"$([ "$i" -eq 1 ] || echo ,)" '{ "number": "'"$i"'", "color": "'"$(status "$i")"'" }'
done
echo ']'
}
# setup
# add monitors
monitor_event
# add workspaces
while read -r k v; do workspaces[$k]="$v"; done < <(hyprctl -j workspaces | gojq -r '.[]|"\(.id) \(.monitor)"')
# check occupied workspaces
for num in "${!workspaces[@]}"; do
o[$num]=1
done
# generate initial widget
generate
# main loop
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | rg --line-buffered "workspace|mon(itor)?" | while read -r line; do
case ${line%>>*} in
"workspace")
focusedws=${line#*>>}
swaymsg -m -t subscribe '[ "workspace" ]' | jq -r '.change+" "+.current.name' | while read -r line; do
case ${line%' '*} in
"focus")
focusedws=${line#*' '}
;;
"focusedmon")
focusedws=${line#*,}
"init")
workspace_event "${line#*' '}" 1
;;
"createworkspace")
workspace_event "${line#*>>}" 1
;;
"destroyworkspace")
workspace_event "${line#*>>}" 0
;;
"monitor"*)
monitor_event
"empty")
workspace_event "${line#*' '}" 0
;;
esac
generate