Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Issues with multiple monitors and komorebi bar #1238

Closed
JonasKleinebecker opened this issue Jan 22, 2025 · 6 comments
Closed

[BUG]: Issues with multiple monitors and komorebi bar #1238

JonasKleinebecker opened this issue Jan 22, 2025 · 6 comments
Labels
bug Something isn't working

Comments

@JonasKleinebecker
Copy link

Summary

I have two issues working with komorebi, komorebibar and whkd that might be connected.
Firstly, the komorebi bar only shows up on my first monitor, even though I specify two komorebi.bar files in my komorebi config with different monitor indexes.
Even if I change the index in the komorebi.bar.monitor0 file to 1 the bar still shows up on the monitor with index 0, however it now displays the workspaces associated with monitor 1.
The monitors seem to be correctly identified by komorebic since komorebic send-to-monitor 1 correctly sends a window to my second monitor.
The second issue is that I cannot correctly start applications on my second monitor. If I go to a workspace that is associated with my second monitor such as "Tokyo" via my hotkey alt + 5 and then start up a new application, the new window is added to the last active workspace on my first monitor instead. However once again, komorebic send-to-named-workspace Tokyo correctly sends a window to my second monitor. I can then also successfully refocus the Tokyo workspace on my second workspace using alt + 5. Still if I try to start a new application after focusing Tokyo on my second monitor the window is added to the last active worskspace on monitor 0.
Is there a config step that I missed?

Version Information

Windows 11 Pro
Version 23H2 (Build 22631.4751)

komorebic 0.1.33
tag:v0.1.33
commit_hash:cc51f62c
build_time:2025-01-11 22:30:30 +00:00
build_env:rustc 1.84.0 (9fc6b4312 2025-01-07),stable-x86_64-pc-windows-msvc

Komorebi Configuration

komorebi.json:
{
  "$schema": "https://raw.githubusercontent.com/LGUG2Z/komorebi/v0.1.33/schema.json",
  "app_specific_configuration_path": "$Env:USERPROFILE/applications.json",
  "window_hiding_behaviour": "Cloak",
  "cross_monitor_move_behaviour": "Insert",
  "default_workspace_padding": 15,
  "default_container_padding": 15,
  "border": true,
  "border_width": 5,
  "border_style": "Rounded",
  "border_offset": -1,
  "display_index_preferences": {
    "0": "AUS27AF-5&3939123b&0&UID37122",
    "1": "SAM0D20-5&3939123b&0&UID37121"
  },
  "bar_configurations": [
    "C:/Users/jonas/komorebi.bar.monitor0.json",
    "C:/Users/jonas/komorebi.bar.monitor1.json"
  ],
  "theme": {
    "palette": "Base16",
    "name": "Ashes",
    "unfocused_border": "Base03",
    "bar_accent": "Base0D"
  },
  "stackbar": {
    "height": 40,
    "mode": "OnStack",
    "tabs": {
      "width": 300
    }
  },
  "monitors": [
    {
      "workspaces": [
        {
          "name": "Browser",
          "layout": "VerticalStack"
        },
        {
          "name": "Terminal",
          "layout": "VerticalStack"
        },
        {
          "name": "Music",
          "layout": "VerticalStack"
        },
        {
          "name": "Explorer",
          "layout": "VerticalStack"
        },
        {
          "name": "Berlin",
          "layout": "VerticalStack"
        },
        {
          "name": "Munich",
          "layout": "VerticalStack"
        }
      ]
    },
    {
      "workspaces": [
        {
          "name": "Tokyo",
          "layout": "VerticalStack"
        },
        {
          "name": "Paris",
          "layout": "VerticalStack"
        }
      ]
    }
  ]
}
komorebi.bar.monitor0.json:
{
  "$schema": "https://raw.githubusercontent.com/LGUG2Z/komorebi/v0.1.33/schema.bar.json",
  "monitor": {
    "index": 0,
    "work_area_offset": {
      "left": 0,
      "top": 40,
      "right": 0,
      "bottom": 40
    }
  },
  "font_family": "JetBrains Mono",
  "theme": {
    "palette": "Base16",
    "name": "Ashes",
    "accent": "Base0D"
  },
  "left_widgets": [
    {
      "Komorebi": {
        "workspaces": {
          "enable": true,
          "hide_empty_workspaces": true
        },
        "layout": {
          "enable": true
        },
        "focused_window": {
          "enable": true,
          "show_icon": true
        }
      }
    }
  ],
  "right_widgets": [
    {
      "Update": {
        "enable": true
      }
    },
    {
      "Media": {
        "enable": true
      }
    },
    {
      "Storage": {
        "enable": false
      }
    },
    {
      "Memory": {
        "enable": false
      }
    },
    {
      "Network": {
        "enable": false,
        "show_total_data_transmitted": false,
        "show_network_activity": false
      }
    },
    {
      "Date": {
        "enable": false,
        "format": "DayDateMonthYear"
      }
    },
    {
      "Time": {
        "enable": false,
        "format": "TwentyFourHour"
      }
    },
    {
      "Battery": {
        "enable": false
      }
    }
  ]
}
komorebi.bar.monitor1.json:
{
  "$schema": "https://raw.githubusercontent.com/LGUG2Z/komorebi/v0.1.33/schema.bar.json",
  "monitor": {
    "index": 1,
    "work_area_offset": {
      "left": 0,
      "top": 40,
      "right": 0,
      "bottom": 40
    }
  },
  "font_family": "JetBrains Mono",
  "theme": {
    "palette": "Base16",
    "name": "Ashes",
    "accent": "Base0D"
  },
  "left_widgets": [
    {
      "Komorebi": {
        "workspaces": {
          "enable": true,
          "hide_empty_workspaces": true
        },
        "layout": {
          "enable": true
        },
        "focused_window": {
          "enable": true,
          "show_icon": true
        }
      }
    }
  ],
  "right_widgets": [
    {
      "Update": {
        "enable": true
      }
    },
    {
      "Media": {
        "enable": true
      }
    },
    {
      "Storage": {
        "enable": false
      }
    },
    {
      "Memory": {
        "enable": false
      }
    },
    {
      "Network": {
        "enable": false,
        "show_total_data_transmitted": false,
        "show_network_activity": false
      }
    },
    {
      "Date": {
        "enable": false,
        "format": "DayDateMonthYear"
      }
    },
    {
      "Time": {
        "enable": false,
        "format": "TwentyFourHour"
      }
    },
    {
      "Battery": {
        "enable": false
      }
    }
  ]
}

