Polybar i3 没有出现工作区模块

Polybar i3 没有出现工作区模块

我刚刚从默认的 i3 bar 切换到使用 polybar(运行 Fedora 30,i3-gaps)。我按照本指南安装了 Polybar:https://computingforgeeks.com/install-polybar-status-bar-on-fedora/。我首先尝试运行 Polybar 的默认配置,它工作正常,只是工作区应该在的左侧没有任何东西。我尝试了一下,试图让它正常工作,但我遇到的任何论坛中似乎都没有人有类似的情况。

我最终复制了这个答案中给出的 Polybar 配置,因为他们似乎以与我相同的方式在 i3 配置中设置工作区:https://computingforgeeks.com/install-polybar-status-bar-on-fedora/,但结果是相同的 - 我的 Polybar 上没有出现工作区模块。

我的多杆配置文件是:

[global/wm]
margin-top = 100
margin-bottom = 100

[colors]
fg = ${xrdb:color7}
modfg = ${xrdb:color1}
bg = ${xrdb:color0}

white = #d1d1d1
gray = #585858
black = #ce1d1d1d
red = #c795ae
blue = #95aec7
yellow = #c7ae95
green = #aec795


[bar/bar1]
width = 100%
height = 41
top = true
;margin-top = 100

border-top-size = 1  # creating top border space
offset-y = -3   # aligning tray icons with rest of bar
monitor = ${env:MONITOR:}

;background = #141021
background = #000f0f0f # This is the hexcode for transparency (also used in powermenu)
foreground = #c4b7c5


fixed-center = false

font-0 = FontAwesome:pixelsize=10;0
font-1 = PragmataPro Nerd Font:pixelsize=10;0
font-2 = "Font Awesome 5 Free:style=Regular:pixelsize=10;1"
font-3 = "Font Awesome 5 Free:style=Solid:pixelsize=10;1"
font-4 = "Font Awesome 5 Brands:pixelsize=10;1"

modules-left = i3
modules-center = date
modules-right = wireless-network cpu memory filesystem temperature pulseaudio backlight battery powermenu

tray-position = right
;tray-maxsize = 41
tray-background = #000f0f0f
tray-foreground= #000f0f0f

scroll-up = i3wm-wsnext
scroll-down = i3wm-wsprev


overline-size = 2
overline-color = ${colors.white}
underline-size = 4
underline-color = ${colors.white}

;override-redirect = true
;wm-restack = i3


[module/i3]
type = internal/i3

pin-workspaces = false
strip-wsnumbers = true
index-sort = false 
enable-scroll = false

format = <label-state> 
format-padding-right = 2

label-unfocused-foreground = #8a7f8f
label-unfocused-padding = 1

label-focused-foreground = #c16772
label-focused-padding = 1

label-urgent-foreground = #e4b226
label-urgent-padding = 1


[module/filesystem]
type = internal/fs

; Mountpoints to display
mount-0 = /

label-mounted =  %free%
format-mounted-padding = 2

; Seconds to sleep between updates
; Default: 30
; interval = 10

; Display fixed precision values
; Default: false
fixed-values = true

; Spacing between entries
; Default: 2
spacing = 6




[module/filesystem2]
type = internal/fs

; Mountpoints to display
mount-0 = /media/<my_name>/Data

label-mounted =  %free%
format-mounted-padding = 2

; Seconds to sleep between updates
; Default: 30
; interval = 10

; Display fixed precision values
; Default: false
fixed-values = true

; Spacing between entries
; Default: 2
spacing = 6





[module/cpu]
type = internal/cpu

interval = 1

format = <label>
format-padding = 2

label =  %percentage%%


[module/memory]
type = internal/memory

interval = 1

format = <label>
format-padding = 2

label =  %gb_used% (%percentage_used%%)


[module/temperature]
type = internal/temperature

interval = 1

thermal-zone = 0

warn-temperature = 74

format = <ramp> <label>
format-padding = 2

format-warn = <ramp> <label-warn>
format-warn-padding = 2

label = %temperature-c%

label-warn = %temperature-c%
label-warn-foreground = #e4b226

ramp-0 = 
ramp-1 = 
ramp-2 = 
ramp-3 = 
ramp-4 = 


[module/date]
type = internal/date

interval = 1

date = %a %b %d, 
time = %H:%M:%S

date-alt = %A, %d %B %Y
time-alt = %H:%M:%S

format = <label>
format-padding = 2

label =  %date% %time%


[module/battery]
; Note - if battery isn't showing, try BAT0 or BAT1, etc.
type = internal/battery

full-at = 95

battery = BAT1
adapter = ACAD

poll-interval = 5

format-charging = <animation-charging> <label-charging>
format-charging-padding = 2

format-discharging = <ramp-capacity> <label-discharging>
format-discharging-padding = 2

format-full = <ramp-capacity> <label-full>
format-full-padding = 2

label-charging = %percentage%%

label-discharging = %percentage%%

label-full = %percentage%%

ramp-capacity-0 = 
ramp-capacity-1 = 
ramp-capacity-2 = 
ramp-capacity-3 = 
ramp-capacity-4 = 

animation-charging-0 = 
animation-charging-1 = 
animation-charging-2 = 
animation-charging-3 = 
animation-charging-4 = 
animation-charging-framerate = 500


[module/backlight]
type = internal/backlight

card = intel_backlight

format = <label>
format-padding = 2

label =  %percentage%%


[module/pulseaudio]
type = internal/pulseaudio
; List sinks via `pactl list sinks` and look at the Name field

sink = alsa_output.pci-0000_00_1b.0.analog-stereo
;interval = 1

format-volume-padding = 2
format-volume = <ramp-volume> <label-volume>
ramp-volume-0 = 
ramp-volume-1 = 
ramp-volume-2 = 

format-muted-padding = 2
label-muted =  0%


[module/powermenu]
type = custom/menu

label-open =   

label-close = cancel

label-close-background = #000f0f0f
label-close-foreground = #ffeefc
label-open-padding-left = 4
label-open-padding-right = 3
label-close-padding = 3

menu-0-0 = lock
menu-0-0-exec = ~/scripts/lock.sh
menu-0-0-background = #000f0f0f
menu-0-0-foreground = #c05c47
menu-0-0-padding-right = 3

menu-0-1 = reboot
menu-0-1-exec = menu-open-1
menu-0-1-background = #000f0f0f
menu-0-1-foreground = #c05c47
menu-0-1-padding-right = 3

menu-0-2 = power off
menu-0-2-exec = menu-open-2
menu-0-2-background = #000f0f0f
menu-0-2-foreground = #c05c47
menu-0-2-padding-right = 3

menu-1-0 = reboot?  
menu-1-0-exec = reboot
menu-1-0-background = #000f0f0f
menu-1-0-foreground = #e4b226
menu-1-0-padding-right = 3

menu-2-0 = power off?  
menu-2-0-exec = poweroff
menu-2-0-background = #000f0f0f
menu-2-0-foreground = #e4b226
menu-2-0-padding-right = 3


[module/wireless-network]
type = internal/network

; Look at ifconfig for interface
interface = wlo1

format-connected = <label-connected>
format-connected-padding = 2

format-disconnected = <label-disconnected>
format-disconnected-padding = 2

label-connected =  %essid%

label-disconnected =  None

我的 i3 配置是:

# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#

# i3 config file (v4)
#
# Please see https://i3wm.org/docs/userguide.html for a complete reference!

set $mod Mod4

# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
font pango:System San Francisco Display 10

# This font is widely installed, provides lots of unicode glyphs, right-to-left
# text rendering and scalability on retina/hidpi displays (thanks to pango).
#font pango:DejaVu Sans Mono 8

# Before i3 v4.8, we used to recommend this one as the default:
# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
# The font above is very space-efficient, that is, it looks good, sharp and
# clear in small sizes. However, its unicode glyph coverage is limited, the old
# X core fonts rendering does not support right-to-left and this being a bitmap
# font, it doesn’t scale on retina/hidpi displays.


# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod

# start a terminal
bindsym $mod+Return exec gnome-terminal #i3-sensible-terminal
#start a browser
bindsym $mod+numbersign exec firefox

# kill focused window
bindsym $mod+Shift+q kill

# start dmenu (a program launcher)
bindsym $mod+d exec dmenu_run
# There also is the (new) i3-dmenu-desktop which only displays applications
# shipping a .desktop file. It is a wrapper around dmenu, so you need that
# installed.
# bindsym $mod+d exec --no-startup-id i3-dmenu-desktop

