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

currentMonitor in komorebi provider doesn't work #40

Closed
thearturca opened this issue Mar 16, 2024 · 2 comments · Fixed by #43
Closed

currentMonitor in komorebi provider doesn't work #40

thearturca opened this issue Mar 16, 2024 · 2 comments · Fixed by #43

Comments

@thearturca
Copy link
Contributor

Have to use this code to display monitor current workspace name.

          <span class="workspace">
            {{ komorebi.allMonitors.find(m => self.args.MONITOR_NAME.includes(m.name))?.workspaces[komorebi.allMonitors.find(m => self.args.MONITOR_NAME.includes(m.name))?.focusedWorkspaceIndex].name }}
          </span>

komorebi.currentMonitor display only primary monitor on my setup

my config
# Yaml is white-space sensitive (use 2 spaces to indent).

###
# Settings to apply to all windows.
#
# Docs regarding global: https://some-future-docs-link.com
global:
  # Whether to enable the browser devtools.
  enable_devtools: true

###
# Define a new window with an id of 'bar'. This window can then be opened
# via the Zebar cli by running 'zebar open bar'.
#
# Docs regarding window: https://some-future-docs-link.com
window/bar:
  providers: ['self']
  enable_devtools: true
  # Width of the window in physical pixels.
  width: '{{ self.args.MONITOR_WIDTH }}'
  # Height of the window in physical pixels.
  height: '45'
  # X-position of the window in physical pixels.
  position_x: '{{ self.args.MONITOR_X }}'
  # Y-position of the window in physical pixels.
  position_y: '{{ self.args.MONITOR_Y }}'
  # Whether to show the window above/below all others.
  # Allowed values: 'always_on_top', 'always_on_bottom', 'normal'.
  z_order: 'normal'
  # Whether the window should be shown in the taskbar.
  show_in_taskbar: false
  # Whether the window should have resize handles.
  resizable: false
  # Styles to apply globally within the window. For example, we can use
  # this to import the Nerdfonts icon font. Ref https://www.nerdfonts.com/cheat-sheet
  # for a cheatsheet of available Nerdfonts icons.
  global_styles: |
    @import "https://www.nerdfonts.com/assets/css/webfont.css";
  # CSS/SCSS styles to apply to the root element within the window.
  styles: |
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    height: 100%;
    color: #ffffffe6;
    font-family: ui-monospace, monospace;
    font-size: 13px;
    padding: 0px 20px;
    padding-left: 0px;

    .group {
      padding: 10px 18px;
      border-radius: 4px;
    }

  group/left:
    styles: |
      display: flex;
      align-items: center;
      gap: 10px;
      width: fit-content;
      padding: 0;
      background: #00000000;

    template/workspace-name:
      styles: |
        display: flex;
        align-items: center;
        gap: 6px;

        .workspace {
          background: #0000008f;
          width: auto;
          height: auto;
          padding: 10px 20px;
          color: #ffffffe6;
          border: none;
          border-radius: 4px;

          &.active {
            background: rgba(255, 255, 255, 1.0);
            color: #000000e6;
          }

          &:hover {
            background: rgba(255, 255, 255, 0.25);
          }
        }
      providers: ['komorebi', 'self']
      template: |
          <span class="workspace">
            {{ komorebi.allMonitors.find(m => self.args.MONITOR_NAME.includes(m.name))?.workspaces[komorebi.allMonitors.find(m => self.args.MONITOR_NAME.includes(m.name))?.focusedWorkspaceIndex].name }}
          </span>

    template/layout:
      styles: |
        display: flex;
        align-items: center;
        flex-direction: column;
        padding: 10px 20px;
        color: #ffffffe6;
        border: none;
        border-radius: 4px;
        background: #0000008f;

      providers: ['komorebi']
      template: |
        @switch (komorebi.currentWorkspaces[komorebi.currentMonitor.focusedWorkspaceIndex].layout) {
          @case ('bsp') {<span>[\\]</span>}
          @case ('vertical_stack') {<span>[V]=</span>}
          @case ('horizontal_stack') {<span>[H]=</span>}
          @case ('ultrawide_vertical_stack') {<span>||=</span>}
          @case ('rows') {<span>[==]</span>}
          @case ('grid') {<span>[]</span>}
          @case ('custom') {<span>Custom</span>}
          @default {<span>{{ komorebi.currentWorkspaces[komorebi.currentMonitor.focusedWorkspaceIndex].layout.layout }}</span>}
        }

  group/center:
    styles: |
      justify-self: center;
      align-items: center;
      display: flex;
      gap: 20px;

    template/workspaces:
      styles: |
        display: flex;
        align-items: center;
        gap: 6px;

        .workspace {
          background: #0000008f;
          width: auto;
          height: auto;
          padding: 10px 12px;
          color: #ffffffe6;
          border: none;
          border-radius: 4px;

          &.active {
            background: rgba(255, 255, 255, 1.0);
            color: #000000e6;
          }

          &:hover {
            background: rgba(255, 255, 255, 0.25);
          }
        }
      providers: ['komorebi']
      template: |
        @for (workspace of komorebi.currentMonitor.workspaces) {
          <button class="workspace {{ workspace === komorebi.focusedWorkspace && 'active' }}">
            {{ komorebi.currentWorkspaces.indexOf(workspace) + 1 }}
          </button>
        }

  group/right:
    styles: |
      background: #0000008f;
      justify-self: end;
      display: flex;
      align-items: center;
      gap: 20px;

      i {
        color: #7481b2e1;
        margin-right: 7px;
      }

    template/memory:
      providers: ['memory']
      template: |
        <i class="nf nf-fae-chip"></i>
        {{ Math.round(memory.usage) }}%

    template/cpu:
      providers: ['cpu']
      styles: |
        .high-usage {
          color: #900029;
        }
      template: |
        <i class="nf nf-oct-cpu"></i>

        <!-- Change the text color if the CPU usage is high. -->
        @if (cpu.usage > 85) {
          <span class="high-usage">{{ Math.round(cpu.usage) }}%</span>
        } @else {
          <span>{{ Math.round(cpu.usage) }}%</span>
        }

    template/clock:
      providers: ['date']
      # Available date tokens: https://moment.github.io/luxon/#/formatting?id=table-of-tokens
      template: |
        {{ date.toFormat(date.now, 't') }}

@lars-berger
Copy link
Member

Will take a look - there's currently an issue where Zebar windows have to sometimes be manually refreshed on multi-monitor setups.

Copy link

🎉 This issue has been resolved in version 1.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants