Refactor config to merge modules from platforms

This commit is contained in:
Kiana Sheibani 2023-01-03 21:17:49 -05:00
parent a3eecd7007
commit 0c4ce3e936
32 changed files with 95 additions and 116 deletions

View file

@ -0,0 +1,15 @@
{ ... }:
{
home.sessionVariables = {
MOZ_ENABLE_WAYLAND = "1";
MOZ_USE_XINPUT2 = "1";
};
imports = [
./sway.nix
./swaylock.nix
./mako.nix
./rofi.nix
./waybar.nix
];
}

View file

@ -0,0 +1,42 @@
{ pkgs, ... }:
{
programs.mako = {
enable = true;
font = "UbuntuMono Light 11";
format = ''<i>%a</i>\n<b>%s</b>\n\n%b'';
layer = "overlay";
backgroundColor = "#111320d0";
width = 300;
margin = "5";
padding = "5,10";
borderSize = 2;
borderColor = "#7bc5e4";
borderRadius = 5;
defaultTimeout = 10000;
extraConfig =
''
[urgency=low]
format=<i>%s</i>\n%b
background-color=#111111c0
border-color=#787c99
border-size=1
[urgency=high]
background-color=#1e0909d0
border-color=#ce7284
border-size=3
default-timeout=0
ignore-timeout=1
[app-name=discord]
format=<b>%s</b>\n\n%b
border-color=#7da6ff
[app-name=discordcanary]
format=<b>%s</b>\n\n%b
border-color=#7da6ff
'';
};
}

View file

@ -0,0 +1,7 @@
{ config, pkgs, ... }:
{
programs.rofi.enable = true;
programs.rofi.package = pkgs.rofi-wayland;
xdg.configFile.rofi.source = ./rofi;
}

View file

@ -0,0 +1,113 @@
configuration {
cycle: false;
modi: "drun,run,window:~/.config/rofi/window.sh,workspace:~/.config/rofi/workspace.sh";
font: "JetBrainsMono Nerd Font 14";
location: 0;
terminal: "alacritty";
show-icons: true;
hide-scrollbar: true;
drun-display-format: "{name}";
display-drun: "  Apps ";
display-run: "  Run ";
display-window: " 﩯 Window ";
display-workspace: "  Workspace ";
}
@theme "tokyonight"
element-text, element-icon, mode-switcher {
background-color: inherit;
text-color: inherit;
}
window {
// Using percentages here breaks literally everything for some reason
height: 550px;
width: 50%;
/* border: 3px; */
border-color: @border-col;
background-color: @bg-col;
border-radius: 12px;
}
mainbox {
background-color: @bg-col;
}
inputbar {
children: [prompt,entry];
background-color: @selected-col;
border-radius: 12px;
padding: 2px;
}
prompt {
background-color: @blue;
padding: 6px;
text-color: @bg-col;
border-radius: 8px;
margin: 20px 0px 20px 20px;
}
textbox-prompt-colon {
expand: false;
str: ":";
}
entry {
padding: 6px;
margin: 20px 0px 4px 10px;
text-color: @fg-col;
background-color: @selected-col;
}
listview {
padding: 10 10 0;
margin: 10 10 0 10;
columns: 5;
background-color: @bg-col;
}
element {
padding: 15 10 15;
background-color: @bg-col;
text-color: @fg-col;
orientation: vertical;
}
element-icon {
size: 56px;
horizontal-align: 0.5;
}
element selected {
background-color: @selected-col;
text-color: @blue ;
border-radius: 8px;
}
element-text {
vertical-align: 0.5;
horizontal-align: 0.5;
expand: true;
font: "JetBrainsMono Nerd Font Medium 10";
}
mode-switcher {
spacing: 0;
}
button {
padding: 10px;
background-color: @bg-col;
text-color: @empty;
vertical-align: 0.5;
horizontal-align: 0.5;
}
button selected {
background-color: @bg-col;
text-color: @blue;
}

View file

@ -0,0 +1,6 @@
@import "config.rasi"
configuration {
show-icons: false;
}