# change focus
bindsym $mod+j focus left
bindsym $mod+k focus down
bindsym $mod+l focus up
bindsym $mod+semicolon focus right

# alternatively, you can use the cursor keys:
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right

# move focused window
bindsym $mod+Shift+j move left
bindsym $mod+Shift+k move down
bindsym $mod+Shift+l move up
bindsym $mod+Shift+semicolon move right

# alternatively, you can use the cursor keys:
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right

# split in horizontal orientation
bindsym $mod+h split h

# split in vertical orientation
bindsym $mod+v split v

# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle

# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split

# toggle tiling / floating
bindsym $mod+Shift+space floating toggle

# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle

# focus the parent container
bindsym $mod+a focus parent

# focus the child container
#bindsym $mod+d focus child

# Define names for default workspaces for which we configure key bindings later on.
# We use variables to avoid repeating the names in multiple places.
set $ws1 "1:" 
set $ws2 "2:" 
set $ws3 "3:" 
set $ws4 "4:" 
#set $ws5 "5:<span font='SVGFont1 12' rise='-2000'>a</span>"
set $ws6 "6:"
set $ws7 "7:"
set $ws8 "8:"
set $ws9 "9:"
set $ws10 "10:"
set $ws11 "11:"
#set $ws1 "1" 
#set $ws2 "2" 
#set $ws3 "3" 
#set $ws4 "4" 
set $ws5 "5"
#set $ws6 "6"
#set $ws7 "7"
#set $ws8 "8"
#set $ws9 "9"
#set $ws10 "10"
#set $ws11 "11"

# switch to workspace
bindsym $mod+1 workspace $ws1
bindsym $mod+2 workspace $ws2
bindsym $mod+3 workspace $ws3
bindsym $mod+4 workspace $ws4
bindsym $mod+5 workspace $ws5
bindsym $mod+6 workspace $ws6
bindsym $mod+7 workspace $ws7
bindsym $mod+8 workspace $ws8
bindsym $mod+9 workspace $ws9
bindsym $mod+0 workspace $ws10
bindsym $mod+Control+1 workspace $ws11

# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace $ws1
bindsym $mod+Shift+2 move container to workspace $ws2
bindsym $mod+Shift+3 move container to workspace $ws3
bindsym $mod+Shift+4 move container to workspace $ws4
bindsym $mod+Shift+5 move container to workspace $ws5
bindsym $mod+Shift+6 move container to workspace $ws6
bindsym $mod+Shift+7 move container to workspace $ws7
bindsym $mod+Shift+8 move container to workspace $ws8
bindsym $mod+Shift+9 move container to workspace $ws9
bindsym $mod+Shift+0 move container to workspace $ws10
bindsym $mod+Shift+Control+1 move container to workspace $ws11


# reload the configuration file
bindsym $mod+Shift+c reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r restart
# exit i3 (logs you out of your X session)
bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"

# resize window (you can also use the mouse for that)
mode "resize" {
        # These bindings trigger as soon as you enter the resize mode

        # Pressing left will shrink the window’s width.
        # Pressing right will grow the window’s width.
        # Pressing up will shrink the window’s height.
        # Pressing down will grow the window’s height.
        bindsym j resize shrink width 10 px or 10 ppt
        bindsym k resize grow height 10 px or 10 ppt
        bindsym l resize shrink height 10 px or 10 ppt
        bindsym semicolon resize grow width 10 px or 10 ppt

        # same bindings, but for the arrow keys
        bindsym Left resize shrink width 10 px or 10 ppt
        bindsym Down resize grow height 10 px or 10 ppt
        bindsym Up resize shrink height 10 px or 10 ppt
        bindsym Right resize grow width 10 px or 10 ppt

        # back to normal: Enter or Escape or $mod+r
        bindsym Return mode "default"
        bindsym Escape mode "default"
        bindsym $mod+r mode "default"
}

bindsym $mod+r mode "resize"

set $bg-color            #44444480
set $inactive-bg-color   #44444480
set $text-color          #f3f4f5
set $inactive-text-color #676E7D
set $urgent-bg-color     #E53935
set $ws-focused-bg   #ffc553

# window colors
#                       border              background         text                 indicator
client.focused          $bg-color           $bg-color          $text-color          #00ff00
client.unfocused        $inactive-bg-color  $inactive-bg-color $inactive-text-color #00ff00
client.focused_inactive $inactive-bg-color  $inactive-bg-color $inactive-text-color #00ff00
client.urgent       $urgent-bg-color    $urgent-bg-color   $text-color      #00ff00

# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
#bar {
#   strip_workspace_numbers yes
#   status_command i3status
#   colors {
#          background $bg-color
#              separator #757575
##                                border             background         text
#          focused_workspace  $ws-focused-bg     $ws-focused-bg     $text-color
#          inactive_workspace $inactive-bg-color $inactive-bg-color $inactive-text-color
#          urgent_workspace   $urgent-bg-color   $urgent-bg-color   $text-color
#       }
#}
exec_always --no-startup-id $HOME/.config/polybar/launch.sh
exec compton -f -I 0.06 -O 0.6

#GAPS!!!
gaps inner 10
for_window [class=".*"] border pixel 0

#touchpad touch-ups:
exec_always "~/.config/i3/touchpad_options"

#key swaps:
exec_always ~/.config/i3/key_mappings

#media
# Pulse Audio controls
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 0 +5% #increase sound volume
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 0 -5% #decrease sound volume
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute 0 toggle # mute sound

# Sreen brightness controls
bindsym XF86MonBrightnessUp exec xbacklight -inc 10 # increase screen brightness
bindsym XF86MonBrightnessDown exec xbacklight -dec 10 # decrease screen brightness

# Media player controls
bindsym XF86AudioPlay exec playerctl play-pause
#bindsym XF86AudioPause exec playerctl pause
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous

#HARRY'S COMMANDS:
#desktop background
exec_always feh --bg-fill ~/Pictures/desktop-photos/roundabout-darkened.png

#lock shortcut:
bindsym $mod+shift+x exec i3lock -c 222222

#set dpi for i3 toolbars
exec_always xrdb -merge ~/.Xresources
exec_always xrandr --dpi 120

编辑:做了更多的故障排除,发现问题出在我安装的 Polybar 中。如果我从终端运行它,它会告诉我没有对内部/i3 的内置支持。命令 polybar -v 给了我:

polybar 3.3.0-101-gf0c65e6

Features: +alsa +curl -i3 +mpd +network(libnl) +pulseaudio +xkeyboard

虽然这正是指南(上面链接的,声称是为了在 Fedora 上安装 i3wm)告诉我应该得到的输出,但看起来 -i3 (逻辑上)意味着它缺乏 i3 支持(参考:https://github.com/polybar/polybar/issues/526)。我不完全知道如何正确执行安装,但我将卸载 Polybar 并寻找一些有关如何执行安装的更好文档。

答案1

我在 Ubuntu 18.04 上遇到了同样的问题(没有显示工作区)。原因是libjsoncpp-dev主包存储库太旧(1.7.4 vs 1.7.7)。您必须注意 cmake 输出。如果版本太旧,它会自行构建所需的最低版本的静态库。这是我首先得到的

./build.sh
...
-- Checking for module 'jsoncpp>=1.7.7'
--   Requested 'jsoncpp >= 1.7.7' but version of jsoncpp is 1.7.4
You may find new versions of jsoncpp at https://github.com/open-source-parsers/jsoncpp
-- Could not find jsoncpp>=1.7.7 -- building static lib...
-- JsonCpp Version: 1.7.7

然后我按照推荐的URL,下载了最新版本1.9,安装了它,从系统存储库中删除了包,重新运行./build.sh。然后我得到

-- Checking for module 'jsoncpp>=1.7.7'
--   Found jsoncpp, version 1.9.0

但重新启动后,工作区 ID 仍然没有出现:(

编辑 事实证明我当然必须激活 i3 模块。它不是示例 Polybar 配置的一部分,但在正确完成的问题中。我需要

...
modules-left = i3
...

然后它就可以正常工作,即使不需要jsoncpp手动安装。好的!

答案2

有同样的问题并修复它。在某些 Polybar 配置中,如果未按默认名称调用工作区,您将无法看到工作区。

我在您的 i3 配置中看到您将每个工作区命名为:1:2:等等。为了解决我的问题,我将每个工作区名称重新定义为其默认名称:12

相关内容