如何在Fedora上安装Polybar状态栏
时间:2020-02-23 14:33:20 来源:igfitidea点击:
Polybar是一个创建的工具,以帮助用户构建美丽且高度可自定义的状态栏,大多数用户运行窗口经理应该知道这个工具。
PolyBar可以配置为替换传统桌面环境,而不会掌握shell脚本。
本教程将通过安装和配置Polybar状态栏的步骤来步行,以便在Fedora工作站上使用i3WM。
Polybar的特征
通过安装/构建PolyBar,我们将在状态栏上设置以下服务。
Systray IconsWindow标题播放控制和状态显示MPD的MPD使用libmpdclientalsa volument controlsworkspace和桌面面板为bspwm和i3workspace模块,用于ewmh兼容窗口经理管理器,指示器statuscpu和记忆负载指示灯DateNation National Displaynet连接详细信息Walklight和时间基于标签时间的shell脚本executioncommand输出DialingUser定义菜单Treeinter-Process Messaging和更多...
第1步:安装开发工具。
对于Fedora Systems,存储库中不可用PolyBar包。
我们将从来源构建它,因此需要开发工具。
sudo dnf install -y @development-tools cmake gcc-c++ autoconf automake
安装I3,音量控制,MPD,网络,GitHub 等的构建依赖项。
sudo dnf install xcb-util-xrm-devel xcb-proto xcb-util-devel xcb-util-wm-devel xcb-util-cursor-devel xcb-util-image-devel alsa-lib-devel pulseaudio-libs-devel i3-ipc i3-devel jsoncpp-devel libmpdclient-devel libcurl-devel wireless-tools-devel libnl3-devel cairo-devel
第2步:下载最新的PolyBar源。
在安装依赖项后,通过克隆Github存储库下载最新版本PolyBar。
cd /tmp git clone --recursive https://github.com/polybar/polybar
要编译和安装polybar,请运行以下命令:
cd polybar sudo ./build.sh
我们应该获得类似的
** Fetching submodules ** A build dir already exists (pass -f to replace) ** Setting build options ** Use GCC even if Clang is installed ----------------------------- [y/N]: y ** Include support for "internal/i3" (requires i3) ---------------- [y/N]: ** Include support for "internal/alsa" (requires alsalib) --------- [y/N]: y ** Include support for "internal/pulseaudio" (requires libpulse) -- [y/N]: y ** Include support for "internal/network" (requires libnl/libiw) -- [y/N]: y ** Include support for "internal/mpd" (requires libmpdclient) ----- [y/N]: y ** Include support for "internal/github" (requires libcurl) ------- [y/N]: y ** Build "polybar-msg" used to send ipc messages ------------------ [y/N]: y ** Executing cmake command -- Trying to enable ccache -- Couldn't locate ccache, disabling ccache... -- The CXX compiler identification is GNU 9.1.1 -- Check for working CXX compiler: /usr/bin/g++ -- Check for working CXX compiler: /usr/bin/g++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done y-- Detecting CXX compile features -- Detecting CXX compile features - done -- No build type specified; using Release -- Using supported compiler GNU-9.1.1 -- Found PkgConfig: /usr/bin/pkg-config (found version "1.6.1") -- Looking for C++ include pthread.h -- Looking for C++ include pthread.h - found -- Looking for pthread_create -- Looking for pthread_create - not found -- Check if compiler accepts -pthread -- Check if compiler accepts -pthread - yes -- Found Threads: TRUE -- Checking for module 'cairo-fc' -- Found cairo-fc, version 1.16.0 -- Checking for module 'alsa' -- Found alsa, version 1.1.9 -- Checking for module 'libcurl' -- Found libcurl, version 7.64.0 -- Checking for module 'libmpdclient' -- Found libmpdclient, version 2.14 -- Checking for module 'libnl-genl-3.0' -- Found libnl-genl-3.0, version 3.4.0 -- Checking for module 'libpulse' -- Found libpulse, version 12.2-rebootstrapped -- Checking for module 'xcb-composite' -- Found xcb-composite, version 1.13.1 -- Checking for module 'xcb-xkb' -- Found xcb-xkb, version 1.13.1 -- Checking for module 'xcb-randr' -- Found xcb-randr, version 1.13.1 -- Checking for module 'xcb-randr>=1.12' -- Found xcb-randr, version 1.13.1 -- Checking for module 'xcb-xrm' -- Found xcb-xrm, version 1.3 -- Checking for module 'xcb-cursor' -- Found xcb-cursor, version 0.1.3 -- Build: -- Version: 3.3.0-98-gc650513 -- Type: Release -- CXX: /usr/bin/g++ -Wall -Wextra -Wpedantic -O2 -DNDEBUG -- LD: /usr/bin/ld -- Targets: -- [X] polybar-msg -- [ ] testsuite -- [ ] documentation -- Module support: -- [X] alsa (1.1.9) -- [X] curl (7.64.0) -- [ ] i3 -- [X] mpd (2.14) -- [X] network (libnl) (3.4.0) -- [X] pulseaudio (12.2-rebootstrapped) -- [X] xkeyboard (1.13.1) -- X extensions: -- [X] xcb-randr (1.13.1) -- [X] xcb-randr (monitor support) (1.13.1) -- [X] xcb-composite (1.13.1) -- [X] xcb-xkb (1.13.1) -- [X] xcb-xrm (1.3) -- [X] xcb-cursor (0.1.3) -- Log options: -- [X] Trace logging -- The C compiler identification is GNU 9.1.1 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Checking for module 'xcb-proto' -- Found xcb-proto, version 1.13 -- Found PythonInterp: /usr/bin/python2.7 (found suitable version "2.7.16", minimum required is "2.7") -- XCB[XCB]: Found component XCB -- Found XCB_XCB: /usr/lib64/libxcb.so -- XCB[ICCCM]: Found component ICCCM -- Found XCB_ICCCM: /usr/lib64/libxcb-icccm.so -- XCB[EWMH]: Found component EWMH -- Found XCB_EWMH: /usr/lib64/libxcb-ewmh.so -- XCB[UTIL]: Found component UTIL -- Found XCB_UTIL: /usr/lib64/libxcb-util.so -- XCB[IMAGE]: Found component IMAGE -- Found XCB_IMAGE: /usr/lib64/libxcb-image.so -- Found XCB: /usr/lib64/libxcb.so;/usr/lib64/libxcb-icccm.so;/usr/lib64/libxcb-ewmh.so;/usr/lib64/libxcb-util.so;/usr/lib64/libxcb-image.so -- Searching for xcbgen with python2 -- Searching for xcbgen with python2.7 -- Searching for xcbgen with python3 -- Found xcbgen in /usr/lib/python3.7/site-packages -- XCB[RANDR]: Found component RANDR -- Found XCB_RANDR: /usr/lib64/libxcb-randr.so -- Found XCB: /usr/lib64/libxcb.so;/usr/lib64/libxcb-icccm.so;/usr/lib64/libxcb-ewmh.so;/usr/lib64/libxcb-util.so;/usr/lib64/libxcb-image.so;/usr/lib64/libxcb-randr.so -- XCB[COMPOSITE]: Found component COMPOSITE -- Found XCB_COMPOSITE: /usr/lib64/libxcb-composite.so -- Found XCB: /usr/lib64/libxcb.so;/usr/lib64/libxcb-icccm.so;/usr/lib64/libxcb-ewmh.so;/usr/lib64/libxcb-util.so;/usr/lib64/libxcb-image.so;/usr/lib64/libxcb-randr.so;/usr/lib64/libxcb-composite.so -- XCB[XKB]: Found component XKB -- Found XCB_XKB: /usr/lib64/libxcb-xkb.so -- Found XCB: /usr/lib64/libxcb.so;/usr/lib64/libxcb-icccm.so;/usr/lib64/libxcb-ewmh.so;/usr/lib64/libxcb-util.so;/usr/lib64/libxcb-image.so;/usr/lib64/libxcb-randr.so;/usr/lib64/libxcb-composite.so;/usr/lib64/libxcb-xkb.so -- xpp: including xcb proto composite.xml -- xpp: including xcb proto randr.xml -- xpp: including xcb proto xkb.xml -- xpp: including xcb proto xproto.xml -- Font not found: fixed:pixelsize=10 -- Font not found: unifont:fontformat=truetype -- Font not found: siji:pixelsize=10 -- Configuring done -- Generating done -- Build files have been written to: /home/jmutai/Downloads/polybar/build ** Building project [ 1%] Generating ../../../lib/xpp/include/xpp/proto/x.hpp [ 2%] Generating ../../../lib/xpp/include/xpp/proto/composite.hpp [ 3%] Generating ../../../lib/xpp/include/xpp/proto/randr.hpp list: size, ['red', 'green', 'blue'] list: size, ['red', 'green', 'blue'] [ 4%] Generating ../../../lib/xpp/include/xpp/proto/xkb.hpp Scanning dependencies of target xpp [ 5%] Linking CXX static library libxpp.a [ 5%] Built target xpp Scanning dependencies of target poly [ 6%] Building CXX object bin/CMakeFiles/poly.dir/adapters/alsa/control.cpp.o [ 7%] Building CXX object bin/CMakeFiles/poly.dir/adapters/alsa/mixer.cpp.o [ 8%] Building CXX object bin/CMakeFiles/poly.dir/adapters/mpd.cpp.o [ 9%] Building CXX object bin/CMakeFiles/poly.dir/adapters/net.cpp.o [ 10%] Building CXX object bin/CMakeFiles/poly.dir/adapters/net_nl.cpp.o [ 12%] Building CXX object bin/CMakeFiles/poly.dir/adapters/pulseaudio.cpp.o [ 13%] Building CXX object bin/CMakeFiles/poly.dir/cairo/utils.cpp.o [ 14%] Building CXX object bin/CMakeFiles/poly.dir/components/bar.cpp.o [ 15%] Building CXX object bin/CMakeFiles/poly.dir/components/builder.cpp.o [ 16%] Building CXX object bin/CMakeFiles/poly.dir/components/command_line.cpp.o [ 17%] Building CXX object bin/CMakeFiles/poly.dir/components/config.cpp.o [ 18%] Building CXX object bin/CMakeFiles/poly.dir/components/controller.cpp.o [ 19%] Building CXX object bin/CMakeFiles/poly.dir/components/ipc.cpp.o [ 20%] Building CXX object bin/CMakeFiles/poly.dir/components/logger.cpp.o [ 21%] Building CXX object bin/CMakeFiles/poly.dir/components/parser.cpp.o [ 23%] Building CXX object bin/CMakeFiles/poly.dir/components/renderer.cpp.o [ 24%] Building CXX object bin/CMakeFiles/poly.dir/components/screen.cpp.o [ 25%] Building CXX object bin/CMakeFiles/poly.dir/components/taskqueue.cpp.o [ 26%] Building CXX object bin/CMakeFiles/poly.dir/drawtypes/animation.cpp.o [ 27%] Building CXX object bin/CMakeFiles/poly.dir/drawtypes/iconset.cpp.o [ 28%] Building CXX object bin/CMakeFiles/poly.dir/drawtypes/label.cpp.o [ 29%] Building CXX object bin/CMakeFiles/poly.dir/drawtypes/progressbar.cpp.o [ 30%] Building CXX object bin/CMakeFiles/poly.dir/drawtypes/ramp.cpp.o [ 31%] Building CXX object bin/CMakeFiles/poly.dir/events/signal_emitter.cpp.o [ 32%] Building CXX object bin/CMakeFiles/poly.dir/events/signal_receiver.cpp.o [ 34%] Building CXX object bin/CMakeFiles/poly.dir/modules/alsa.cpp.o [ 35%] Building CXX object bin/CMakeFiles/poly.dir/modules/backlight.cpp.o [ 36%] Building CXX object bin/CMakeFiles/poly.dir/modules/battery.cpp.o [ 37%] Building CXX object bin/CMakeFiles/poly.dir/modules/bspwm.cpp.o [ 38%] Building CXX object bin/CMakeFiles/poly.dir/modules/counter.cpp.o [ 39%] Building CXX object bin/CMakeFiles/poly.dir/modules/cpu.cpp.o [ 40%] Building CXX object bin/CMakeFiles/poly.dir/modules/date.cpp.o [ 41%] Building CXX object bin/CMakeFiles/poly.dir/modules/fs.cpp.o [ 42%] Building CXX object bin/CMakeFiles/poly.dir/modules/github.cpp.o [ 43%] Building CXX object bin/CMakeFiles/poly.dir/modules/ipc.cpp.o [ 45%] Building CXX object bin/CMakeFiles/poly.dir/modules/memory.cpp.o [ 46%] Building CXX object bin/CMakeFiles/poly.dir/modules/menu.cpp.o [ 47%] Building CXX object bin/CMakeFiles/poly.dir/modules/meta/base.cpp.o [ 48%] Building CXX object bin/CMakeFiles/poly.dir/modules/mpd.cpp.o [ 49%] Building CXX object bin/CMakeFiles/poly.dir/modules/network.cpp.o [ 50%] Building CXX object bin/CMakeFiles/poly.dir/modules/pulseaudio.cpp.o [ 51%] Building CXX object bin/CMakeFiles/poly.dir/modules/script.cpp.o [ 52%] Building CXX object bin/CMakeFiles/poly.dir/modules/systray.cpp.o [ 53%] Building CXX object bin/CMakeFiles/poly.dir/modules/temperature.cpp.o [ 54%] Building CXX object bin/CMakeFiles/poly.dir/modules/text.cpp.o [ 56%] Building CXX object bin/CMakeFiles/poly.dir/modules/xbacklight.cpp.o [ 57%] Building CXX object bin/CMakeFiles/poly.dir/modules/xkeyboard.cpp.o [ 58%] Building CXX object bin/CMakeFiles/poly.dir/modules/xwindow.cpp.o [ 59%] Building CXX object bin/CMakeFiles/poly.dir/modules/xworkspaces.cpp.o [ 60%] Building CXX object bin/CMakeFiles/poly.dir/utils/bspwm.cpp.o [ 61%] Building CXX object bin/CMakeFiles/poly.dir/utils/command.cpp.o [ 62%] Building CXX object bin/CMakeFiles/poly.dir/utils/concurrency.cpp.o [ 63%] Building CXX object bin/CMakeFiles/poly.dir/utils/env.cpp.o [ 64%] Building CXX object bin/CMakeFiles/poly.dir/utils/factory.cpp.o [ 65%] Building CXX object bin/CMakeFiles/poly.dir/utils/file.cpp.o [ 67%] Building CXX object bin/CMakeFiles/poly.dir/utils/http.cpp.o [ 68%] Building CXX object bin/CMakeFiles/poly.dir/utils/inotify.cpp.o [ 69%] Building CXX object bin/CMakeFiles/poly.dir/utils/io.cpp.o [ 70%] Building CXX object bin/CMakeFiles/poly.dir/utils/process.cpp.o [ 71%] Building CXX object bin/CMakeFiles/poly.dir/utils/socket.cpp.o [ 72%] Building CXX object bin/CMakeFiles/poly.dir/utils/string.cpp.o [ 73%] Building CXX object bin/CMakeFiles/poly.dir/utils/throttle.cpp.o [ 74%] Building CXX object bin/CMakeFiles/poly.dir/x11/atoms.cpp.o [ 75%] Building CXX object bin/CMakeFiles/poly.dir/x11/background_manager.cpp.o [ 76%] Building CXX object bin/CMakeFiles/poly.dir/x11/connection.cpp.o [ 78%] Building CXX object bin/CMakeFiles/poly.dir/x11/cursor.cpp.o [ 79%] Building CXX object bin/CMakeFiles/poly.dir/x11/ewmh.cpp.o [ 80%] Building CXX object bin/CMakeFiles/poly.dir/x11/extensions/composite.cpp.o [ 81%] Building CXX object bin/CMakeFiles/poly.dir/x11/extensions/randr.cpp.o [ 82%] Building CXX object bin/CMakeFiles/poly.dir/x11/extensions/xkb.cpp.o [ 83%] Building CXX object bin/CMakeFiles/poly.dir/x11/icccm.cpp.o [ 84%] Building CXX object bin/CMakeFiles/poly.dir/x11/registry.cpp.o [ 85%] Building CXX object bin/CMakeFiles/poly.dir/x11/tray_client.cpp.o [ 86%] Building CXX object bin/CMakeFiles/poly.dir/x11/tray_manager.cpp.o [ 87%] Building CXX object bin/CMakeFiles/poly.dir/x11/window.cpp.o [ 89%] Building CXX object bin/CMakeFiles/poly.dir/x11/winspec.cpp.o [ 90%] Building CXX object bin/CMakeFiles/poly.dir/x11/xembed.cpp.o [ 91%] Building CXX object bin/CMakeFiles/poly.dir/x11/xresources.cpp.o [ 92%] Linking CXX static library libpoly.a [ 92%] Built target poly Scanning dependencies of target polybar [ 93%] Building CXX object bin/CMakeFiles/polybar.dir/main.cpp.o [ 94%] Linking CXX executable polybar [ 94%] Built target polybar Scanning dependencies of target polybar-msg [ 95%] Building CXX object bin/CMakeFiles/polybar-msg.dir/ipc.cpp.o [ 96%] Building CXX object bin/CMakeFiles/polybar-msg.dir/utils/env.cpp.o [ 97%] Building CXX object bin/CMakeFiles/polybar-msg.dir/utils/file.cpp.o [ 98%] Building CXX object bin/CMakeFiles/polybar-msg.dir/utils/string.cpp.o [100%] Linking CXX executable polybar-msg [100%] Built target polybar-msg ** Execute 'sudo make install'? [Y/n] ** Install example configuration? [y/N]: y [ 5%] Built target xpp [ 92%] Built target poly [ 94%] Built target polybar [100%] Built target polybar-msg Install the project... -- Install configuration: "Release" -- Installing: /usr/local/share/doc/polybar/config -- Installing: /usr/local/share/bash-completion/completions/polybar -- Installing: /usr/local/share/zsh/site-functions/_polybar -- Installing: /usr/local/share/zsh/site-functions/_polybar_msg -- Installing: /usr/local/bin/polybar -- Installing: /usr/local/bin/polybar-msg [ 5%] Built target xpp [ 97%] Built target poly [100%] Built target polybar Scanning dependencies of target userconfig -- Installing: /root/.config/polybar/config [100%] Built target userconfig ** Build complete!
第3步:确认Polybar安装
确认Polybar安装和功能可用。
$which polybar /usr/local/bin/polybar $polybar --version polybar 3.3.0-98-gc650513 Features: +alsa +curl -i3 +mpd +network(libnl) +pulseaudio +xkeyboard
第4步:安装字体
在Fedora上安装字体:
# Powerline fonts/Fontawesome sudo dnf install powerline-fonts fontawesome-fonts # FiraCode font dnf copr enable evana/fira-code-fonts dnf install fira-code-fonts
配置Polybar.
我建议我们访问Polybar文档页面以了解其不同环境的配置。
下面是我的i3WM的PolyBar配置 - 路径:~/.config/polybar/config
;===================================================== ; ; To learn more about how to configure Polybar ; go to https://github.com/jaagr/polybar ; ; The README contains alot of information ; ;===================================================== [colors] background = #ee2f343f background-alt = #f72f343f foreground = #f3f4f5 foreground-alt = #f3f4f5 foreground-dim = #676e7d primary = #ffb52a secondary = #e60053 alert = #ff6600 high = #268bd2 high-alt = #0c2b41 ; other colors black = #000000 red = #E06C75 green = #98C379 orange = #D19A66 blue = #61AEEE magenta = #C678DD cyan = #56B6C2 lightgray = #ABB2BF darkgray = #5C6370 white = #FFFFFF [bar/main] ;monitor = ${env:MONITOR:HDMI-1} ;bottom = true override-redirect = true wm-restack = i3 width = 100% height = 18 offset-x = 0 offset-y = 0 ;radius = 6.0 ;fixed-center = false overline-size = 2 overline-color = #f00 underline-size = 2 underline-color = ${colors.high} background = ${colors.background} foreground = ${colors.foreground} line-size = 3 line-color = #f00 border-size = 4 border-color = #00000000 padding-left = 0 padding-right = 2 module-margin-left = 0 module-margin-right = 2 ;font-0 = fixed:pixelsize=10;1 ;font-1 = unifont:fontformat=truetype:size=8:antialias=false;0 font-0 = Monaco:size=8:weight=bold font-1 = FontAwesome:size=11 font-2 = siji:pixelsize=10;1 ;modules-left = menu i3 xwindow ;modules-left = menu i3 xwindow ;modules-left = i3 modules-center = mpd modules-right = fsroot fshome xkeyboard memory cpu xbacklight volume wlan eth battery temperature date powermenu tray-position = right tray-padding = 2 ;tray-transparent = true ;tray-background = #0063ff ;wm-restack = bspwm ;wm-restack = i3 ;override-redirect = true ;scroll-up = bspwm-desknext ;scroll-down = bspwm-deskprev ;scroll-up = i3wm-wsnext ;scroll-down = i3wm-wsprev [module/xwindow] type = internal/xwindow ;label = %title:0:30:...% label = %title:0:30:...% %{B- -o -u} [module/xkeyboard] type = internal/xkeyboard blacklist-0 = num lock format-prefix = " " format-underline = ${colors.secondary} format-prefix-foreground = ${colors.foreground-alt} label-layout = %layout% label-indicator-padding = 2 label-indicator-background = ${colors.secondary} label-indicator-underline = ${colors.secondary} #[module/filesystem] #type = internal/fs #interval = 25 ##mount-0 = / #mount-1 = /home ##label-mounted = %{F#0a81f5}%mountpoint%%{F-}: %free% #;label-mounted = %mountpoint%: %percentage_free%% of %total% #label-unmounted = %mountpoint% not mounted #label-unmounted-foreground = ${colors.foreground-alt} [module/bspwm] type = internal/bspwm label-focused = %name% label-focused-background = ${colors.background-alt} label-focused-underline= ${colors.primary} label-focused-padding = 2 label-occupied = %name% label-occupied-padding = 2 label-urgent = %name%! label-urgent-background = ${colors.alert} label-urgent-padding = 2 label-empty = %name% label-empty-foreground = ${colors.foreground-alt} label-empty-padding = 2 [module/i3] type = internal/i3 format = <label-state> <label-mode> name-sort = true strip-wsnumbers = true ;This will split the workspace name on ':' ws-icon-0 = 1; ws-icon-1 = 2; ws-icon-2 = 3; ws-icon-3 = 4; ws-icon-4 = 5; ws-icon-5 = 6; ws-icon-6 = 7; ws-icon-default = ♟ ; Only show workspaces on the same output as the bar ;pin-workspaces = true label-mode-padding = 2 label-mode-foreground = #000 label-mode-background = ${colors.primary} ; focused = Active workspace on focused monitor label-focused = %name% label-focused-background = ${module/bspwm.label-focused-background} label-focused-underline = ${module/bspwm.label-focused-underline} label-focused-padding = ${module/bspwm.label-focused-padding} ; unfocused = Inactive workspace on any monitor label-unfocused = %name% label-unfocused-padding = ${module/bspwm.label-occupied-padding} ; visible = Active workspace on unfocused monitor label-visible = %name% label-visible-background = ${self.label-focused-background} label-visible-underline = ${self.label-focused-underline} label-visible-padding = ${self.label-focused-padding} ; urgent = Workspace with urgency hint set label-urgent = %name% label-urgent-background = ${module/bspwm.label-urgent-background} label-urgent-padding = ${module/bspwm.label-urgent-padding} ; [module/mpd] type = internal/mpd format-online = <icon-prev> <toggle> <icon-next> <icon-random> <icon-repeat> <label-time> format-offline = <label-offline> label-offline = no music icon-prev = icon-stop = o icon-play = icon-pause = icon-next = icon-seekf = >> icon-random = icon-repeat = ;label-song =