Skip to content

Instantly share code, notes, and snippets.

@egoexpress
Last active January 23, 2024 07:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egoexpress/64369f867dba7b41686c3ff3cf1a59c9 to your computer and use it in GitHub Desktop.
Save egoexpress/64369f867dba7b41686c3ff3cf1a59c9 to your computer and use it in GitHub Desktop.
Workspacer (workspacer.org) configuration using a custom menu bar, new key mappings and app filters/routers
#r "C:\Work\Tools\System\Workspacer\workspacer.Shared.dll"
#r "C:\Work\Tools\System\Workspacer\plugins\workspacer.Bar\workspacer.Bar.dll"
#r "C:\Work\Tools\System\Workspacer\plugins\workspacer.ActionMenu\workspacer.ActionMenu.dll"
#r "C:\Work\Tools\System\Workspacer\plugins\workspacer.FocusIndicator\workspacer.FocusIndicator.dll"
using System;
using workspacer;
using workspacer.Bar;
using workspacer.Bar.Widgets;
using workspacer.ActionMenu;
using workspacer.FocusIndicator;
Action<IConfigContext> doConfig = (context) =>
{
// disable updates
context.Branch = Branch.None;
// custom menu bar with 24h clock and battery widget
context.AddBar(new BarPluginConfig() {
BarTitle = "workspacer.Bar",
BarHeight = 30,
FontSize = 12,
DefaultWidgetForeground = Color.White,
DefaultWidgetBackground = Color.Black,
Background = Color.Black,
LeftWidgets = () => new IBarWidget[] { new WorkspaceWidget(), new TextWidget("┋ "), new TitleWidget() },
RightWidgets = () => new IBarWidget[] { new TextWidget("┋"), new ActiveLayoutWidget(), new TextWidget("┊"), new TimeWidget(2000, "HH:mm"), new TextWidget("┊"), new BatteryWidget() },
});
context.AddFocusIndicator();
context.AddActionMenu();
context.WorkspaceContainer.CreateWorkspaces("work", "web", "mail", "doc", "note", "temp");
// don't handle these windows
context.WindowRouter.AddFilter((window) => !window.Title.Contains("Clockify"));
context.WindowRouter.AddFilter((window) => !window.Title.Contains("Skype for Business"));
context.WindowRouter.AddFilter((window) => !window.Title.Contains("Erinnerung"));
context.WindowRouter.AddFilter((window) => !window.Title.Contains("Outlook-Nachrichtenübermittlung"));
context.WindowRouter.AddFilter((window) => !window.Title.Contains("NCP Secure Enterprise Client"));
// assign windows to workspaces
context.WindowRouter.AddRoute((window) => window.Title.Contains("Visual Studio Code") ? context.WorkspaceContainer["work"] : null);
context.WindowRouter.AddRoute((window) => window.Title.Contains("Mozilla Firefox") ? context.WorkspaceContainer["web"] : null);
context.WindowRouter.AddRoute((window) => window.Title.Contains("Outlook") ? context.WorkspaceContainer["mail"] : null);
context.WindowRouter.AddRoute((window) => window.Title.Contains("Obsidian") ? context.WorkspaceContainer["note"] : null);
// excluded as Workspacer re-routes to the desktop even if app was forcefully moved from there (thus showing an
// empty desktop every time the app is focussed externally)
// context.WindowRouter.AddRoute((window) => window.Title.Contains("OneNote") ? context.WorkspaceContainer["doc"] : null);
// add shortcuts for <LCtrl>+<LAlt>+<#> to switch workspaces
KeyModifiers mod = KeyModifiers.LAlt | KeyModifiers.LControl;
context.Keybinds.Subscribe(mod, Keys.D1, () => context.Workspaces.SwitchToWorkspace(0), "switch to workspace 1");
context.Keybinds.Subscribe(mod, Keys.D2, () => context.Workspaces.SwitchToWorkspace(1), "switch to workspace 2");
context.Keybinds.Subscribe(mod, Keys.D3, () => context.Workspaces.SwitchToWorkspace(2), "switch to workspace 3");
context.Keybinds.Subscribe(mod, Keys.D4, () => context.Workspaces.SwitchToWorkspace(3), "switch to workspace 4");
context.Keybinds.Subscribe(mod, Keys.D5, () => context.Workspaces.SwitchToWorkspace(4), "switch to workspace 5");
context.Keybinds.Subscribe(mod, Keys.D6, () => context.Workspaces.SwitchToWorkspace(5), "switch to workspace 6");
// remove default shortcuts for <Alt>+<#> to switch workspaces
mod = KeyModifiers.LAlt;
context.Keybinds.Unsubscribe(mod, Keys.D1);
context.Keybinds.Unsubscribe(mod, Keys.D2);
context.Keybinds.Unsubscribe(mod, Keys.D3);
context.Keybinds.Unsubscribe(mod, Keys.D4);
context.Keybinds.Unsubscribe(mod, Keys.D5);
context.Keybinds.Unsubscribe(mod, Keys.D6);
context.Keybinds.Unsubscribe(mod, Keys.D7);
context.Keybinds.Unsubscribe(mod, Keys.D8);
context.Keybinds.Unsubscribe(mod, Keys.D9);
// remove unnecessary keyboard shortcuts
context.Keybinds.Unsubscribe(mod, Keys.O);
context.Keybinds.Unsubscribe(mod, Keys.R);
context.Keybinds.Unsubscribe(mod | KeyModifiers.Shift, Keys.O);
context.Keybinds.Unsubscribe(mod | KeyModifiers.Shift, Keys.R);
context.Keybinds.Unsubscribe(mod | KeyModifiers.Shift, Keys.I);
context.Keybinds.Unsubscribe(mod | KeyModifiers.Shift, Keys.D7);
context.Keybinds.Unsubscribe(mod | KeyModifiers.Shift, Keys.D8);
context.Keybinds.Unsubscribe(mod | KeyModifiers.Shift, Keys.D9);
};
return doConfig;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment