[GH-ISSUE #1455] CPU usage is high on commit 25cceb0 #1848

Closed
opened 2026-05-22 22:54:56 +01:00 by JakeStanger · 2 comments
Owner

Originally created by @ffs-akl on GitHub (Apr 14, 2026).
Original GitHub issue: https://github.com/JakeStanger/ironbar/issues/1455

Describe the bug

On commit 25cceb0, Cpu usage keeps 23-35%
To reproduce
Steps to reproduce the behavior:

  1. Build git ver 25cceb0
  2. launch ironbar

Expected behavior

cpu usage return to normal like commit 6412696
System information:

  • Distro: [Arch Linux]
  • Compositor: [niri wip branch]
  • Ironbar version: [git ver 25cceb0]

Configuration

Config
  let {
    $menu = { type = "menu"  
                          label = null
                          label_icon = "niri"  
                          label_icon_size = 20
                          app_icon_size = 20
                          height = 440
                          width = 200
                          start = [ 
                                            { type = "custom"  icon = "com.mitchellh.ghostty" label = "Ghostty终端"  on_click = "ghostty" }
                                            { type = "custom"  icon = "thunar" label = "Thunar文件管理器" on_click = "thunar" }
                                            { type = "custom"  icon = "chromium"  label="chromium浏览器"   on_click = "chromium" }
                                            { type = "custom"  icon = "org.gnome.TextEditor"  label = "Gnome文本编辑器"on_click = "gnome-text-editor" }
                                            { type = "custom"  icon = "flclash" label="Flclash-Clash代理" on_click = "flclash" }
                                            { type = "custom"  icon = "org.gnome.Fractal" label = "Fractal Matrix 客户端"  on_click = "fractal" }
                                            { type = "custom"  icon = "org.mozilla.Thunderbird" label = "Thunderbird邮件客户端"  on_click = "thunderbird" }
                                            {  type = "custom" icon = "system-lock-screen" label = "锁屏"  on_click = "hyprlock"  }
                                            {  type = "custom" icon = "system-log-out" label = "注销"  on_click = "~/.config/labwc/Power n"  }
                                            {  type = "custom"  icon = "system-reboot" label = "重启"   on_click = "~/.config/labwc/Power r " }
                                            { type = "custom"   icon = "system-shutdown" label = "关机"  on_click = "~/.config/labwc/Power p" } 
                                                  ]   
                        center= [ ]
                        end = [ ]
                            } 
    $workspaces = { type = "workspaces" }
    $launcher = {  type = "launcher" 
                             favorites = [ "ghostty" "chromium" "thunar" "org.gnome.TextEditor" "flclash" "org.gnome.Fractal" ]
                             icon_size = 18
                             truncate.mode = "end" 
                             truncate.max_length = 30 
                             }

     $sys_info = { type = "sys_info" 
                            format = [" "]
                            interval.cpu = 1 
                                }
     $config_dir  = "$env_HOME/.config/ironbar"
     $cpu_graph = { type = "cairo"
                                path = "$config_dir/cpu_graph.lua"
                                frequency = 500
                                height = 20
                                width =  20
                                   }
    $clipboard = { type = "clipboard" max_items = 5 truncate.mode = "end" truncate.length = 30 }
    $bluetooth = { type = "bluetooth"
                              icon_size = 16
                              format.not_found = ""
                              format.disabled = "󰂲"
                              format.enabled = "󰂯"
                              format.connected = "󰂯 {device_alias}"
                              format.connected_battery = "󰂯 {device_alias} • {device_battery_percent}%"
                             popup.max_height.devices = 5
                             popup.header = " 启用"
                             popup.disabled = "{adapter_status}"
                             popup.device.header = "{device_alias}"
                             popup.device.header_battery = "{device_alias}"
                             popup.device.footer = "{device_status}"
                             popup.device.footer_battery = "{device_status} • Battery   {device_battery_percent}%"
                             adapter_status.not_found = "没有发现蓝牙设备"
                             adapter_status.enabled = "已启用蓝牙"
                             adapter_status.enabling = "启用蓝牙中..."
                             adapter_status.disabled = "蓝牙已禁用"
                             adapter_status.disabling = "禁用蓝牙中..."
                             device_status.connected = "已连结"
                             device_status.connecting = "连结中..."
                             device_status.disconnected = "取消连结"
                             device_status.disconnecting = "取消连结中..."
                                  }
      $button_power = { type = "button" name="power-btn" label = "" on_click = "popup:toggle" }
      $popup_power = { type = "box"
                                       orientation = "vertical"
                                       widgets = [{ type = "box"
                                                             widgets = [
                                                                               { type = "button" class="power-btn" label = "<span font-size='12pt'>󰗽</span>" on_click = "!niri msg action quit --skip-confirmation" }
                                                                               { type = "button" class="power-btn" label = "<span font-size='12pt'></span>" on_click = "!systemctl poweroff" }
                                                                               { type = "button" class="power-btn" label = "<span font-size='12pt'></span>" on_click = "!systemctl reboot" }
                                                                                            ]
                                                                     }]
                                                 }
    $power_menu = {
                                 type = "custom"
                                 class = "power-menu"
                                 bar = [ $button_power ]
                                 popup = [ $popup_power ]
                                 tooltip = "Up: {{30000:uptime -p | cut -d ' ' -f2-}}"
                                   }
    $volume = { type = "volume"
                          format = "{icon} {percentage}%"
                          sink_slider_orientation = "vertical"
                          max_volume = 100
                          truncate = "end"
                          icons.volume_high = "󰕾"
                          icons.volume_medium = "󰖀"
                          icons.volume_low = "󰕿"
                          icons.muted = "󰝟" 
                               }
    $tray = { type = "tray" }
    $clock = { type = "clock"   format = "%H:%M"}
    $notifications = { type = "notifications"  show_if = "pgrep -x swaync" }
    $menulau = {  type = "custom"
                              name = "menulau"
                              class = "menulau"
                              bar = [ {  type = "button" 
                                              name = "m-button" 
                                             widgets = [ { type = "image"
                                                                    src = "/usr/share/pixmaps/archlinux-logo.svg" 
                                                                     size = 10
                                                                          } ]
                                              on_click = "!pkill -RTMIN sysmenu" 
                                                 } ]
                                 }
} in {
           icon_theme = "Qogir-Light"
           position = "bottom"
           popup_autohide = true
           height = 32
           start = [ $power_menu $workspaces ]
           center = [ $menulau $launcher]
           end = [ $sys_info $cpu_graph $tray $clipboard $volume  $bluetooth $clock $notifications ]
          }
     

Styles
 #bar {
         background-color: alpha(@theme_bg_color, 0.6) ;
  }
  */
 window   {
         background-color:  alpha(@theme_bg_color, 0.6) ;
       }
  button {
         background-color:  alpha(@theme_bg_color, 0.0);
         padding: 0px 4px 0px 4px;
         margin: 1px 2px 1px 1px;
         border-radius: 0px;
       }


  
  popover  {
     
        background-color:  alpha(@theme_bg_color, 0.0);
         }
  
  popover contents  {
            background-color:  @theme_bg_color;
        }
  
  calendar  {
           
              background-color:  alpha(@theme_bg_color, 0.6) ;
          }
  /*menu*/
  .menu {
            }
  .popup-menu .main,  .popup-menu .sub-menu {
             }       
   .popup-menu .main .category,  .popup-menu .sub-menu .application  {
            padding: 5px 1px 5px 1px;
            margin: 1px;
             }
  .popup-menu .main .category:hover, 
  .popup-menu .sub-menu .application:hover,   
  .popup-launcher .popup-item:hover {
          background-color: alpha(#353535,0.3);
          border-radius: 6px
           }
    .popup-menu .main .category.open {
          font-size: 16px;
          font-weight: 900;
          color: alpha(#353535,0.6); 
           }
    .popup-launcher {
       }
     .popup-launcher .popup-item {
       }
  

.launcher .item, 
.menulau #m-button,
.power-menu #power-btn,
.popup-power-menu .power-btn,
.workspaces button,
.tray button,
.bluetooth,
.clipboard,
.notifications button,
.volume,
.clock {
    transition: transform 200ms ease-in-out;
}

.menu:hover,
.launcher .item:hover, 
.menulau #m-button:hover,
.power-menu #power-btn:hover,
.popup-power-menu .power-btn:hover,
.workspaces button:hover,
.tray button:hover,
.bluetooth:hover,
.clipboard:hover,
.notifications button:hover,
.volume:hover,
.clock:hover {
    transform: scale(1.2);
}

/* 3. 点击状态:向内弹回(更有机械手感) */
.menu:active,
.launcher .item:active, 
.menulau #m-button:active,
.power-menu #power-btn:active,
.popup-power-menu .power-btn:active,
.workspaces button:active,
.tray button:active,
.bluetooth:active,
.clipboard:active,
.notifications button:active,
.volume:active,
.clock:active {
    transform: scale(0.9); 
}


.menulau #m-button  {
        margin-right: 5px;
 }
 
 .power-menu  #power-btn {
    font-size: 18px;
    color: #66ff99d9;
    margin-left: 5px;
}
 .popup-power-menu .power-btn {
    font-size: 18px;
    color: #ff4d4de6;
}
 /* --- launcher --- */
/*  .launcher  .item {
            padding: 0px 1px 0px 1px;
            margin: 1px 6px 1px 1px;
            border-radius: 0;
  }  */
  .launcher .item + .item {
    margin-left: 8px;
    margin-right: 8px;
    }
    


  .launcher .item.open {
     box-shadow: inset 0 -3px 0 0 #38bdf8;
     transition: box-shadow 200ms ease-in-out;
   }

 .launcher .item.focused {
     box-shadow: inset 0 -3px 0 0 #22c55e;
     transition: box-shadow 200ms ease;
   }

.launcher .item.urgent {
    box-shadow: inset 0 -3px 0 0 #ef4444; /* 替换原来的 border-bottom */
    transition: box-shadow 200ms ease;
   }
  

 /*sys-info */
 .sysinfo {
       }
 .sysinfo .item {
        font-size: 16px;
       }
 .cairo { 
         margin-right: 5px;
        }
 /* --- volume --- */
.volume .source {   
      }
.popup-volume .device-box {
     }

/* --- clock --- */
.clock {
        padding: 1px;
        margin:  1px;
         }

.popup-clock .calendar-clock {
        }

Additional context

Screenshots

Originally created by @ffs-akl on GitHub (Apr 14, 2026). Original GitHub issue: https://github.com/JakeStanger/ironbar/issues/1455 **Describe the bug** <!-- A clear and concise description of what the bug is. --> On commit 25cceb0, Cpu usage keeps 23-35% **To reproduce** Steps to reproduce the behavior: 1. Build git ver 25cceb0 2. launch ironbar **Expected behavior** <!-- A clear and concise description of what you expected to happen. --> cpu usage return to normal like commit 6412696 **System information:** - Distro: [Arch Linux] - Compositor: [niri wip branch] - Ironbar version: [git ver 25cceb0] **Configuration** <!-- Share your bar configuration and stylesheet as applicable: --> <details><summary>Config</summary> ``` let { $menu = { type = "menu" label = null label_icon = "niri" label_icon_size = 20 app_icon_size = 20 height = 440 width = 200 start = [ { type = "custom" icon = "com.mitchellh.ghostty" label = "Ghostty终端" on_click = "ghostty" } { type = "custom" icon = "thunar" label = "Thunar文件管理器" on_click = "thunar" } { type = "custom" icon = "chromium" label="chromium浏览器" on_click = "chromium" } { type = "custom" icon = "org.gnome.TextEditor" label = "Gnome文本编辑器"on_click = "gnome-text-editor" } { type = "custom" icon = "flclash" label="Flclash-Clash代理" on_click = "flclash" } { type = "custom" icon = "org.gnome.Fractal" label = "Fractal Matrix 客户端" on_click = "fractal" } { type = "custom" icon = "org.mozilla.Thunderbird" label = "Thunderbird邮件客户端" on_click = "thunderbird" } { type = "custom" icon = "system-lock-screen" label = "锁屏" on_click = "hyprlock" } { type = "custom" icon = "system-log-out" label = "注销" on_click = "~/.config/labwc/Power n" } { type = "custom" icon = "system-reboot" label = "重启" on_click = "~/.config/labwc/Power r " } { type = "custom" icon = "system-shutdown" label = "关机" on_click = "~/.config/labwc/Power p" } ] center= [ ] end = [ ] } $workspaces = { type = "workspaces" } $launcher = { type = "launcher" favorites = [ "ghostty" "chromium" "thunar" "org.gnome.TextEditor" "flclash" "org.gnome.Fractal" ] icon_size = 18 truncate.mode = "end" truncate.max_length = 30 } $sys_info = { type = "sys_info" format = [" "] interval.cpu = 1 } $config_dir = "$env_HOME/.config/ironbar" $cpu_graph = { type = "cairo" path = "$config_dir/cpu_graph.lua" frequency = 500 height = 20 width = 20 } $clipboard = { type = "clipboard" max_items = 5 truncate.mode = "end" truncate.length = 30 } $bluetooth = { type = "bluetooth" icon_size = 16 format.not_found = "" format.disabled = "󰂲" format.enabled = "󰂯" format.connected = "󰂯 {device_alias}" format.connected_battery = "󰂯 {device_alias} • {device_battery_percent}%" popup.max_height.devices = 5 popup.header = " 启用" popup.disabled = "{adapter_status}" popup.device.header = "{device_alias}" popup.device.header_battery = "{device_alias}" popup.device.footer = "{device_status}" popup.device.footer_battery = "{device_status} • Battery {device_battery_percent}%" adapter_status.not_found = "没有发现蓝牙设备" adapter_status.enabled = "已启用蓝牙" adapter_status.enabling = "启用蓝牙中..." adapter_status.disabled = "蓝牙已禁用" adapter_status.disabling = "禁用蓝牙中..." device_status.connected = "已连结" device_status.connecting = "连结中..." device_status.disconnected = "取消连结" device_status.disconnecting = "取消连结中..." } $button_power = { type = "button" name="power-btn" label = "" on_click = "popup:toggle" } $popup_power = { type = "box" orientation = "vertical" widgets = [{ type = "box" widgets = [ { type = "button" class="power-btn" label = "<span font-size='12pt'>󰗽</span>" on_click = "!niri msg action quit --skip-confirmation" } { type = "button" class="power-btn" label = "<span font-size='12pt'></span>" on_click = "!systemctl poweroff" } { type = "button" class="power-btn" label = "<span font-size='12pt'></span>" on_click = "!systemctl reboot" } ] }] } $power_menu = { type = "custom" class = "power-menu" bar = [ $button_power ] popup = [ $popup_power ] tooltip = "Up: {{30000:uptime -p | cut -d ' ' -f2-}}" } $volume = { type = "volume" format = "{icon} {percentage}%" sink_slider_orientation = "vertical" max_volume = 100 truncate = "end" icons.volume_high = "󰕾" icons.volume_medium = "󰖀" icons.volume_low = "󰕿" icons.muted = "󰝟" } $tray = { type = "tray" } $clock = { type = "clock" format = "%H:%M"} $notifications = { type = "notifications" show_if = "pgrep -x swaync" } $menulau = { type = "custom" name = "menulau" class = "menulau" bar = [ { type = "button" name = "m-button" widgets = [ { type = "image" src = "/usr/share/pixmaps/archlinux-logo.svg" size = 10 } ] on_click = "!pkill -RTMIN sysmenu" } ] } } in { icon_theme = "Qogir-Light" position = "bottom" popup_autohide = true height = 32 start = [ $power_menu $workspaces ] center = [ $menulau $launcher] end = [ $sys_info $cpu_graph $tray $clipboard $volume $bluetooth $clock $notifications ] } ``` </details> <details><summary>Styles</summary> ``` #bar { background-color: alpha(@theme_bg_color, 0.6) ; } */ window { background-color: alpha(@theme_bg_color, 0.6) ; } button { background-color: alpha(@theme_bg_color, 0.0); padding: 0px 4px 0px 4px; margin: 1px 2px 1px 1px; border-radius: 0px; } popover { background-color: alpha(@theme_bg_color, 0.0); } popover contents { background-color: @theme_bg_color; } calendar { background-color: alpha(@theme_bg_color, 0.6) ; } /*menu*/ .menu { } .popup-menu .main, .popup-menu .sub-menu { } .popup-menu .main .category, .popup-menu .sub-menu .application { padding: 5px 1px 5px 1px; margin: 1px; } .popup-menu .main .category:hover, .popup-menu .sub-menu .application:hover, .popup-launcher .popup-item:hover { background-color: alpha(#353535,0.3); border-radius: 6px } .popup-menu .main .category.open { font-size: 16px; font-weight: 900; color: alpha(#353535,0.6); } .popup-launcher { } .popup-launcher .popup-item { } .launcher .item, .menulau #m-button, .power-menu #power-btn, .popup-power-menu .power-btn, .workspaces button, .tray button, .bluetooth, .clipboard, .notifications button, .volume, .clock { transition: transform 200ms ease-in-out; } .menu:hover, .launcher .item:hover, .menulau #m-button:hover, .power-menu #power-btn:hover, .popup-power-menu .power-btn:hover, .workspaces button:hover, .tray button:hover, .bluetooth:hover, .clipboard:hover, .notifications button:hover, .volume:hover, .clock:hover { transform: scale(1.2); } /* 3. 点击状态:向内弹回(更有机械手感) */ .menu:active, .launcher .item:active, .menulau #m-button:active, .power-menu #power-btn:active, .popup-power-menu .power-btn:active, .workspaces button:active, .tray button:active, .bluetooth:active, .clipboard:active, .notifications button:active, .volume:active, .clock:active { transform: scale(0.9); } .menulau #m-button { margin-right: 5px; } .power-menu #power-btn { font-size: 18px; color: #66ff99d9; margin-left: 5px; } .popup-power-menu .power-btn { font-size: 18px; color: #ff4d4de6; } /* --- launcher --- */ /* .launcher .item { padding: 0px 1px 0px 1px; margin: 1px 6px 1px 1px; border-radius: 0; } */ .launcher .item + .item { margin-left: 8px; margin-right: 8px; } .launcher .item.open { box-shadow: inset 0 -3px 0 0 #38bdf8; transition: box-shadow 200ms ease-in-out; } .launcher .item.focused { box-shadow: inset 0 -3px 0 0 #22c55e; transition: box-shadow 200ms ease; } .launcher .item.urgent { box-shadow: inset 0 -3px 0 0 #ef4444; /* 替换原来的 border-bottom */ transition: box-shadow 200ms ease; } /*sys-info */ .sysinfo { } .sysinfo .item { font-size: 16px; } .cairo { margin-right: 5px; } /* --- volume --- */ .volume .source { } .popup-volume .device-box { } /* --- clock --- */ .clock { padding: 1px; margin: 1px; } .popup-clock .calendar-clock { } ``` </details> **Additional context** <!-- Add any other context about the problem here. --> **Screenshots** <!-- If applicable, add screenshots to help explain your problem. -->
JakeStanger 2026-05-22 22:54:56 +01:00
Author
Owner

@JakeStanger commented on GitHub (Apr 14, 2026):

I'm only seeing a peak of 1% CPU with your config which is making this slightly harder to narrow down, but I think the custom power_menu module is causing the spike. Can you try commenting that out and see if that reduces the CPU usage for you please?

<!-- gh-comment-id:4246779417 --> @JakeStanger commented on GitHub (Apr 14, 2026): I'm only seeing a peak of 1% CPU with your config which is making this slightly harder to narrow down, but I think the custom power_menu module is causing the spike. Can you try commenting that out and see if that reduces the CPU usage for you please?
Author
Owner

@JakeStanger commented on GitHub (Apr 14, 2026):

Got it. A recent changes to scripts accidentally moved the sleep call for the script interval out of the polling loop, so scripts were being polled as fast as your poor machine could cope. The tooltip on the power menu module was doing it for you.

<!-- gh-comment-id:4246961585 --> @JakeStanger commented on GitHub (Apr 14, 2026): Got it. A recent changes to scripts accidentally moved the `sleep` call for the script interval out of the polling loop, so scripts were being polled as fast as your poor machine could cope. The tooltip on the power menu module was doing it for you.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
JakeStanger/ironbar#1848
No description provided.