Hotkey Configuration

.shell powershell

App shortcuts - these require shell to be pwsh / powershell

The apps will be focused if open, or launched if not open

alt + f : if ($wshell.AppActivate('Firefox') -eq $False) { start firefox }

alt + b : if ($wshell.AppActivate('Chrome') -eq $False) { start chrome }

#launch apps
win + 1 : start chrome
win + 2 : start 'C:\Users\jonas\AppData\Roaming\Spotify\Spotify'
win + 3 : start wt
win + 4 : start explorer
win + 5 : start 'C:Users\jonas\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Discord Inc\Discord'

alt + shift + q : komorebic close
alt + shift + m : komorebic toggle-maximize

Focus windows

alt + shift + h : komorebic focus left
alt + shift + j : komorebic focus down
alt + shift + k : komorebic focus up
alt + shift + l : komorebic focus right

Move windows

alt + shift + left : komorebic move left
alt + shift + down : komorebic move down
alt + shift + up : komorebic move up
alt + shift + right : komorebic move right

Resize

alt + shift + oem_plus : komorebic resize-axis horizontal increase
alt + shift + oem_minus : komorebic resize-axis horizontal decrease

Manipulate windows

alt + shift + t : komorebic toggle-tiling

Window manager options

#alt + shift + r : komorebic retile
#alt + p : komorebic toggle-pause

Layouts

#alt + x : komorebic flip-layout horizontal
#alt + y : komorebic flip-layout vertical

Workspaces

alt + 1 : komorebic focus-named-workspace Browser
alt + 2 : komorebic focus-named-workspace Terminal
alt + 3 : komorebic focus-named-workspace Music
alt + 4 : komorebic focus-named-workspace Explorer
alt + 5 : komorebic focus-named-workspace Tokyo
alt + 6 : komorebic focus-named-workspace Paris
alt + 7 : komorebic focus-named-workspace Berlin
alt + 8 : komorebic focus-named-workspace Munich

Move windows across workspaces

alt + shift + 1 : komorebic move-to-named-workspace Browser
alt + shift + 2 : komorebic move-to-named-workspace Terminal
alt + shift + 3 : komorebic move-to-named-workspace Music
alt + shift + 4 : komorebic move-to-named-workspace Explorer
alt + shift + 5 : komorebic move-to-named-workspace Tokyo
alt + shift + 6 : komorebic move-to-named-workspace Paris
alt + shift + 7 : komorebic move-to-named-workspace Berlin
alt + shift + 8 : komorebic move-to-named-workspace Munich

