Skip to content

Commit

Permalink
refactor(apps): make vesktop select last workspace if left monitor …
Browse files Browse the repository at this point in the history
…was not found
  • Loading branch information
zakuciael committed Sep 10, 2024
1 parent 189c45a commit 2d70978
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
9 changes: 8 additions & 1 deletion lib/utils.nix
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,14 @@ in rec {
getAttr "data" (findFirst predicate default mappedLayouts);

findLayoutWorkspace = layoutConfig: predicate: let
workspaces = builtins.map (x: x.value // {inherit (x) name;}) (attrsToList layoutConfig.workspaces);
arr = attrsToList layoutConfig.workspaces;
workspaces = imap1 (i: x:
x.value
// {
inherit (x) name;
last = i == (builtins.length arr);
})
arr;
in
findFirst predicate null workspaces;

Expand Down
11 changes: 8 additions & 3 deletions modules/desktop/apps/vesktop.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ with lib;
with lib.my;
with lib.my.utils; let
vesktop = unstable.vesktop;
leftLayout = findLayoutConfig config ({name, ...}: name == "left"); # Left monitor
leftLayout = findLayoutConfig config ({name, ...}: name == "left"); # Try and find left monitor
# Left monitor or main if not found
layout =
if leftLayout != null
then leftLayout
else findLayoutConfig config ({name, ...}: name == "main"); # Left monitor or main if not found
workspace = findLayoutWorkspace layout ({default, ...}: default); # Default workspace
else findLayoutConfig config ({name, ...}: name == "main");
# Default workspace or if left monitor was not found last workspace
workspace =
if leftLayout != null
then findLayoutWorkspace layout ({default, ...}: default)
else findLayoutWorkspace layout ({last, ...}: last);
class = "^(vesktop)$";
in {
modules.desktop.wm.${desktop}.autostartPrograms = [
Expand Down

0 comments on commit 2d70978

Please sign in to comment.