Initial sway, waybar and rofi config

This commit is contained in:
Erwin Boskma 2021-11-12 17:10:17 +01:00
parent 2bf5db5288
commit be2e1e5aa3
Signed by: erwin
GPG key ID: 02C3C0D914C0012B
16 changed files with 1078 additions and 28 deletions

View file

@ -2,8 +2,7 @@
description = "System config";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-21.05";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
@ -15,7 +14,8 @@
};
outputs = { nixpkgs, home-manager, ... }@inputs:
outputs = { self, ... }@inputs:
with inputs;
let
defSystem = systemArch: baseConfig:
@ -24,12 +24,11 @@
modules = [
{ _module.args.inputs = inputs; }
{ _module.args.self-overlay = self.overlay; }
{ _module.args.overlay-unstable = self.overlay-unstable; }
({ ... }: {
imports = builtins.attrValues self.nixosModules ++ [
{
nix.nixPath = [ "nixpkgs=${nixpkgs}" ];
nixpkgs.overlays = [ self.overlay self.overlay-unstable ];
nixpkgs.overlays = [ self.overlay ];
}
baseConfig
@ -70,12 +69,12 @@
# };
overlay = final: prev: (import ./overlays) final prev;
overlay-unstable = final: prev: {
unstable = import nixpkgs-unstable {
system = "x86_64-linux";
config.allowUnfree = true;
};
};
# overlay = final: prev: {
# unstable = import nixpkgs {
# system = "x86_64-linux";
# config.allowUnfree = true;
# };
# };
nixosModules = builtins.listToAttrs (map
(x: {
@ -112,6 +111,11 @@
# cpuCores = 4;
# };
vm1 = defSystem "x86_64-linux" {
imports = [
(import (./machines/vm1/configuration.nix) { inherit self; })
];
};
vm2 = defSystem "x86_64-linux" {
imports = [
(import (./machines/vm2/configuration.nix) { inherit self; })
@ -125,8 +129,8 @@
# };
};
}
(flake-utils.lib.eachSystem [ "x86_64-linux" ])
} //
(flake-utils.lib.eachSystem [ "x86_64-linux" ])
(system:
let
pkgs = import nixpkgs {
@ -141,10 +145,12 @@
rec {
packages = flake-utils.lib.flattenTree {
rofi-wayland = pkgs.rofi-wayland;
pamedia = pkgs.pamedia;
};
apps = {
rofi-wayland = flake-utils.lib.mkApp { drv = packages.rofi-wayland; };
pamedia = flake-utils.lib.mkApp { drv = packages.pamedia; };
};
}
);

View file

@ -0,0 +1,86 @@
configuration {
modi: "drun";
font: "Overpass Nerd Font 10";
display-drun: "";
sidebar-mode: false;
show-icons: true;
icon-theme: "Paper";
}
@theme "/dev/null"
* {
bg: #b5b5aa;
fg: #2b2b2b;
button: #9e9e95;
background-color: @bg;
text-color: @fg;
}
window {
transparency: "real";
border-radius: 7px;
width: 40%;
y-offset: 10px;
padding: 20px;
location: north;
}
prompt { enabled: false; }
entry {
placeholder: "Search";
expand: true;
padding: 5px 2% 5px 2%;
background-color: @button;
placeholder-color: @fg;
}
inputbar {
children: [ prompt, entry ];
background-color: @button;
text-color: @fg;
expand: false;
border-radius: 6px;
padding: 8px;
}
listview {
columns: 1;
lines: 8;
cycle: false;
dynamic: true;
layout: vertical;
}
mainbox {
children: [ inputbar, listview ];
spacing: 2%;
padding: 2% 1% 2% 1%;
}
element {
orientation: horizontal;
border-radius: 0%;
padding: 1.0% 0% 1.0% 1.0%;
}
element-text {
expand: true;
vertical-align: 0.5;
margin: 0.5% 1% 0% 1%;
background-color: inherit;
text-color: inherit;
}
element-icon {
size: 48px;
border: 0px;
}
element selected {
background-color: @fg;
text-color: @bg;
border-radius: 6px;
}

View file

@ -0,0 +1,16 @@
{ lib, pkgs, config, ... }:
with lib;
let
cfg = config.eboskma.programs.rofi;
in
{
options.eboskma.programs.rofi.enable = mkEnableOption "Enable rofi";
config = mkIf cfg.enable {
programs.rofi = {
enable = true;
theme = ./launch.rasi;
};
};
}

View file

@ -0,0 +1,111 @@
configuration {
dpi: 0;
me-select-entry: "Control+MousePrimary";
me-accept-entry: "MousePrimary";
}
* {
blue: #009ad1;
orange: #d14200;
text: #efefef;
text-alt: #c2c2c2;
bg: #333333;
spacing: 0;
background-color: transparent;
font: "DroidSansMono Nerd Font Mono, 14, FontAwesome5Free, 14";
highlight: bold;
text-color: @text;
}
window {
transparency: "real";
y-offset: -1.5em;
x-offset: -0.5em;
width: 27em;
background-color: transparent;
}
inputbar {
enabled: false;
border: 1px;
border-color: @orange;
border-radius: 5px;
padding: 10px;
margin: 0 5px;
background-color: @bg;
}
prompt {
text-color: @text;
}
textbox-prompt-colon {
expand: false;
str: ":";
text-color: @text-alt;
}
entry {
margin: 0 0.0em;
}
listview {
padding: 0.2em;
spacing: 0.2em;
dynamic: true;
scrollbar: false;
lines: 1;
columns: 5;
background-color: transparent;
}
element {
padding: 0.6em;
text-color: @text-alt;
highlight: bold #95ee8f; /* green */
background-color: @bg;
border-radius: 5px;
border: 1px;
border-color: @orange;
}
element-icon {
size: 1em;
padding: 0 0.6em 0 0;
}
element selected {
border: 0 0 0 1px;
background-color: @blue;
text-color: @text;
}
element urgent, element selected urgent {
text-color: @red;
}
element active, element selected active {
text-color: @purple;
}
message, error-message {
margin: 0 0 0.6em;
padding: 1%;
border-radius: 5px;
background-color: @emphasis;
}
error-message {
margin: 0;
padding: 0.6em;
border-color: @red;
border: 3px;
}
mode-switcher {
margin: 0.1em 0 0 0;
}
button selected {
padding: 0.3em;
border-radius: 5px;
background-color: @emphasis;
}

View file

@ -0,0 +1,186 @@
{ lib, pkgs, config, ... }:
with lib;
let
cfg = config.eboskma.programs.sway;
mod = "Mod4";
swaylockcmd = "${pkgs.swaylock}/bin/swaylock --ignore-empty-password --daemonize --show-failed-attempts --indicator-caps-lock --clock --image /home/erwin/Dropbox/Private/Wallpapers/2560x1440/arch.png --fade-in 0.5 --scaling fill";
in
{
options.eboskma.programs.sway.enable = mkEnableOption "Enable sway";
config = mkIf cfg.enable {
wayland.windowManager.sway = {
enable = true;
config = {
modifier = mod;
assigns = {
"1" = [{ app_id = "firefox"; }];
"2" = [{ app_id = "Alacritty"; }];
"3" = [{ class = "Code"; }];
"10" = [{ class = "telegramdesktop"; } { class = "Signal"; }];
};
bars = [
{
command = "${pkgs.waybar}/bin/waybar";
}
];
left = "n";
down = "e";
up = "i";
right = "o";
floating = {
criteria = [{ app_id = "gnome-calculator"; }];
modifier = mod;
};
fonts = {
names = [ "Iosevka Nerd Font" ];
style = "Regular";
size = 12.0;
};
gaps = {
inner = 10;
outer = 5;
smartBorders = "on";
};
input = {
"36125:40349:splitKB_Kyria" = {
xkb_options = "lv3:ralt_switch";
};
"1133:49291:Logitech_G502_HERO_SE" = {
natural_scroll = "enabled";
};
};
output = {
"Virtual-1" = {
bg = "~/.wallpapers/river-1920.png fill";
mode = "1920x1080@60Hz";
};
"DP-2" = {
bg = "~/.wallpapers/river-2560.png fill";
mode = "2560x1440@144Hz";
adaptive_sync = "on";
};
};
menu = "${pkgs.wofi}/bin/wofi --show drun -i | ${pkgs.findutils}/bin/xargs swaymsg exec --";
keybindings = {
"${mod}+Return" = "exec ${config.wayland.windowManager.sway.config.terminal}";
"${mod}+Shift+q" = "kill";
"${mod}+s" = "exec ${config.wayland.windowManager.sway.config.menu}";
"${mod}+Shift+s" = "exec ${pkgs.wofi}/bin/wofi --show run | ${pkgs.findutils}/bin/xargs swaymsg exec --";
"${mod}+${config.wayland.windowManager.sway.config.left}" = "focus left";
"${mod}+${config.wayland.windowManager.sway.config.down}" = "focus down";
"${mod}+${config.wayland.windowManager.sway.config.up}" = "focus up";
"${mod}+${config.wayland.windowManager.sway.config.right}" = "focus right";
"${mod}+Left" = "focus left";
"${mod}+Down" = "focus down";
"${mod}+Up" = "focus up";
"${mod}+Right" = "focus right";
"${mod}+Shift+${config.wayland.windowManager.sway.config.left}" = "move left";
"${mod}+Shift+${config.wayland.windowManager.sway.config.down}" = "move down";
"${mod}+Shift+${config.wayland.windowManager.sway.config.up}" = "move up";
"${mod}+Shift+${config.wayland.windowManager.sway.config.right}" = "move right";
"${mod}+Shift+Left" = "move left";
"${mod}+Shift+Down" = "move down";
"${mod}+Shift+Up" = "move up";
"${mod}+Shift+Right" = "move right";
"${mod}+h" = "split h";
"${mod}+v" = "split v";
"${mod}+t" = "fullscreen toggle";
"${mod}+a" = "focus parent";
"${mod}+r" = "layout stacking";
"${mod}+w" = "layout tabbed";
"${mod}+f" = "layout toggle split";
"${mod}+Shift+space" = "floating toggle";
"${mod}+space" = "focus mode_toggle";
"${mod}+1" = "workspace number 1";
"${mod}+2" = "workspace number 2";
"${mod}+3" = "workspace number 3";
"${mod}+4" = "workspace number 4";
"${mod}+5" = "workspace number 5";
"${mod}+6" = "workspace number 6";
"${mod}+7" = "workspace number 7";
"${mod}+8" = "workspace number 8";
"${mod}+9" = "workspace number 9";
"${mod}+Shift+1" =
"move container to workspace number 1";
"${mod}+Shift+2" =
"move container to workspace number 2";
"${mod}+Shift+3" =
"move container to workspace number 3";
"${mod}+Shift+4" =
"move container to workspace number 4";
"${mod}+Shift+5" =
"move container to workspace number 5";
"${mod}+Shift+6" =
"move container to workspace number 6";
"${mod}+Shift+7" =
"move container to workspace number 7";
"${mod}+Shift+8" =
"move container to workspace number 8";
"${mod}+Shift+9" =
"move container to workspace number 9";
"${mod}+Shift+minus" = "move scratchpad";
"${mod}+minus" = "scratchpad show";
"${mod}+Shift+c" = "reload";
"${mod}+Shift+p" = "restart";
"${mod}+Shift+f" = "exec --no-startup-id ~/.config/wofi/session.sh";
"${mod}+l" = "exec ${swaylockcmd}";
"${mod}+p" = "mode resize";
"${mod}+Print" = "exec grim -o $(swaymsg -t get_outputs | ${pkgs.jq}/bin/jq -r '.[] | select(.focused) | .name')";
"${mod}+Shift+Print" = "exec grim -o $(swaymsg -t get_outputs | ${pkgs.jq}/bin/jq -r '.[] | select(.focused) | .name') - | ${pkgs.wl-clipboard}/bin/wl-copy -t \"image/png\" -f";
"${mod}+Shift+Ctrl+Print" = "exec grim -g \"$(${pkgs.slurp}/bin/slurp)\" - | ${pkgs.wl-clipboard}/bin/wl-copy -t \"image/png\" -f";
"${mod}+Shift+Alt+Print" = "exec grim -g \"$(${pkgs.slurp}/bin/slurp)\"";
"XF86AudioRaiseVolume" = "exec ${pkgs.pamedia}/bin/pamedia up";
"XF86AudioLowerVolume" = "exec ${pkgs.pamedia}/bin/pamedia down";
"XF86AudioMute" = "exec ${pkgs.pamedia}/bin/pamedia mute";
"XF86Calculator" = "exec ${pkgs.gnome.gnome-calculator}/bin/gnome-calculator";
};
terminal = "${pkgs.alacritty}/bin/alacritty";
window = {
border = 1;
titlebar = false;
};
workspaceAutoBackAndForth = true;
};
extraConfig = ''
assign [app_id="firefox"] 1
assign [app_id="Alacritty"] 2
assign [app_id="Code"] 3
assign [app_id="telegramdesktop"] 10
assign [app_id="Signal"] 10
for_window [app_id="^.*"] inhibit_idle fullscreen
for_window [class="^.*"] inhibit_idle fullscreen
for_window [app_id="gnome-calculator"] floating enable
exec --no-startup-id ${pkgs.networkmanagerapplet}/bin/nm-applet --indicator
'';
};
};
}

View file

@ -0,0 +1,366 @@
{ lib, pkgs, config, ... }:
with lib;
let
cfg = config.eboskma.programs.waybar;
in
{
options.eboskma.programs.waybar.enable = mkEnableOption "Enable waybar";
config = mkIf cfg.enable {
programs.waybar = {
enable = true;
settings = [
{
layer = "top";
position = "top";
height = 30;
modules-left = [
"sway/workspaces"
"sway/mode"
# "custom/now_playing"
];
modules-center = [
"sway/window"
];
modules-right = [
"network"
"memory"
"cpu"
"temperature"
"custom/keyboard-layout"
"pulseaudio"
"tray"
"clock#date"
"clock#time"
"idle_inhibitor"
];
modules = {
"clock#time" = {
interval = 1;
format = "{:%H:%M:%S}";
tooltip = false;
};
"clock#date" = {
interval = 10;
format = " {:%e %b %Y}";
tooltip-format = "{:%e %B %Y}";
};
"cpu" = {
interval = 5;
format = " {usage}% ({load})";
states = {
warning = 70;
critical = 90;
};
};
"custom/keyboard-layout" = {
exec = "swaymsg -t get_inputs | grep -m1 'xkb_active_layout_name' | cut -d '\"' -f4";
interval = 30;
format = " {}"; # Icon: keyboard
# Signal sent by Sway key binding (~/.config/sway/key-bindings)
signal = 1; # SIGHUP
tooltip = false;
};
"memory" = {
interval = 5;
format = " {}%"; # Icon: memory
states = {
warning = 70;
critical = 90;
};
};
"network" = {
interval = 5;
format-wifi = " {essid} ({signalStrength}%)"; # Icon: wifi
format-ethernet = " {ifname}: {ipaddr}/{cidr}"; # Icon: ethernet
format-disconnected = " Disconnected";
tooltip-format = "{ifname}: {ipaddr}";
};
"sway/mode" = {
format = "<span style=\"italic\"> {}</span>"; # Icon: expand-arrows-alt
tooltip = false;
};
# TODO: package as nix thingy
# "custom/now_playing" = {
# exec = "${HOME}/.config/waybar/ha-now-playing --host home.datarift.nl --entity media_player.sonos_woonkamer --token eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiI5OWJmN2YyNWYyODc0ZmZhOWVhMTZiNGM1MTQyZmUzZiIsImlhdCI6MTYwMzIyMDAyMiwiZXhwIjoxOTE4NTgwMDIyfQ.dNfjPN-cYStiPrSO-PVArJdShMWl2rdDeo8AXr1byIY";
# format = " ♪ {}";
# interval = 2;
# on-click = "${HOME}/.config/waybar/ha-now-playing --host home.datarift.nl --entity media_player.sonos_woonkamer --token eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiI5OWJmN2YyNWYyODc0ZmZhOWVhMTZiNGM1MTQyZmUzZiIsImlhdCI6MTYwMzIyMDAyMiwiZXhwIjoxOTE4NTgwMDIyfQ.dNfjPN-cYStiPrSO-PVArJdShMWl2rdDeo8AXr1byIY play-pause";
# on-scroll-down = "${HOME}/.config/waybar/ha-now-playing --host home.datarift.nl --entity media_player.sonos_woonkamer --token eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiI5OWJmN2YyNWYyODc0ZmZhOWVhMTZiNGM1MTQyZmUzZiIsImlhdCI6MTYwMzIyMDAyMiwiZXhwIjoxOTE4NTgwMDIyfQ.dNfjPN-cYStiPrSO-PVArJdShMWl2rdDeo8AXr1byIY volume-up";
# on-scroll-up = "${HOME}/.config/waybar/ha-now-playing --host home.datarift.nl --entity media_player.sonos_woonkamer --token eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiI5OWJmN2YyNWYyODc0ZmZhOWVhMTZiNGM1MTQyZmUzZiIsImlhdCI6MTYwMzIyMDAyMiwiZXhwIjoxOTE4NTgwMDIyfQ.dNfjPN-cYStiPrSO-PVArJdShMWl2rdDeo8AXr1byIY volume-down";
# };
"sway/window" = {
format = "{}";
max-length = 120;
};
"sway/workspaces" = {
all-outputs = false;
disable-scroll = true;
format = "{icon} {name}";
format-icons = {
"1 =www" = "";
# Icon = firefox-browser
"2 =mail" = "";
# Icon = mail
"3 =editor" = "";
# Icon = code
"4 =terminals" = "";
# Icon = terminal
"5 =portal" = "";
# Icon = terminal
"urgent" = "";
"focused" = "";
"default" = "";
};
};
"pulseaudio" = {
#scroll-step = 1;
format = "{icon} {volume}%";
format-bluetooth = "{icon} {volume}%";
format-muted = "";
format-icons = {
headphones = "";
handsfree = "";
headset = "";
phone = "";
portable = "";
car = "";
default = [ "" "奔" "" ];
};
on-click = "pavucontrol";
};
"temperature" = {
hwmon-path = "/sys/class/hwmon/hwmon2/temp1_input";
critical-threshold = 80;
interval = 5;
format = "{icon} {temperatureC}°C";
format-icons = [
"" # Icon = temperature-empty
"" # Icon = temperature-quarter
"" # Icon = temperature-half
"" # Icon = temperature-three-quarters
"" # Icon = temperature-full
];
tooltip = true;
};
"tray" = {
icon-size = 21;
spacing = 10;
};
"idle_inhibitor" = {
format = "<span size=\"large\">{icon}</span>";
format-icons = {
activated = "";
deactivated = "";
};
};
};
}
];
style =
''
@keyframes blink-warning {
70% {
color: white;
}
to {
color: white;
background-color: orange;
}
}
@keyframes blink-critical {
70% {
color: white;
}
to {
color: white;
background-color: red;
}
}
* {
border: none;
border-radius: 0;
min-height: 0;
margin: 0;
padding: 0;
}
#waybar {
background: #323232;
color: white;
font-family: "MesloLGM Nerd Font", sans-serif;
font-size: 13px;
}
#battery,
#clock,
#cpu,
#custom-keyboard-layout,
#memory,
#mode,
#network,
#pulseaudio,
#temperature,
#tray,
#custom-now_playing,
#idle_inhibitor {
padding-left: 10px;
padding-right: 10px;
}
#battery {
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
#battery.warning {
color: orange;
}
#battery.critical {
color: red;
}
#battery.warning.discharging {
animation-name: blink-warning;
animation-duration: 3s;
}
#battery.critical.discharging {
animation-name: blink-critical;
animation-duration: 2s;
}
#clock {
font-weight: bold;
}
#cpu {
/* No styles */
}
#cpu.warning {
color: orange;
}
#cpu.critical {
color: red;
}
#memory {
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
#memory.warning {
color: orange;
}
#memory.critical {
color: red;
animation-name: blink-critical;
animation-duration: 2s;
}
#mode {
background: #64727D;
border-top: 2px solid white;
/* To compensate for the top border and still have vertical centering */
padding-bottom: 2px;
}
#network {
/* No styles */
}
#network.disconnected {
color: orange;
}
#pulseaudio {
/* No styles */
}
#pulseaudio.muted {
/* No styles */
}
#custom-spotify {
color: rgb(102, 220, 105);
}
#temperature {
/* No styles */
}
#temperature.critical {
color: red;
}
#tray {
/* No styles */
}
#window {
font-weight: bold;
}
#workspaces button {
border-top: 2px solid transparent;
/* To compensate for the top border and still have vertical centering */
padding-bottom: 2px;
padding-left: 10px;
padding-right: 10px;
color: #888888;
}
#workspaces button.focused {
border-color: #4c7899;
color: white;
background-color: #285577;
}
#workspaces button.urgent {
border-color: #c9545d;
color: #c9545d;
}
#idle_inhibitor {
background-color: transparent;
font-weight: bold;
}
#idle_inhibitor.activated {
background-color: #c9545d;
color: #ffffff;
}
#custom-now_playing {
font-weight: bold;
}
'';
};
};
}