View file

@ -0,0 +1,16 @@
* {
bg-col: #1a1b26;
bg-col-light: #272834;
border-col: #7aa2f7;
selected-col: #282e49;
blue: #7bc5e4;
fg-col: #abb2bf;
fg-col2: #e06c75;
grey: #565c64;
width: 600;
selected: #caaa6a;
red: #ce7284;
green: #7dc5a0;
empty: #5b668e;
inactive: #4a5374;
}

View file

@ -0,0 +1,14 @@
#!/usr/bin/env bash
if [ $# -ne 0 ]; then
id=$(echo "$@" | cut -d ' ' -f1)
swaymsg "[con_id=$id]" focus
# Hack to get around weird bug
pkill rofi
exit 0
fi
swaymsg -t get_tree |
jq -r '.nodes[].nodes[] | if .nodes then [recurse(.nodes[])] else [] end + .floating_nodes |
.[] | select(.nodes==[]) | ((.id | tostring) + " " + .name)'

View file

@ -0,0 +1,12 @@
#!/usr/bin/env bash
if [ $# -ne 0 ]; then
swaymsg workspace "$@"
# Hack to get around weird bug
pkill rofi
exit 0
fi
swaymsg -t get_workspaces |
jq -r '.[].name'

View file

@ -0,0 +1,131 @@
{ pkgs, lib, ... }:
let
modifier = "Mod4";
terminal = "alacritty";
in {
home.packages = with pkgs; [ swayidle wl-clipboard wlroots ];
wayland.windowManager.sway = {
enable = true;
wrapperFeatures.gtk = true;
config = {
inherit modifier terminal;
menu = "rofi -show drun";
fonts = {
names = [ "JetBrainsMono Nerd Font" ];
style = "Medium";
size = 10.0;
};
bars = [{ command = "waybar"; }];
window.border = 3;
gaps = {
inner = 8;
outer = 0;
};
colors = {
unfocused.border = "#474f6f";
unfocused.background = "#1a1b26";
unfocused.text = "#a9b1d6";
unfocused.indicator = "#474f6f";
unfocused.childBorder = "#474f6f";
focused.border = "#7bc5e4";
focused.background = "#1a1b26";
focused.text = "#a9b1d6";
focused.indicator = "#7bc5e4";
focused.childBorder = "#7bc5e4";
focusedInactive.border = "#787c99";
focusedInactive.background = "#1a1b26";
focusedInactive.text = "#a9b1d6";
focusedInactive.indicator = "#787c99";
focusedInactive.childBorder = "#787c99";
urgent.border = "#d5556f";
urgent.background = "#444b6a";
urgent.text = "#ffffff";
urgent.indicator = "#d5556f";
urgent.childBorder = "#d5556f";
};
startup = map (x: { command = x; }) [
# Make wob channels
''mkfifo $SWAYSOCK.volume.wob && tail -f $SWAYSOCK.volume.wob | wob''
''mkfifo $SWAYSOCK.brightness.wob && tail -f $SWAYSOCK.brightness.wob | wob \
--border-color "#FFFF00FF" --bar-color "#FFFF00FF"''
''swayidle timeout 120 'swaylock -f --grace=180' \
timeout 600 'systemctl suspend' \
before-sleep 'swaylock -f' ''
''export XDG_SESSION_TYPE=wayland''
''export XDG_CURRENT_DESKTOP=sway''
];
keybindings = let
# Volume using pamixer and wob
audio-disp = ''pamixer --get-volume > $SWAYSOCK.volume.wob'';
audio = cmd: "exec pamixer ${cmd} && ${audio-disp}";
# Brightness using brightnessctl and wob
brightness-disp = ''brightnessctl -e -m | cut -d "," -f4 | tr -d "%" > $SWAYSOCK.brightness.wob'';
brightness = x: "exec brightnessctl -e set ${x} && ${brightness-disp}";
# Play controls using playerctl
playerctl = cmd: "exec playerctl ${cmd}";
# Grim screenshot file name
filename = ''~/Pictures/$(date +%Y-%m-%d_%H-%M-%S).png'';
in pkgs.lib.mkOptionDefault {
"${modifier}+Shift+d" = "exec rofi -show run -config ~/.config/rofi/noicons.rasi";
"${modifier}+w" = "exec rofi -show window -config ~/.config/rofi/noicons.rasi";
"${modifier}+Shift+w" = "exec rofi -show workspace -config ~/.config/rofi/noicons.rasi";
"${modifier}+t" = "layout tabbed";
"${modifier}+Shift+m" = "exec swaylock";
# Emacs Everywhere
"${modifier}+Mod1+e" = "emacsclient --eval '(emacs-everywhere)'";
# Screenshot
"Print" = ''exec grim ${filename}'';
"Shift+Print" = ''exec grim -g "$(slurp)" ${filename}'';
"Mod1+Print" = ''exec grim -g "$(swaymsg -t get_tree | jq -j '.. | select(.type?) | select(.focused).rect | "\(.x),\(.y) \(.width)x\(.height)"')" ${filename}'';
# Special XF86 key bindings
"XF86AudioRaiseVolume" = audio "-ui 2";
"XF86AudioLowerVolume" = audio "-ud 2";
"Shift+XF86AudioRaiseVolume" = audio "-ui 2 --allow-boost";
"Shift+XF86AudioLowerVolume" = audio "-ud 2 --allow-boost";
"XF86AudioMute" = ''exec pamixer --toggle-mute'';
"XF86AudioMicMute" = ''exec pactl set-source-mute @DEFAULT_SOURCE@ toggle'';
"XF86MonBrightnessDown" = brightness "4%-";
"XF86MonBrightnessUp" = brightness "4%+";
"XF86AudioPlay" = playerctl "play-pause";
"XF86AudioNext" = playerctl "next";
"XF86AudioPrev" = playerctl "previous";
# Exit
"${modifier}+Shift+e" = ''exec swaynag -t warning -m \
"You pressed the exit shortcut. Do you really want to exit sway? \
This will end your Wayland session." -b "Yes, exit sway" "swaymsg exit" '';
# Workspaces
"${modifier}+1" = "workspace 10:browser";
"${modifier}+2" = "workspace 20:terminal";
"${modifier}+3" = "workspace 30:code";
"${modifier}+4" = "workspace 40:files";
"${modifier}+5" = "workspace 50:discord";
"${modifier}+6" = "workspace 60:settings";
"${modifier}+Shift+1" = "move container to workspace 10:browser";
"${modifier}+Shift+2" = "move container to workspace 20:terminal";
"${modifier}+Shift+3" = "move container to workspace 30:code";
"${modifier}+Shift+4" = "move container to workspace 40:files";
"${modifier}+Shift+5" = "move container to workspace 50:discord";
"${modifier}+Shift+6" = "move container to workspace 60:settings";
};
output."*" = {
bg = "${../../assets/background.png} fill";
};
};
};
}

View file

@ -0,0 +1,35 @@
{ pkgs, ... }:
{
home.packages = [ pkgs.swaylock-effects ];
xdg.configFile."swaylock/config".text =
''
ignore-empty-password
grace-no-mouse
fade-in=0.3
indicator
screenshots
font=UbuntuMono
text-color=ffffff
color=00000000
ring-color=7da6ff
key-hl-color=7bc5e4
line-uses-inside
indicator-radius=120
indicator-thickness=7
clock
datestr=%A, %Y-%m-%d
effect-scale=0.4
effect-vignette=0.3:0.7
effect-blur=2x2
'';
}

View file

@ -0,0 +1,318 @@
{ config, pkgs, ... }:
{
programs.waybar = {
enable = true;
settings =
let spanfa = "<span font=\"Font Awesome 5 Regular 11\">";
in [{
height = 32;
margin = "8 8 0";
modules-left = [ "sway/workspaces" "sway/mode" "custom/sep" "cpu" "memory" "temperature" ];
modules-center = [ "sway/window" ];
modules-right =
if config.custom.platform == "laptop" then
[ "battery" "pulseaudio" "backlight" "network" "clock" "idle_inhibitor" ]
else
[ "pulseaudio" "network" "clock" "idle_inhibitor" ];
modules = {
"sway/workspaces" = {
disable-scroll = true;
all-outputs = true;
numeric-first = true;
format = "<big>{icon}</big>";
persistent_workspaces = {
"10:browser" = [];
"20:terminal" = [];
"30:code" = [];
"40:files" = [];
"50:discord" = [];
"60:settings" = [];
};
format-icons = {
terminal = "${spanfa}</span>";
code = "${spanfa}</span>";
browser = "${spanfa}<big></big></span>";
files = "${spanfa}</span>";
discord = "${spanfa}</span>";
settings = "${spanfa}</span>";
};
};
"sway/mode" = {
format = "<span style=\"italic\">{}</span>";
};
"mpd" = {
format = "{stateIcon} {consumeIcon}{randomIcon}{repeatIcon}{singleIcon}{artist} - {album} - {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S}) {songPosition}|{queueLength} ";
format-disconnected = "Disconnected ";
format-stopped = "{consumeIcon}{randomIcon}{repeatIcon}{singleIcon}Stopped ";
unknown-tag = "N/A";
interval = 2;
consume-icons.on = " ";
random-icons.off = "<span color=\"#f53c3c\"></span> ";
random-icons.on = " ";
repeat-icons.on = " ";
single-icons.on = "1 ";
state-icons.paused = "";
state-icons.playing = "";
tooltip-format = "MPD (connected)";
tooltip-format-disconnected = "MPD (disconnected)";
};
"idle_inhibitor" = {
format = "{icon}";
format-icons.activated = "";
format-icons.deactivated = "";
};
"tray" = {
# icon-size = 21;
spacing = 10;
};
"clock" = {
format = "<span font_family=\"Font Awesome 6 Pro Solid 11\"></span> {:%H:%M}";
tooltip-format = "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>";
format-alt = " {:%Y-%m-%d}";
};
"cpu" = {
format = "<span font=\"Font Awesome 5 Regular 13\"></span> <span rise=\"1pt\">{usage}%</span>";
tooltip = false;
};
"battery" = {
states.warning = 30;
states.low = 15;
states.critical = 5;
format-icons = [ "" "" "" "" "" "" "" "" "" "" "" ];
format = "<span font=\"UbuntuMono Nerd Font 12\">{icon}</span> {capacity}%";
format-charging = "<span font=\"UbuntuMono Nerd Font 12\"> </span>{capacity}%";
format-time = "{H}h {M}m";
};
"memory" = {
format = "${spanfa}<small></small></span> {}%";
};
"temperature" = {
# thermal-zone = 2;
# hwmon-path = "/sys/class/hwmon/hwmon2/temp1_input";
critical-threshold = 80;
format = "${spanfa}<small>{icon}</small></span> {temperatureC}°C";
format-icons = [ "" "" "" "" "" ];
};
"backlight" = {
# device = "acpi_video1";
format = "<span font=\"Font Awesome 5 Regular 12\"><big>{icon}</big></span><small> </small><span rise=\"2pt\">{percent}%</span>";
format-icons = [ "" "" "" "" ];
};
"network" = {
# interface = "wlp2*"; # (Optional) To force the use of this interface
format = "{ifname}";
format-wifi = "${spanfa}<small></small></span> Online";
format-ethernet = "${spanfa} </span>";
format-disconnected = "";
tooltip-format-wifi = "{essid} - {signalStrength}%";
tooltip-format-ethernet = "{signalStrength}%";
tooltip-format-disconnected = "";
};
"pulseaudio" = {
scroll-step = 1;
smooth-scrolling-threshold = 2.0;
format = "${spanfa}{icon}</span> {volume}%";
format-bluetooth = " ${spanfa}{icon}</span> {volume}%";
format-bluetooth-muted = "${spanfa} </span> 0%";
format-muted = "${spanfa}</span> {volume}%";
format-icons.headphone = "";
format-icons.phone = "";
format-icons.portable = "";
format-icons.car = "";
format-icons.default = [ "" "" "" ];
on-click = "pamixer -t";
};
"custom/media" = {
format = "{icon} {}";
return-type = "json";
max-length = 40;
format-icons.spotify = "";
format-icons.default = "🎜";
escape = true;
};
"custom/sep".format = "";
};
}];
style =
''
@define-color background #1a1b26;
@define-color foreground #a9b1d6;
@define-color red #ce7284;
@define-color green #7dc5a0;
@define-color yellow #caaa6a;
@define-color blue #7bc5e4;
@define-color magenta #ad8ee6;
@define-color altred #d5556f;
@define-color altgreen #b9f27c;
@define-color altyellow #ff9e64;
@define-color altblend #282e49;
@define-color empty #474f6f;
@define-color pink #c386c0;
@define-color violet #8682de;
* {
border: none;
font-family: "JetBrainsMono Nerd Font", monospace;
font-size: 13px;
}
window#waybar {
background-color: @background;
border-radius: 8px;
color: @foreground;
padding: 3px 0px;
}
#custom-sep {
color: @altblend;
font-size: 14px;
}
#workspaces {
margin-left: 6px;
}
#workspaces button {
padding: 0px 3px;
border-radius: 0px;
color: @blue;
}
#workspaces button:hover {
box-shadow: inherit;
text-shadow: inherit;
background: @background;
border: none;
padding: 0px 3px;
}
#workspaces button.persistent {color: @empty;}
#workspaces button.focused {
color: shade(@pink, 1.1);
text-shadow: 0px 0px 2px shade(@pink, 1.2);
}
#workspaces button.urgent {
background-color: @altred;
color: #ffffff;
}
#clock,
#battery,
#cpu,
#memory,
#disk,
#temperature,
#network,
#custom-media,
#tray,
#mode,
#idle_inhibitor,
#mpd {
margin: 0px 8px;
}
#idle_inhibitor {
padding: 0px 8px 0px 0px;
}
#cpu {
background-color: @altblend;
margin: 3px 0px 3px 2px;
padding-right: 5px;
padding-left: 8px;
border-radius: 18px 0px 0px 18px;
}
#pulseaudio {
background-color: @altblend;
${
if config.custom.platform == "laptop" then
''
margin: 3px 0px 3px 2px;
padding-right: 5px;
padding-left: 8px;
border-radius: 18px 0px 0px 18px;
''
else
''
margin: 3px 2px;
padding: 0px 8px;
border-radius: 18px;
''
}
}
#backlight, #memory {
background-color: @altblend;
margin: 3px 4px 3px 0px;
padding-left: 5px;
padding-right: 8px;
border-radius: 0px 18px 18px 0px;
}
#network {
background-color: @altblend;
margin: 3px 4px;
padding: 0px 6px;
border-radius: 18px;
}
#window {
font-family: "NotoSans Nerd Font";
font-size: 12px;
}
#mode {
color: @magenta;
text-shadow: 0px 0px 2px shade(@magenta, 1.05);
}
#cpu {color: @green;}
#memory {color: @yellow;}
#temperature {color: @blue;}
#clock {color: @blue;}
#temperature {color: @blue;}
#temperature.critical {color: @altyellow;}
@keyframes blink { to { color: @background; } }
#battery {color: @green;}
#battery.warning:not(.charging) {color: @altyellow;}
#battery.low:not(.charging) {color: @altred;}
#battery.critical:not(.charging) {
color: #ff2525;
animation-name: blink;
animation-duration: 1s;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
#backlight {color: @yellow;}
#network {color: @green;}
#pulseaudio {color: @pink;}
#pulseaudio.muted {color: @red;}
#idle_inhibitor.deactivated {color: @altred;}
#idle_inhibitor.activated {color: @altgreen;}
'';
};
}