i3/desktop: Split out
This commit is contained in:
parent
2ad4bee0f9
commit
d994dfb9fb
|
@ -55,7 +55,6 @@
|
|||
|
||||
# Imported from scripts
|
||||
rms = ''${pkgs.findutils}/bin/find . -name "*.sync-conflict-*" -delete''; # Remove syncthing conflict files
|
||||
pw = ''${pkgs.pwgen}/bin/pwgen 32 -y''; # Generate passwords. ln((26*2+10)**32)/ln(2) ≅ 190 bits of entropy
|
||||
newestFile = ''${pkgs.findutils}/bin/find -type f -printf '%T+ %p\n' | sort | tail'';
|
||||
oldestFile = ''${pkgs.findutils}/bin/find -type f -printf '%T+ %p\n' | sort | head'';
|
||||
};
|
||||
|
@ -125,7 +124,6 @@
|
|||
};
|
||||
tmux.enable = true;
|
||||
translate-shell.enable = true; # TODO Cool config?
|
||||
password-store.enable = true;
|
||||
};
|
||||
home = {
|
||||
activation = {
|
||||
|
@ -184,10 +182,6 @@
|
|||
sox
|
||||
imagemagick
|
||||
numbat
|
||||
|
||||
# password
|
||||
pwgen
|
||||
|
||||
];
|
||||
sessionVariables = {
|
||||
# Favourite commands
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
./monitoring
|
||||
./nix
|
||||
./pager
|
||||
./password
|
||||
./prompt
|
||||
./rebuild
|
||||
./shell
|
||||
|
|
22
hm/desktop/audio/default.nix
Normal file
22
hm/desktop/audio/default.nix
Normal file
|
@ -0,0 +1,22 @@
|
|||
{ pkgs, lib, config, ... }:
|
||||
let
|
||||
pactl = "exec ${pkgs.pulseaudio}/bin/pactl"; # TODO Use NixOS package if using NixOS
|
||||
mod = config.xsession.windowManager.i3.config.modifier;
|
||||
in
|
||||
{
|
||||
config = lib.mkIf config.frogeye.desktop.xorg {
|
||||
home.packages = with pkgs; [
|
||||
pavucontrol # Because can't use Win+F1X on Pinebook 🙃
|
||||
];
|
||||
xsession.windowManager.i3.config.keybindings =
|
||||
{
|
||||
"XF86AudioRaiseVolume" = "${pactl} set-sink-mute @DEFAULT_SINK@ false; ${pactl} set-sink-volume @DEFAULT_SINK@ +5%";
|
||||
"XF86AudioLowerVolume" = "${pactl} set-sink-mute @DEFAULT_SINK@ false; ${pactl} set-sink-volume @DEFAULT_SINK@ -5%";
|
||||
"XF86AudioMute" = "${pactl} set-sink-mute @DEFAULT_SINK@ true";
|
||||
"${mod}+F7" = "${pactl} suspend-sink @DEFAULT_SINK@ 1; ${pactl} suspend-sink @DEFAULT_SINK@ 0"; # Re-synchronize bluetooth headset
|
||||
"${mod}+F11" = "exec ${pkgs.pavucontrol}/bin/pavucontrol";
|
||||
"${mod}+F12" = "exec ${pkgs.pavucontrol}/bin/pavucontrol";
|
||||
# TODO Find pacmixer?
|
||||
};
|
||||
};
|
||||
}
|
|
@ -5,9 +5,13 @@ let
|
|||
in
|
||||
{
|
||||
imports = [
|
||||
./audio
|
||||
./frobar
|
||||
./i3.nix
|
||||
./lock
|
||||
./mpd
|
||||
./qutebrowser.nix
|
||||
./screenshots
|
||||
];
|
||||
config = lib.mkIf config.frogeye.desktop.xorg {
|
||||
xsession = {
|
||||
|
@ -154,9 +158,6 @@ in
|
|||
publicShare = null;
|
||||
templates = null;
|
||||
videos = "${config.home.homeDirectory}/Vidéos";
|
||||
extraConfig = {
|
||||
XDG_SCREENSHOTS_DIR = "${config.home.homeDirectory}/Screenshots";
|
||||
};
|
||||
};
|
||||
configFile = {
|
||||
"pulse/client.conf" = {
|
||||
|
@ -222,17 +223,6 @@ in
|
|||
};
|
||||
};
|
||||
};
|
||||
mpd = {
|
||||
enable = true;
|
||||
network = {
|
||||
listenAddress = "0.0.0.0"; # So it can be controlled from home
|
||||
# TODO ... and whoever is the Wi-Fi network I'm using, which, not great
|
||||
startWhenNeeded = true;
|
||||
};
|
||||
extraConfig = ''
|
||||
restore_paused "yes"
|
||||
'';
|
||||
};
|
||||
autorandr.enable = true;
|
||||
};
|
||||
|
||||
|
@ -249,11 +239,6 @@ in
|
|||
# remote
|
||||
tigervnc
|
||||
|
||||
# music
|
||||
mpc-cli
|
||||
ashuffle
|
||||
vimpc
|
||||
|
||||
# multimedia common
|
||||
gimp
|
||||
inkscape
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ pkgs ? import <nixpkgs> { config = { }; overlays = [ ]; }, ... }:
|
||||
{ pkgs ? import <nixpkgs> { config = { }; overlays = [ ]; }, lib, config, ... }:
|
||||
# Tried using pyproject.nix but mpd2 dependency wouldn't resolve,
|
||||
# is called pyton-mpd2 on PyPi but mpd2 in nixpkgs.
|
||||
let
|
||||
|
@ -22,7 +22,7 @@ let
|
|||
};
|
||||
in
|
||||
{
|
||||
config = {
|
||||
config = lib.mkIf config.frogeye.desktop.xorg {
|
||||
xsession.windowManager.i3.config.bars = [ ];
|
||||
programs.autorandr.hooks.postswitch = {
|
||||
frobar = "${pkgs.systemd}/bin/systemctl --user restart frobar";
|
||||
|
|
|
@ -1,37 +1,5 @@
|
|||
{ pkgs, lib, config, ... }:
|
||||
let
|
||||
# LOCKER
|
||||
# lockColors = with config.lib.stylix.colors.withHashtag; { a = base00; b = base01; d = base00; }; # Black or White, depending on current theme
|
||||
# lockColors = with config.lib.stylix.colors.withHashtag; { a = base0A; b = base0B; d = base00; }; # Green + Yellow
|
||||
lockColors = { a = "#82a401"; b = "#466c01"; d = "#648901"; }; # Old
|
||||
lockSvg = pkgs.writeText "lock.svg" "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 50 50\" height=\"50\" width=\"50\"><path fill=\"${lockColors.a}\" d=\"M0 50h50V0H0z\"/><path d=\"M0 0l50 50H25L0 25zm50 0v25L25 0z\" fill=\"${lockColors.b}\"/></svg>";
|
||||
lockPng = pkgs.runCommand "lock.png" { } "${pkgs.imagemagick}/bin/convert ${lockSvg} $out";
|
||||
locker = pkgs.writeShellScript "i3-locker" ''
|
||||
# Remove SSH and GPG keys from keystores
|
||||
${pkgs.openssh}/bin/ssh-add -D
|
||||
echo RELOADAGENT | ${pkgs.gnupg}/bin/gpg-connect-agent
|
||||
${pkgs.coreutils}/bin/rm -rf "/tmp/cached_pass_$UID"
|
||||
|
||||
${pkgs.lightdm}/bin/dm-tool lock
|
||||
# TODO Does that work for all DMs?
|
||||
# TODO Might want to use i3lock on NixOS configs still?
|
||||
if [ $? -ne 0 ]; then
|
||||
if [ -d ${config.xdg.cacheHome}/lockpatterns ]
|
||||
then
|
||||
pattern=$(${pkgs.findutils} ${config.xdg.cacheHome}/lockpatterns | sort -R | head -1)
|
||||
else
|
||||
pattern=${lockPng}
|
||||
fi
|
||||
revert() {
|
||||
${pkgs.xorg.xset}/bin/xset dpms 0 0 0
|
||||
}
|
||||
trap revert SIGHUP SIGINT SIGTERM
|
||||
${pkgs.xorg.xset}/bin/xset dpms 5 5 5
|
||||
${pkgs.i3lock}/bin/i3lock --nofork --color ${builtins.substring 1 6 lockColors.d} --image=$pattern --tiling --ignore-empty-password
|
||||
revert
|
||||
fi
|
||||
'';
|
||||
|
||||
# FOCUS
|
||||
focus = "exec ${ pkgs.writeShellScript "i3-focus-window" ''
|
||||
WINDOW=`${pkgs.xdotool}/bin/xdotool getwindowfocus`
|
||||
|
@ -75,9 +43,6 @@ in
|
|||
let
|
||||
mod = config.xsession.windowManager.i3.config.modifier;
|
||||
rofi = "exec --no-startup-id ${config.programs.rofi.package}/bin/rofi";
|
||||
pactl = "exec ${pkgs.pulseaudio}/bin/pactl"; # TODO Use NixOS package if using NixOS
|
||||
screenshots_dir = config.xdg.userDirs.extraConfig.XDG_SCREENSHOTS_DIR;
|
||||
scrot = "${pkgs.scrot}/bin/scrot --exec '${pkgs.coreutils}/bin/mv $f ${screenshots_dir}/ && ${pkgs.optipng}/bin/optipng ${screenshots_dir}/$f'";
|
||||
in
|
||||
{
|
||||
# Compatibility layer for people coming from other backgrounds
|
||||
|
@ -88,9 +53,6 @@ in
|
|||
"${mod}+z" = "kill";
|
||||
button2 = "kill";
|
||||
# Rofi
|
||||
"${mod}+c" = "exec --no-startup-id ${config.programs.rofi.pass.package}/bin/rofi-pass --last-used";
|
||||
# TODO Try autopass.cr
|
||||
# 23.11 config.programs.rofi.pass.package
|
||||
"${mod}+i" = "exec --no-startup-id ${pkgs.rofimoji}/bin/rofimoji";
|
||||
"${mod}+plus" = "${rofi} -modi ssh -show ssh";
|
||||
"${mod}+ù" = "${rofi} -modi ssh -show ssh -ssh-command '{terminal} -e {ssh-client} {host} -t \"sudo -s -E\"'";
|
||||
|
@ -107,18 +69,6 @@ in
|
|||
}";
|
||||
"${mod}+Shift+Return" = "exec ${config.programs.urxvt.package}/bin/urxvt";
|
||||
"${mod}+p" = "exec ${pkgs.xfce.thunar}/bin/thunar";
|
||||
# Volume control
|
||||
"XF86AudioRaiseVolume" = "${pactl} set-sink-mute @DEFAULT_SINK@ false; ${pactl} set-sink-volume @DEFAULT_SINK@ +5%";
|
||||
"XF86AudioLowerVolume" = "${pactl} set-sink-mute @DEFAULT_SINK@ false; ${pactl} set-sink-volume @DEFAULT_SINK@ -5%";
|
||||
"XF86AudioMute" = "${pactl} set-sink-mute @DEFAULT_SINK@ true";
|
||||
"${mod}+F7" = "${pactl} suspend-sink @DEFAULT_SINK@ 1; ${pactl} suspend-sink @DEFAULT_SINK@ 0"; # Re-synchronize bluetooth headset
|
||||
"${mod}+F11" = "exec ${pkgs.pavucontrol}/bin/pavucontrol";
|
||||
"${mod}+F12" = "exec ${pkgs.pavucontrol}/bin/pavucontrol";
|
||||
# TODO Find pacmixer?
|
||||
# Media control
|
||||
"XF86AudioPrev" = "exec ${pkgs.mpc-cli}/bin/mpc prev";
|
||||
"XF86AudioPlay" = "exec ${pkgs.mpc-cli}/bin/mpc toggle";
|
||||
"XF86AudioNext" = "exec ${pkgs.mpc-cli}/bin/mpc next";
|
||||
# Backlight
|
||||
"XF86MonBrightnessUp" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set +5%";
|
||||
"XF86MonBrightnessDown" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set 5%-";
|
||||
|
@ -129,11 +79,6 @@ in
|
|||
${pkgs.libgnomekbd}/bin/gkbd-keyboard-display -l $layout
|
||||
''
|
||||
}";
|
||||
# Screenshots
|
||||
"Print" = "exec ${scrot} --focused";
|
||||
"${mod}+Print" = "exec ${scrot}";
|
||||
"Ctrl+Print" = "exec ${pkgs.coreutils}/bin/sleep 1 && ${scrot} --select";
|
||||
# TODO Try using bindsym --release instead of sleep
|
||||
# change focus
|
||||
"${mod}+h" = "focus left; ${focus}";
|
||||
"${mod}+j" = "focus down; ${focus}";
|
||||
|
@ -212,11 +157,6 @@ in
|
|||
"${mod}+Shift+c" = "reload";
|
||||
"${mod}+Shift+r" = "restart";
|
||||
"${mod}+Shift+e" = "exit";
|
||||
# Screen off commands
|
||||
"${mod}+F1" = "exec --no-startup-id ${pkgs.bash}/bin/sh -c \"${pkgs.coreutils}/bin/sleep .25 && ${pkgs.xorg.xset}/bin/xset dpms force off\"";
|
||||
# TODO --release?
|
||||
"${mod}+F4" = "exec --no-startup-id ${pkgs.xautolock}/bin/xautolock -disable";
|
||||
"${mod}+F5" = "exec --no-startup-id ${pkgs.xautolock}/bin/xautolock -enable";
|
||||
# Modes
|
||||
"${mod}+Escape" = "mode ${mode_system}";
|
||||
"${mod}+r" = "mode ${mode_resize}";
|
||||
|
@ -224,16 +164,17 @@ in
|
|||
"${mod}+t" = "mode ${mode_screen}";
|
||||
"${mod}+y" = "mode ${mode_temp}";
|
||||
};
|
||||
# TOOD Config option so we don't have to separate name and binding
|
||||
modes = let return_bindings = {
|
||||
"Return" = "mode default";
|
||||
"Escape" = "mode default";
|
||||
}; in
|
||||
{
|
||||
"${mode_system}" = {
|
||||
"l" = "exec --no-startup-id exec ${locker}, mode default";
|
||||
"l" = "exec --no-startup-id exec xlock, mode default";
|
||||
"e" = "exit, mode default";
|
||||
"s" = "exec --no-startup-id exec ${locker} & ${pkgs.systemd}/bin/systemctl suspend --check-inhibitors=no, mode default";
|
||||
"h" = "exec --no-startup-id exec ${locker} & ${pkgs.systemd}/bin/systemctl hibernate, mode default";
|
||||
"s" = "exec --no-startup-id exec xlock & ${pkgs.systemd}/bin/systemctl suspend --check-inhibitors=no, mode default";
|
||||
"h" = "exec --no-startup-id exec xlock & ${pkgs.systemd}/bin/systemctl hibernate, mode default";
|
||||
"r" = "exec --no-startup-id ${pkgs.systemd}/bin/systemctl reboot, mode default";
|
||||
"p" = "exec --no-startup-id ${pkgs.systemd}/bin/systemctl poweroff -i, mode default";
|
||||
} // return_bindings;
|
||||
|
@ -294,14 +235,11 @@ in
|
|||
};
|
||||
floating = {
|
||||
criteria = [
|
||||
{ title = "pacmixer"; }
|
||||
{ window_role = "pop-up"; }
|
||||
{ window_role = "task_dialog"; }
|
||||
];
|
||||
};
|
||||
startup = [
|
||||
# Lock screen after 10 minutes
|
||||
{ notification = false; command = "${pkgs.xautolock}/bin/xautolock -time 10 -locker '${pkgs.xorg.xset}/bin/xset dpms force standby' -killtime 1 -killer ${locker}"; }
|
||||
{
|
||||
notification = false;
|
||||
command = "${pkgs.writeShellApplication {
|
||||
|
@ -312,7 +250,6 @@ in
|
|||
# TODO Only on computers with battery
|
||||
}}/bin/batteryNotify";
|
||||
}
|
||||
# TODO There's a services.screen-locker.xautolock but not sure it can match the above command
|
||||
];
|
||||
workspaceLayout = "tabbed";
|
||||
focus.mouseWarping = true; # i3 only supports warping to workspace, hence ${focus}
|
||||
|
|
64
hm/desktop/lock/default.nix
Normal file
64
hm/desktop/lock/default.nix
Normal file
|
@ -0,0 +1,64 @@
|
|||
{ pkgs, lib, config, ... }:
|
||||
let
|
||||
# lockColors = with config.lib.stylix.colors.withHashtag; { a = base00; b = base01; d = base00; }; # Black or White, depending on current theme
|
||||
# lockColors = with config.lib.stylix.colors.withHashtag; { a = base0A; b = base0B; d = base00; }; # Green + Yellow
|
||||
lockColors = { a = "#82a401"; b = "#466c01"; d = "#648901"; }; # Old
|
||||
lockSvg = pkgs.writeText "lock.svg" ''
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" height="50" width="50">
|
||||
<path fill="${lockColors.a}" d="M0 50h50V0H0z"/>
|
||||
<path d="M0 0l50 50H25L0 25zm50 0v25L25 0z" fill="${lockColors.b}"/>
|
||||
</svg>
|
||||
'';
|
||||
lockPng = pkgs.runCommand "lock.png" { } "${pkgs.imagemagick}/bin/convert ${lockSvg} $out";
|
||||
mod = config.xsession.windowManager.i3.config.modifier;
|
||||
in
|
||||
{
|
||||
config = lib.mkIf config.frogeye.desktop.xorg {
|
||||
home.packages = with pkgs; [
|
||||
(pkgs.writeShellApplication {
|
||||
name = "xlock";
|
||||
text = ''
|
||||
# Remove SSH and GPG keys from keystores
|
||||
${pkgs.openssh}/bin/ssh-add -D
|
||||
echo RELOADAGENT | ${pkgs.gnupg}/bin/gpg-connect-agent
|
||||
${pkgs.coreutils}/bin/rm -rf "/tmp/cached_pass_$UID"
|
||||
# TODO Should probably be an option and defined where relevant?
|
||||
# TODO Maybe we could have a terminal lock? With vlock.
|
||||
|
||||
# TODO Does that work for all DMs?
|
||||
# TODO Might want to use i3lock on NixOS configs still?
|
||||
if ! ${pkgs.lightdm}/bin/dm-tool lock
|
||||
then
|
||||
if [ -d ${config.xdg.cacheHome}/lockpatterns ]
|
||||
then
|
||||
pattern=$(${pkgs.findutils} ${config.xdg.cacheHome}/lockpatterns | sort -R | head -1)
|
||||
else
|
||||
pattern=${lockPng}
|
||||
fi
|
||||
revert() {
|
||||
${pkgs.xorg.xset}/bin/xset dpms 0 0 0
|
||||
}
|
||||
trap revert SIGHUP SIGINT SIGTERM
|
||||
${pkgs.xorg.xset}/bin/xset dpms 5 5 5
|
||||
${pkgs.i3lock}/bin/i3lock --nofork --color ${builtins.substring 1 6 lockColors.d} --image="$pattern" --tiling --ignore-empty-password
|
||||
revert
|
||||
fi
|
||||
'';
|
||||
})
|
||||
];
|
||||
xsession.windowManager.i3.config = {
|
||||
keybindings = {
|
||||
# Screen off commands
|
||||
"${mod}+F1" = "exec --no-startup-id ${pkgs.bash}/bin/sh -c \"${pkgs.coreutils}/bin/sleep .25 && ${pkgs.xorg.xset}/bin/xset dpms force off\"";
|
||||
# TODO --release?
|
||||
"${mod}+F4" = "exec --no-startup-id ${pkgs.xautolock}/bin/xautolock -disable";
|
||||
"${mod}+F5" = "exec --no-startup-id ${pkgs.xautolock}/bin/xautolock -enable";
|
||||
};
|
||||
startup = [
|
||||
# Lock screen after 10 minutes
|
||||
{ notification = false; command = "${pkgs.xautolock}/bin/xautolock -time 10 -locker '${pkgs.xorg.xset}/bin/xset dpms force standby' -killtime 1 -killer xlock"; }
|
||||
# TODO There's a services.screen-locker.xautolock but not sure it can match the above command
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
27
hm/desktop/mpd/default.nix
Normal file
27
hm/desktop/mpd/default.nix
Normal file
|
@ -0,0 +1,27 @@
|
|||
{ pkgs, lib, config, ... }:
|
||||
{
|
||||
config = lib.mkIf config.frogeye.desktop.xorg {
|
||||
home.packages = with pkgs; [
|
||||
ashuffle
|
||||
mpc-cli
|
||||
vimpc
|
||||
];
|
||||
services.mpd = {
|
||||
enable = true;
|
||||
network = {
|
||||
listenAddress = "0.0.0.0"; # So it can be controlled from home
|
||||
# TODO ... and whoever is the Wi-Fi network I'm using, which, not great
|
||||
startWhenNeeded = true;
|
||||
};
|
||||
extraConfig = ''
|
||||
restore_paused "yes"
|
||||
'';
|
||||
};
|
||||
xsession.windowManager.i3.config.keybindings =
|
||||
{
|
||||
"XF86AudioPrev" = "exec ${pkgs.mpc-cli}/bin/mpc prev";
|
||||
"XF86AudioPlay" = "exec ${pkgs.mpc-cli}/bin/mpc toggle";
|
||||
"XF86AudioNext" = "exec ${pkgs.mpc-cli}/bin/mpc next";
|
||||
};
|
||||
};
|
||||
}
|
17
hm/desktop/screenshots/default.nix
Normal file
17
hm/desktop/screenshots/default.nix
Normal file
|
@ -0,0 +1,17 @@
|
|||
{ pkgs, lib, config, ... }:
|
||||
let
|
||||
dir = config.xdg.userDirs.extraConfig.XDG_SCREENSHOTS_DIR;
|
||||
scrot = "${pkgs.scrot}/bin/scrot --exec '${pkgs.coreutils}/bin/mv $f ${dir}/ && ${pkgs.optipng}/bin/optipng ${dir}/$f'";
|
||||
mod = config.xsession.windowManager.i3.config.modifier;
|
||||
in
|
||||
{
|
||||
config = lib.mkIf config.frogeye.desktop.xorg {
|
||||
xdg.userDirs.extraConfig.XDG_SCREENSHOTS_DIR = "${config.home.homeDirectory}/Screenshots";
|
||||
xsession.windowManager.i3.config.keybindings = {
|
||||
"Print" = "exec ${scrot} --focused";
|
||||
"${mod}+Print" = "exec ${scrot}";
|
||||
"Ctrl+Print" = "exec ${pkgs.coreutils}/bin/sleep 1 && ${scrot} --select";
|
||||
# TODO Try using bindsym --release instead of sleep
|
||||
};
|
||||
};
|
||||
}
|
19
hm/password/default.nix
Normal file
19
hm/password/default.nix
Normal file
|
@ -0,0 +1,19 @@
|
|||
{ pkgs, lib, config, ... }:
|
||||
let
|
||||
mod = config.xsession.windowManager.i3.config.modifier;
|
||||
in
|
||||
{
|
||||
config = {
|
||||
home.packages = with pkgs; [
|
||||
pwgen
|
||||
];
|
||||
programs = {
|
||||
bash.shellAliases = {
|
||||
pw = ''${pkgs.pwgen}/bin/pwgen 32 -y''; # Generate passwords. ln((26*2+10)**32)/ln(2) ≅ 190 bits of entropy
|
||||
};
|
||||
password-store.enable = true;
|
||||
};
|
||||
xsession.windowManager.i3.config.keybindings."${mod}+c" = "exec --no-startup-id ${config.programs.rofi.pass.package}/bin/rofi-pass --last-used";
|
||||
# TODO Try autopass.cr
|
||||
};
|
||||
}
|
|
@ -39,6 +39,7 @@
|
|||
hardware = {
|
||||
bluetooth.enable = true;
|
||||
pulseaudio.enable = true;
|
||||
# TODO Try pipewire
|
||||
};
|
||||
|
||||
# UPST
|
||||
|
|
Loading…
Reference in a new issue