View file

@ -0,0 +1,38 @@
{ self, ... }:
{
imports = [ ./hardware-configuration.nix ];
eboskma = {
desktop = {
enable = true;
home-manager = true;
};
};
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
time.timeZone = "Europe/Amsterdam";
networking = {
hostName = "vm2";
useDHCP = false;
interfaces.enp1s.useDHCP = true;
};
# nix = {
# package = pkgs.nixUnstable;
# extraOptions = ''
# experimental-features = nix-command flakes
# '';
# };
services.openssh.enable = true;
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "21.05"; # Did you read the comment?
}

View file

@ -0,0 +1,32 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[
(modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "sr_mod" "virtio_blk" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{
device = "/dev/disk/by-label/nixos";
fsType = "ext4";
};
fileSystems."/boot" =
{
device = "/dev/disk/by-label/boot";
fsType = "vfat";
};
swapDevices =
[{ device = "/dev/disk/by-label/swap"; }];
}

View file

@ -1,6 +1,13 @@
{ self, ... }:
{
imports = [ ./hardware-configuration.nix ../../users/erwin.nix ];
imports = [ ./hardware-configuration.nix ];
eboskma = {
desktop = {
enable = true;
home-manager = true;
};
};
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
@ -8,17 +15,17 @@
time.timeZone = "Europe/Amsterdam";
networking = {
hostname = "vm2";
hostName = "vm2";
useDHCP = false;
interfaces.enp1s.useDHCP = true;
};
nix = {
package = pkgs.nixUnstable;
extraOptions = ''
experimental-features = nix-command flakes
'';
};
# nix = {
# package = pkgs.nixUnstable;
# extraOptions = ''
# experimental-features = nix-command flakes
# '';
# };
services.openssh.enable = true;
# This value determines the NixOS release from which the default

View file

@ -0,0 +1,53 @@
{ lib, pkgs, config, inputs, self-overlay, ... }:
with lib;
let cfg = config.eboskma.desktop;
in
{
imports = [ ../../users/erwin.nix ../../users/root.nix ];
options.eboskma.desktop = {
enable = mkEnableOption "Enable default desktop configuration";
home-manager = mkOption {
type = types.bool;
default = false;
description = ''
Enable home-manager for this desktop
'';
};
};
config = mkIf cfg.enable {
home-manager.users.erwin = mkIf cfg.home-manager {
_module.args.flake-inputs = inputs;
programs.home-manager.enable = true;
programs.command-not-found.enable = true;
home.username = "erwin";
home.homeDirectory = "/home/erwin";
nixpkgs.config = { allowUnfree = true; };
services.gnome-keyring.enable = true;
home.stateVersion = "21.11";
eboskma = {
programs = {
sway.enable = true;
rofi.enable = true;
waybar.enable = true;
};
};
home.packages = with pkgs; [
(nerdfonts.override { fonts = [ "CascadiaCode" "FantasqueSansMono" "FiraCode" "Iosevka" "JetBrainsMono" "Meslo" "Noto" "SourceCodePro" ]; })
];
imports = [
../../home-manager/modules/sway
../../home-manager/modules/waybar
../../home-manager/modules/rofi
];
};
};
}

View file

@ -1,3 +1,4 @@
self: super: {
rofi-wayland = super.pkgs.callPackage ../pkgs/rofi-wayland { };
rofi = super.pkgs.callPackage ../pkgs/rofi-wayland { };
pamedia = super.pkgs.callPackage ../pkgs/pamedia { };
}

21
pkgs/pamedia/default.nix Normal file
View file

@ -0,0 +1,21 @@
{ buildPythonPackage, lib, pulsectl }:
buildPythonPackage rec {
pname = "pamedia";
version = "0.1.0";
src = ./src;
propagatedBuildInputs = [
pulsectl
];
installPhase = ''
install -d $out/bin
install -m 0755 $src/pamedia $out/bin/pamedia
'';
meta = {
description = "Change volume of the PulseAudio default sink";
license = lib.licenses.mit;
};
}

116
pkgs/pamedia/src/pamedia Executable file
View file

@ -0,0 +1,116 @@
#!/usr/bin/env python3
import argparse
import pulsectl
import gi
gi.require_version('Notify', '0.7')
from gi.repository import GLib
from gi.repository import Notify
class PAMedia:
def __init__(self, sink=None):
self.client = pulsectl.Pulse('volumectl')
sinks = self.client.sink_list()
if sink == None:
self.sink = self.client.get_sink_by_name(
self.client.server_info().default_sink_name)
else:
if sink > len(sinks):
notification = Notify.Notification.new(
'Volume', f'Unknown sink index \'{sink}\', using default sink')
notification.show()
self.sink = self.client.get_sink_by_name(
self.client.server_info().default_sink_name)
self.sink = sinks[sink]
def toggle_mute(self):
self.client.mute(self.sink, mute=not self.sink.mute)
def volume_up(self):
self.client.mute(self.sink, mute=False)
self.client.volume_change_all_chans(self.sink, 0.05)
def volume_down(self):
self.client.mute(self.sink, mute=False)
self.client.volume_change_all_chans(self.sink, -0.05)
def volume_set(self, new_volume):
new_volume = min(100, max(0, int(new_volume)))
self.client.volume_set_all_chans(self.sink, new_volume / 100.0)
def list_sinks(self):
for num, sink in enumerate(self.client.sink_list()):
print(f'[{num}] {sink.description}')
def icon(self):
if self.sink.mute:
return 'muted'
elif self.sink.volume.value_flat <= 0.3:
return 'low'
elif self.sink.volume.value_flat <= 0.7:
return 'medium'
else:
return 'high'
def notify(self):
icon = f'audio-volume-{self.icon()}'
title = f'Volume'
if self.sink.mute:
title = 'Muted'
notification = Notify.Notification.new(title, '', icon)
if not self.sink.mute:
notification.set_hint(
'x-canonical-private-synchronous', GLib.Variant.new_string('audio'))
notification.set_hint(
'value', GLib.Variant.new_int32(round(self.volume())))
notification.show()
def volume(self):
return self.sink.volume.value_flat * 100
def volume_format(self):
volume = round(self.volume())
return f'{volume}%'
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='PulseAudio volume control')
parser.add_argument('-s', '--sink', type=int,
help='Select output sink to control')
parser.add_argument('command', metavar='CMD', type=str,
nargs='+', help='Command, one of: mute, up, down, set, get, sinks')
args = parser.parse_args()
ctl = PAMedia(sink=args.sink)
Notify.init('volumectl')
if args.command[0] == 'mute':
ctl.toggle_mute()
elif args.command[0] == 'up':
ctl.volume_up()
elif args.command[0] == 'down':
ctl.volume_down()
elif args.command[0] == 'get':
print(f'Volume: {ctl.volume_format()}')
exit(0)
elif args.command[0] == 'set' and len(args.command) >= 2:
ctl.volume_set(args.command[1])
elif args.command[0] == 'sinks':
ctl.list_sinks()
exit(0)
else:
print(f"Unknown command '{args.command}'")
parser.print_help()
exit(1)
ctl.notify()

View file

@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
'';
nativeBuildInputs = [ meson ninja pkgconfig ];
buildInputs = [
buildInputs = with pkgs; [
libxkbcommon
pango
cairo
@ -29,9 +29,9 @@ stdenv.mkDerivation rec {
librsvg
check
libstartup_notification
libxcb
xcbutil
xcbutilwm
xorg.libxcb
xorg.xcbutil
xorg.xcbutilwm
xcbutilxrm
which
wayland-protocols

View file

@ -1,9 +1,9 @@
{ config, pkgs, lib, ... }:
{ pkgs, ... }:
{
users.users.erwin = {
isNormalUser = true;
home = "/home/erwin";
exdraGroups = [ "wheel" "adm" "audio" "video" ];
extraGroups = [ "wheel" "adm" "audio" "video" ];
shell = pkgs.fish;
openssh.authorizedKeys.keyFiles = [
(pkgs.fetchurl {

11
users/root.nix Normal file
View file

@ -0,0 +1,11 @@
{ pkgs, ... }:
{
users.users.root = {
openssh.authorizedKeys.keyFiles = [
(pkgs.fetchurl {
url = "https://github.com/eboskma.keys";
sha256 = "1l7f425kvfmrs4dfcvllb76182jgb14l1silyy4qmjxvinawb1yj";
})
];
};
}