1
0
Fork 0

Improve sway config

This commit is contained in:
Malte Brandy 2019-11-29 17:52:50 +01:00
parent 1c71fe4519
commit 9ec9447a71
No known key found for this signature in database
GPG key ID: 226A2D41EF5378C9
9 changed files with 220 additions and 173 deletions

View file

@ -1,6 +1,7 @@
{ pkgs, config, ... }:
let
inherit (config.m-0.private) me meWork;
inherit (import ../lib) writeHaskellScript;
my-pkgs = import ../pkgs;
inherit (my-pkgs) lorri;
in {

View file

@ -1,7 +1,14 @@
{ pkgs, lib, config, ... }:
let inherit (import ../../pkgs) desktop-pkgs;
in {
imports = [ ./rofi.nix ./ssh-agent.nix ./eventd.nix ./sleep-nag.nix ];
imports = [
./sway.nix
./wallpaper.nix
./rofi.nix
./ssh-agent.nix
./eventd.nix
./sleep-nag.nix
];
m-0 = {
workspaces = [
"tasks"
@ -69,154 +76,4 @@ in {
Unit.Requires = [ "dbus.service" ];
Install.WantedBy = [ "default.target" ];
};
xdg.configFile."sway/config".text = builtins.readFile ./sway.config + (let
inherit (config.m-0) colors workspaces terminal;
swayColors = {
focused = {
background = colors.blue;
border = colors.blue;
childBorder = colors.blue;
indicator = colors.green;
text = colors.foreground;
};
focused_inactive = {
background = colors.background;
border = colors.background;
childBorder = colors.background;
indicator = colors.green;
text = colors.foreground;
};
unfocused = {
background = colors.background;
border = colors.background;
childBorder = colors.background;
indicator = colors.green;
text = colors.foreground;
};
urgent = {
background = colors.red;
border = colors.red;
childBorder = colors.red;
indicator = colors.green;
text = colors.foreground;
};
};
barColors = {
active_workspace = {
background = colors.blue;
border = colors.blue;
text = colors.white;
};
binding_mode = {
background = colors.red;
border = colors.red;
text = colors.white;
};
focused_workspace = {
background = colors.blue;
border = colors.blue;
text = colors.white;
};
inactive_workspace = {
background = colors.background;
border = colors.background;
text = colors.white;
};
};
bindings = {
"XF86AudioMute" = "exec pactl set-sink-mute '@DEFAULT_SINK@' toggle";
"XF86AudioLowerVolume" =
"exec pactl set-sink-volume '@DEFAULT_SINK@' -5%";
"XF86AudioRaiseVolume" =
"exec pactl set-sink-volume '@DEFAULT_SINK@' +5%";
"XF86AudioMicMute" =
"exec pactl set-source-mute '@DEFAULT_SOURCE@' toggle";
"XF86MonBrightnessUp" =
"exec ${pkgs.brightnessctl}/bin/brightnessctl +5%";
"XF86MonBrightnessDown" =
"exec ${pkgs.brightnessctl}/bin/brightnessctl +5%";
"Tab" = "exec ${pkgs.skippy-xd}/bin/skippy-xd";
"Left" = "focus left";
"Down" = "focus down";
"Up" = "focus up";
"Right" = "focus right";
"Shift+Left" = "move left";
"Shift+Down" = "move down";
"Shift+Up" = "move up";
"Shift+Right" = "move right";
"d" = "splith";
"t" = "layout tabbed";
"s" = "layout toggle split";
"f" = "fullscreen";
"Shift+space" = "floating toggle";
"prior" = "focus parent";
"next" = "focus child";
"shift+q" =
"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'";
"Return" = "exec ${terminal}";
"q" = "kill";
"space" = "exec hotkeys";
"m" = "bar mode toggle monitoring";
};
workspaceBindings = builtins.foldl' (bindings: name:
let
number = toString ((builtins.length (builtins.attrNames bindings)) / 2);
in bindings // {
"${number}" = "workspace ${number}:${name}";
"Shift+${number}" = "move container to workspace ${number}:${name}";
}) { } workspaces;
bindingsConfig = lib.concatStringsSep "\n" (lib.mapAttrsToList
(binding: command: ''
bindsym $mod+${binding} ${command}
'') (bindings // workspaceBindings));
in bindingsConfig + (lib.concatStringsSep "\n" (lib.mapAttrsToList (category:
{ border, background, text, indicator, childBorder }: ''
client.${category} ${border}a0 ${background}c0 ${text} ${indicator} ${childBorder}
'') swayColors)) + ''
bar {
status_command i3status-rs ${./status.toml};
status_padding 0
status_edge_padding 0
font monospace 9.5
height 17
strip_workspace_numbers yes
mode hide
colors {
statusline #ffffff
background #00000000
${
lib.concatStringsSep "\n" (lib.mapAttrsToList (category:
{ background, border, text }: ''
${category} ${background}cc ${border} ${text}
'') barColors)
}
}
}
bar {
id monitoring
status_command i3status-rs ${./status-monitoring.toml};
status_padding 0
status_edge_padding 0
font monospace 9.5
height 17
workspace_buttons no
position top
modifier none
mode invisible
colors {
statusline #ffffff
background #00000000
${
lib.concatStringsSep "\n" (lib.mapAttrsToList (category:
{ background, border, text }: ''
${category} ${background}cc ${border} ${text}
'') barColors)
}
}
}
'');
}

View file

@ -1,15 +1,15 @@
set $mod Mod4
set $term ate
set $lock swaylock -e -F -l -s fill -f -i ~/.wallpaper.jpg
set $lock swaylock -e -F -l -s fill -f -i ~/volatile/wallpaper.jpg
exec my-ssh-add
exec systemctl --user set-environment SWAYSOCK="$SWAYSOCK"
exec swayidle -w \
timeout 600 '$lock' \
timeout 570 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"' \
before-sleep '$lock'
output * bg ~/.wallpaper.jpg fill
output * bg ~/volatile/wallpaper.jpg fill
input type:keyboard {
xkb_layout de
@ -24,5 +24,3 @@ titlebar_padding 1
font monospace 9.5
default_border pixel 1
floating_modifier $mod normal
bindsym ctrl+escape exec $lock

165
home/desktop/sway.nix Normal file
View file

@ -0,0 +1,165 @@
{ pkgs, lib, config, ... }:
let my-pkgs = import ../../pkgs;
in {
xdg.configFile."sway/config".text = builtins.readFile ./sway.config + (let
inherit (config.m-0) colors workspaces terminal;
swayColors = {
focused = {
background = colors.blue;
border = colors.blue;
childBorder = colors.blue;
indicator = colors.green;
text = colors.foreground;
};
focused_inactive = {
background = colors.background;
border = colors.background;
childBorder = colors.background;
indicator = colors.green;
text = colors.foreground;
};
unfocused = {
background = colors.background;
border = colors.background;
childBorder = colors.background;
indicator = colors.green;
text = colors.foreground;
};
urgent = {
background = colors.red;
border = colors.red;
childBorder = colors.red;
indicator = colors.green;
text = colors.foreground;
};
};
barColors = {
active_workspace = {
background = colors.blue;
border = colors.blue;
text = colors.white;
};
binding_mode = {
background = colors.red;
border = colors.red;
text = colors.white;
};
focused_workspace = {
background = colors.blue;
border = colors.blue;
text = colors.white;
};
inactive_workspace = {
background = colors.background;
border = colors.background;
text = colors.white;
};
};
modlessBindings = {
"ctrl+escape" = "exec $lock";
"XF86AudioMute" = "exec pactl set-sink-mute '@DEFAULT_SINK@' toggle";
"XF86AudioLowerVolume" =
"exec pactl set-sink-volume '@DEFAULT_SINK@' -5%";
"XF86AudioRaiseVolume" =
"exec pactl set-sink-volume '@DEFAULT_SINK@' +5%";
"XF86AudioMicMute" =
"exec pactl set-source-mute '@DEFAULT_SOURCE@' toggle";
"XF86MonBrightnessUp" =
"exec ${pkgs.brightnessctl}/bin/brightnessctl s 5%+";
"XF86MonBrightnessDown" =
"exec ${pkgs.brightnessctl}/bin/brightnessctl s 5%-";
};
bindings = {
"Left" = "focus left";
"Down" = "focus down";
"Up" = "focus up";
"Right" = "focus right";
"Shift+Left" = "move left";
"Shift+Down" = "move down";
"Shift+Up" = "move up";
"Shift+Right" = "move right";
"d" = "splith";
"t" = "layout tabbed";
"s" = "layout toggle split";
"f" = "fullscreen";
"Shift+space" = "floating toggle";
"prior" = "focus parent";
"next" = "focus child";
"shift+q" =
"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'";
"Return" = "exec ${terminal}";
"q" = "kill";
"space" = "exec hotkeys";
"m" = "bar mode toggle monitoring";
};
workspaceBindings = builtins.foldl' (bindings: name:
let
number = toString ((builtins.length (builtins.attrNames bindings)) / 2);
in bindings // {
"${number}" = "workspace ${number}:${name}";
"Shift+${number}" = "move container to workspace ${number}:${name}";
}) { } workspaces;
modlessBindingsConfig = lib.concatStringsSep "\n" (lib.mapAttrsToList
(binding: command: ''
bindsym ${binding} ${command}
'') modlessBindings);
bindingsConfig = lib.concatStringsSep "\n" (lib.mapAttrsToList
(binding: command: ''
bindsym $mod+${binding} ${command}
'') (bindings // workspaceBindings));
colorConfig = lib.concatStringsSep "\n" (lib.mapAttrsToList (category:
{ border, background, text, indicator, childBorder }: ''
client.${category} ${border}a0 ${background}c0 ${text} ${indicator} ${childBorder}
'') swayColors);
barsConfig = ''
bar {
status_command i3status-rs ${./status.toml};
status_padding 0
status_edge_padding 0
font monospace 9.5
height 17
strip_workspace_numbers yes
mode hide
colors {
statusline #ffffff
background #00000000
${
lib.concatStringsSep "\n" (lib.mapAttrsToList (category:
{ background, border, text }: ''
${category} ${background}cc ${border} ${text}
'') barColors)
}
}
}
bar {
id monitoring
status_command i3status-rs ${./status-monitoring.toml};
status_padding 0
status_edge_padding 0
font monospace 9.5
height 17
workspace_buttons no
position top
modifier none
mode invisible
colors {
statusline #ffffff
background #00000000
${
lib.concatStringsSep "\n" (lib.mapAttrsToList (category:
{ background, border, text }: ''
${category} ${background}cc ${border} ${text}
'') barColors)
}
}
}
exec ${my-pkgs.my-ssh-add}/bin/my-ssh-add
exec xrdb -load ${builtins.toFile "Xresources" "Xft.dpi: 96"}
'';
in bindingsConfig + modlessBindingsConfig + colorConfig + barsConfig);
}

View file

@ -0,0 +1,26 @@
{ lib, pkgs, config, ... }:
let
inherit (import ../../lib) writeHaskellScript;
randomWallpaper = writeHaskellScript {
name = "random-wallpaper";
imports = [ "System.Random" "Control.Concurrent" ];
bins = [ pkgs.coreutils pkgs.sway ];
} ''
main = forever $ do
files <- fmap (lines . decodeUtf8) $ ls "/home/maralorn/.wallpapers" |> captureTrim
file <- fmap (files Prelude.!!) $ getStdRandom $ randomR (0, length files - 1)
cp ([i|/home/maralorn/.wallpapers/#{file}|] :: String) "/home/maralorn/volatile/wallpaper.jpg"
swaymsg "output * bg /home/maralorn/volatile/wallpaper.jpg fill"
threadDelay 300000000
'';
in {
systemd.user = {
services.random-wallpaper = {
Unit = { Description = "Random Wallpaper"; };
Service = { ExecStart = "${randomWallpaper}/bin/random-wallpaper"; };
Install = { WantedBy = [ "graphical-session.target" ]; };
};
};
}

View file

@ -2,7 +2,7 @@
let
inherit (import ../lib) writeHaskellScript get-niv-path gcRetentionDays;
inherit (import ../lib/update-home.nix) update-home;
configPath = "/home/${config.home.username}/git/nixos/config";
configPath = "/home/${config.home.username}/git/config";
home-maintenance = writeHaskellScript {
name = "home-maintenance";
imports = [ ];

View file

@ -10,7 +10,14 @@
save = 100000;
size = 100000;
};
initExtra = builtins.readFile ./zshrc + ''
initExtra = ''
# If running from tty1 start sway
if [ "$(tty)" = "/dev/tty1" ]; then
. ${my-pkgs.start-ssh-agent}/bin/start-ssh-agent
exec ${pkgs.sway}/bin/sway
fi
${builtins.readFile ./zshrc}
GITSTATUS_DAEMON=${my-pkgs.gitstatus}/bin/gitstatusd source ${
./p10k.zsh
}

View file

@ -1,9 +1,3 @@
# If running from tty1 start sway
if [ "$(tty)" = "/dev/tty1" ]; then
. start-ssh-agent
exec sway
fi
# If not in a tmux, start tmux
if [[ -z "$TMUX" ]] {
session=$(tmux ls | grep -v attached | head -1 | cut -f1 -d:)
@ -31,15 +25,13 @@ precmd() {
fi
}
alias accounting='hledger -f ~/git/buchhaltung/buchhaltung.ledger ui -- --watch --theme=terminal -T -E'
alias o=xdg-open
alias c=cdr
alias sudo='sudo -A'
alias s='sudo -A systemctl'
alias u='systemctl --user'
alias m=man
alias t="tmux attach"
alias tn="tmux new-session"
alias w="develop-here"
alias ls='exa -lh --git'
autoload -Uz chpwd_recent_dirs cdr add-zsh-hook

View file

@ -32,7 +32,7 @@ in rec {
};
};
start-agent = pkgs.writeShellScriptBin "start-ssh-agent" ''
start-ssh-agent = pkgs.writeShellScriptBin "start-ssh-agent" ''
${pkgs.psmisc}/bin/killall -q ssh-agent
eval `${pkgs.openssh}/bin/ssh-agent -s`
systemctl --user set-environment SSH_AUTH_SOCK="$SSH_AUTH_SOCK"
@ -110,7 +110,7 @@ in rec {
laptop-home-pkgs = {
maintenance = pkgs.writeShellScriptBin "maintenance" ''
git -C ~/git/nixos/config pull
git -C ~/git/config pull
update-home
sudo -A update-system
#sudo -A nix-collect-garbage --delete-older-than ${
@ -211,11 +211,12 @@ in rec {
fi
'';
desktop-pkgs = {
inherit urxvt terminal ate start-agent my-ssh-add;
inherit urxvt terminal ate;
inherit (pkgs.gnome3) dconf;
inherit (pkgs)
lm_sensors sway swaylock swayidle xwayland rofi i3status-rust waybar
dmenu;
lm_sensors sway swaylock swayidle xwayland rofi i3status-rust waybar dmenu
xdg_utils;
inherit (unstable) wofi;
};
home-pkgs = {
@ -228,7 +229,7 @@ in rec {
};
accounting-pkgs = {
jali = pkgs.callPackage ./jali { };
inherit (pkgs.haskellPackages) hledger hledger-ui;
inherit (pkgs.haskellPackages) hledger hledger-ui hledger-web;
inherit (pkgs) ledger;
};
system-pkgs = core-system-pkgs // extra-system-pkgs // {