Output of komorebic check

No KOMOREBI_CONFIG_HOME detected, defaulting to C:\Users\jonas

Looking for configuration files in C:\Users\jonas

Found komorebi.json; this file can be passed to the start command with the --config flag

Found C:\Users\jonas.config\whkdrc; key bindings will be loaded from here when whkd is started, and you can start it automatically using the --whkd flag

@JonasKleinebecker JonasKleinebecker added the bug Something isn't working label Jan 22, 2025
@LGUG2Z
Copy link
Owner

LGUG2Z commented Jan 22, 2025

The second issue is that I cannot correctly start applications on my second monitor. If I go to a workspace that is associated with my second monitor such as "Tokyo" via my hotkey alt + 5 and then start up a new application, the new window is added to the last active workspace on my first monitor instead. However once again, komorebic send-to-named-workspace Tokyo correctly sends a window to my second monitor. I can then also successfully refocus the Tokyo workspace on my second workspace using alt + 5. Still if I try to start a new application after focusing Tokyo on my second monitor the window is added to the last active worskspace on monitor 0.

If the workspaces on your secondary monitor(s) are empty when you try to open apps on them, then this is unfortunately expected behaviour; komorebi does not decide where to spawn applications, the operating system does, and komorebi can only react after the operating system emits a message. The empty desktop is a "special" window in Windows land, which exists across monitors, and when it is focused, a new window will typically be opened on whatever the operating system considers to be the primary monitor.

If you want applications to open on specific workspaces on secondary monitors, you should add initial_workspace_rules for them.

@LGUG2Z
Copy link
Owner

LGUG2Z commented Jan 22, 2025

@CtByte any ideas on the bar spawning issue here?

@CtByte
Copy link
Contributor

CtByte commented Jan 22, 2025

@LGUG2Z I've had an issue with my second monitor's bar as well, but only on hot-reload. I would be interested to see if this issue persists in this PR, as my issue is gone when I tested it.

@JonasKleinebecker Just to let you know, if you use the same theme in the komorebi.json and komorebi.bar.*.json configs, then you can just delete the theme settings in the bar configs.

At first glance, I cannot spot a config error with the bars, but it would be worth trying to start your bars individually to see if the console output gives you any clues.

komorebi-bar --config C:/Users/jonas/komorebi.bar.monitor1.json

or

komorebi-bar --config $Env:USERPROFILE/komorebi.bar.monitor1.json

if you get no errors in the console, then you can perhaps "for now" try to specifically set the position of the second bar

komorebi.bar.monitor1.json

  "position": {
    "start": {
      "x": 3840, // width of the first monitor
      "y": 0
    },
    "end": {
      "x": 3840, // width of the second monitor
      "y": 40    // height of your bar
    }
  },

I say "for now" as the settings are greatly improved in the above mentioned PR.

@JonasKleinebecker
Copy link
Author

Thank you for the quick feedback!
The bar issue was due to me misspelling the filename of the second bar ...
The hot reload issue @CtByte mentioned explains why changing the monitor index of the first file did not move the bar as I only used hot reload to apply the changes.
After fixing the spelling, the bars now work as expected.
About the issue of spawning applications in workspaces on the second monitor:
Is it possible to atleast achieve this functionality for the applications I spawn with whkd (I am aware of initial_workspace_rules, but it is not quite what I am looking for)?
What I was thinking of is some small script that

  1. gets the name of the current workspace and saves it
  2. starts a specific application (e.g. start explorer)
  3. sends the newly created window to the saved workspace (komorebic send-to-named-workspace <saved_name_from_step_1>)

This seems like it should be doable but I could not find a command that achieves step 1.

@LGUG2Z
Copy link
Owner

LGUG2Z commented Jan 22, 2025

Sounds like an interesting approach, for now you can use the query command to look up the focused monitor and focused workspace index, but I will expand this command to also be able to return the focused workspace name as well: https://lgug2z.github.io/komorebi/cli/query.html?h=query

LGUG2Z added a commit that referenced this issue Jan 23, 2025
This commit adds the StateQuery::FocusedWorkspaceName variant to allow
users to query the name of the focused workspace via the komorebic query
command.

re #1238
@LGUG2Z
Copy link
Owner

LGUG2Z commented Jan 23, 2025

komorebic query focused-workspace-name will be in the next nightly release

@LGUG2Z LGUG2Z closed this as completed Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants