Better BSPWM binding

This commit is contained in:
Filippo Berto 2022-12-26 13:43:38 +01:00
parent 8ad70a9ada
commit 1f8c424512
No known key found for this signature in database
GPG key ID: FE98AE5EC52B1056
7 changed files with 43 additions and 37 deletions

11
flake.lock generated
View file

@ -114,19 +114,22 @@
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
],
"utils": [
"flake-utils"
] ]
}, },
"locked": { "locked": {
"lastModified": 1667907331, "lastModified": 1670253003,
"narHash": "sha256-bHkAwkYlBjkupPUFcQjimNS8gxWSWjOTevEuwdnp5m0=", "narHash": "sha256-/tJIy4+FbsQyslq1ipyicZ2psOEd8dvl4OJ9lfisjd0=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "6639e3a837fc5deb6f99554072789724997bc8e5", "rev": "0e8125916b420e41bf0d23a0aa33fadd0328beb3",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nix-community", "owner": "nix-community",
"ref": "release-22.05", "ref": "release-22.11",
"repo": "home-manager", "repo": "home-manager",
"type": "github" "type": "github"
} }

View file

@ -4,7 +4,7 @@
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/release-22.11"; nixpkgs.url = "github:NixOS/nixpkgs/release-22.11";
nixpkgs-u.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs-u.url = "github:NixOS/nixpkgs/nixos-unstable";
home-manager = { url = "github:nix-community/home-manager/release-22.05"; inputs.nixpkgs.follows = "nixpkgs"; }; home-manager = { url = "github:nix-community/home-manager/release-22.11"; inputs = { nixpkgs.follows = "nixpkgs"; utils.follows = "flake-utils"; }; };
agenix = { url = "github:ryantm/agenix"; inputs.nixpkgs.follows = "nixpkgs"; }; agenix = { url = "github:ryantm/agenix"; inputs.nixpkgs.follows = "nixpkgs"; };
deploy-rs = { url = "github:serokell/deploy-rs"; inputs = { nixpkgs.follows = "nixpkgs"; }; }; deploy-rs = { url = "github:serokell/deploy-rs"; inputs = { nixpkgs.follows = "nixpkgs"; }; };

View file

@ -1,11 +1,16 @@
{ pkgs, lib, ... }: { pkgs, lib, ... }:
let let
xsetroot = "${pkgs.xorg.xsetroot}/bin/xsetroot";
monitorPages = [ "" "" "" "" "" "" "" "" "" "" ]; monitorPages = [ "" "" "" "" "" "" "" "" "" "" ];
monitorPagesString = lib.strings.concatStringsSep " " monitorPages; monitorPagesString = lib.strings.concatStringsSep " " monitorPages;
monitorSetupScript = pkgs.writeShellScript "monitorSetupScript" ''
autorand -c || true
for monitor in $(bspc query -M --names); do
bspc monitor $monitor -d ${monitorPagesString}
done
'';
strPalette = pkgs.lib.rice.palette.toRGBHex pkgs.rice.colorPalette; strPalette = pkgs.lib.rice.palette.toRGBHex pkgs.rice.colorPalette;
xrandr = "${pkgs.xorg.xrandr}/bin/xrandr";
xsetroot = "${pkgs.xorg.xsetroot}/bin/xsetroot";
in in
{ {
xsession.windowManager.bspwm = { xsession.windowManager.bspwm = {
@ -27,19 +32,12 @@ in
"Zathura" = { state = "tiled"; }; "Zathura" = { state = "tiled"; };
"Yad" = { state = "floating"; }; "Yad" = { state = "floating"; };
}; };
extraConfig = '' startupPrograms = [
${xsetroot} -solid black -cursor_name left_ptr "${monitorSetupScript}" # Setup monitors
autorandr -c "systemctl --user restart polybar" # Restart polybar
"${xsetroot} -solid black -cursor_name left_ptr" # Set cursor
for monitor in $(${xrandr} --listactivemonitors | cut -d " " -f 6); do "${pkgs.update-background}/bin/update-background" # Set background
bspc monitor $monitor -d ${monitorPagesString} ];
done
systemctl --user restart \
polybar.service \
update-background.service
'';
startupPrograms = [ ];
}; };
services = { services = {
network-manager-applet.enable = true; network-manager-applet.enable = true;

View file

@ -4,9 +4,9 @@
# blur = true; # blur = true;
# experimentalBackends = true; # experimentalBackends = true;
fade = false; # fade = false;
shadow = true; # shadow = true;
vSync = true; # vSync = true;
# settings = { # settings = {
# blur = # blur =
# { # {
@ -15,13 +15,13 @@
# deviation = 7.0; # deviation = 7.0;
# }; # };
# }; # };
extraOptions = '' # extraOptions = ''
blur: # blur:
{ # {
method = "gaussian"; # method = "gaussian";
size = 10; # size = 10;
deviation = 7.0; # deviation = 7.0;
} # }
''; # '';
}; };
} }

View file

@ -23,6 +23,9 @@
emojiChooser = "rofimoji --skin-tone light -a copy"; emojiChooser = "rofimoji --skin-tone light -a copy";
yad = "${pkgs.yad}/bin/yad"; yad = "${pkgs.yad}/bin/yad";
notify = "${pkgs.libnotify}/bin/notify-send"; notify = "${pkgs.libnotify}/bin/notify-send";
moveAllNodesToPrimary = pkgs.writeShellScript "moveAllNodesToPrimary" ''
comm -23 <(bspc query -N | sort) <(bspc query -m primary -N | sort) | while read n; do bspc node $n -m primary; done
'';
in in
{ {
enable = true; enable = true;
@ -32,9 +35,11 @@
"super + alt + {h,j,k,l}" = "bspc node -z {left -20 0,bottom 0 20,top 0 -20,right 20 0}"; "super + alt + {h,j,k,l}" = "bspc node -z {left -20 0,bottom 0 20,top 0 -20,right 20 0}";
"super + alt + m" = "lockscreen"; "super + alt + m" = "lockscreen";
"super + alt + p" = "autorandr -c"; "super + alt + p" = "autorandr -c";
"super + alt + shift + p" = "arandr";
"super + alt + q" = '' "super + alt + q" = ''
${yad} --question --center --on-top --sticky --timeout=30 --timeout-indicator=bottom --image=gnome-shutdown --title "Shutdown" --text "Do you want to shutdown?" && bspc quit ${yad} --question --center --on-top --sticky --timeout=30 --timeout-indicator=bottom --image=gnome-shutdown --title "Shutdown" --text "Do you want to shutdown?" && bspc quit
''; '';
"super + alt + o" = "${moveAllNodesToPrimary}";
"super + alt + r" = "bspc wm -r"; "super + alt + r" = "bspc wm -r";
"super + alt + {Right,Down,Left}" = "playerctl {next,play-pause,previous}"; "super + alt + {Right,Down,Left}" = "playerctl {next,play-pause,previous}";
"super + alt + shift + {h,j,k,l}" = "bspc node -z {right -20 0,top 0 20,bottom 0 -20,left 20 0}"; "super + alt + shift + {h,j,k,l}" = "bspc node -z {right -20 0,top 0 20,bottom 0 -20,left 20 0}";

View file

@ -104,10 +104,10 @@
../hm_modules/blender.nix ../hm_modules/blender.nix
../hm_modules/bspwm.nix ../hm_modules/bspwm.nix
../hm_modules/cava.nix ../hm_modules/cava.nix
../hm_modules/dwarf-fortress.nix
../hm_modules/fonts.nix
../hm_modules/easyeffects.nix
# ../hm_modules/dunst.nix # ../hm_modules/dunst.nix
../hm_modules/dwarf-fortress.nix
../hm_modules/easyeffects.nix
../hm_modules/fonts.nix
# ../hm_modules/gnome_shell.nix # ../hm_modules/gnome_shell.nix
# ../hm_modules/grobi.nix # ../hm_modules/grobi.nix
../hm_modules/gtk_theme.nix ../hm_modules/gtk_theme.nix
@ -131,7 +131,7 @@
../hm_modules/obs-studio.nix ../hm_modules/obs-studio.nix
../hm_modules/office.nix ../hm_modules/office.nix
../hm_modules/pass.nix ../hm_modules/pass.nix
../hm_modules/picom.nix # ../hm_modules/picom.nix
../hm_modules/polybar.nix ../hm_modules/polybar.nix
# ../hm_modules/pro_audio.nix # ../hm_modules/pro_audio.nix
# ../hm_modules/pycharm.nix # ../hm_modules/pycharm.nix

View file

@ -96,9 +96,9 @@
../hm_modules/blender.nix ../hm_modules/blender.nix
../hm_modules/bspwm.nix ../hm_modules/bspwm.nix
../hm_modules/cava.nix ../hm_modules/cava.nix
../hm_modules/fonts.nix
../hm_modules/easyeffects.nix
# ../hm_modules/dunst.nix # ../hm_modules/dunst.nix
../hm_modules/easyeffects.nix
../hm_modules/fonts.nix
# ../hm_modules/gnome_shell.nix # ../hm_modules/gnome_shell.nix
# ../hm_modules/grobi.nix # ../hm_modules/grobi.nix
../hm_modules/gtk_theme.nix ../hm_modules/gtk_theme.nix