refactor(cmake): Install components

This commit is contained in:
Michael Carlberg 2016-12-23 18:10:19 +01:00
parent 70bb6f61d4
commit 92424f0d49
11 changed files with 379 additions and 158 deletions

View File

@ -18,7 +18,7 @@ include(build/summary)
add_subdirectory(${PROJECT_SOURCE_DIR}/man)
add_subdirectory(${PROJECT_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}/bin)
add_subdirectory(${PROJECT_SOURCE_DIR}/examples ${PROJECT_BINARY_DIR}/examples)
add_subdirectory(${PROJECT_SOURCE_DIR}/doc ${PROJECT_BINARY_DIR}/doc)
if(BUILD_TESTS)
add_subdirectory(${PROJECT_SOURCE_DIR}/tests ${PROJECT_BINARY_DIR}/tests)

View File

@ -4,4 +4,4 @@ if(NOT USER_CONFIG_HOME)
endif()
set(USER_CONFIG_HOME ${USER_CONFIG_HOME}/polybar)
file(INSTALL @CMAKE_SOURCE_DIR@/examples/config DESTINATION ${USER_CONFIG_HOME})
file(INSTALL @CMAKE_SOURCE_DIR@/doc/config DESTINATION ${USER_CONFIG_HOME})

View File

@ -69,7 +69,8 @@ function(make_executable target_name)
install(TARGETS ${target_name}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT runtime)
endfunction()
# }}}
@ -154,7 +155,8 @@ function(make_library target_name)
install(TARGETS ${LIBRARY_TARGETS}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT library)
endforeach()
endfunction()

View File

@ -74,12 +74,12 @@ endif()
# Configure and install {{{
configure_file(
${PROJECT_SOURCE_DIR}/examples/config.cmake
${CMAKE_SOURCE_DIR}/examples/config
${PROJECT_SOURCE_DIR}/doc/config.cmake
${CMAKE_SOURCE_DIR}/doc/config
ESCAPE_QUOTES @ONLY)
install(FILES config
DESTINATION share/examples/polybar
DESTINATION share/doc/polybar
COMPONENT config)
# }}}

356
doc/config Normal file
View File

@ -0,0 +1,356 @@
;=====================================================
;
; To learn more about how to configure Polybar
; go to https://github.com/jaagr/polybar
;
; The README contains alot of information
;
;=====================================================
[colors]
background = #222
background-alt = #444
foreground = #dfdfdf
foreground-alt = #55
primary = #ffb52a
secondary = #e60053
alert = #bd2c40
[global/wm]
margin-top = 5
margin-bottom = 5
[bar/example]
;monitor = ${env:MONITOR:HDMI-1}
width = 100%
height = 27
offset-x = 0
offset-y = 0
;background = ${xrdb:color9}
background = ${colors.background}
foreground = ${colors.foreground}
overline-size = 2
overline-color = #f00
underline-size = 2
underline-color = #00f
border-bottom = 2
border-bottom-color = #333
spacing = 1
padding-left = 0
padding-right = 2
module-margin-left = 1
module-margin-right = 2
font-0 = fixed:pixelsize=10;0
font-1 = unifont:size=6:heavy:fontformat=truetype;-2
font-2 = siji:pixelsize=10;0
modules-left = bspwm i3 xwindow
modules-center =
modules-right = backlight volume xkeyboard memory cpu 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:...%
[module/xkeyboard]
type = internal/xkeyboard
blacklist-0 = num lock
format-underline = ${colors.secondary}
format-prefix = " "
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
mount-2 = /invalid/mountpoint
label-mounted = %mountpoint%: %percentage_free%
label-unmounted = %mountpoint%: not mounted
label-unmounted-foreground = ${colors.foreground-alt}
[module/bspwm]
type = internal/bspwm
ws-icon-default = x
label-focused = %index%
label-focused-background = ${colors.background-alt}
label-focused-underline= ${colors.primary}
label-focused-padding = 2
label-occupied = %index%
label-occupied-padding = 2
label-urgent = %index%!
label-urgent-background = ${colors.alert}
label-urgent-padding = 2
label-empty = %index%
label-empty-foreground = ${colors.foreground-alt}
label-empty-padding = 2
[module/i3]
type = internal/i3
format = <label-state> <label-mode>
index-sort = true
wrapping-scroll = false
label-mode-padding = 2
label-mode-foreground = #000
label-mode-background = ${colors.primary}
label-focused = %index%
label-focused-background = ${module/bspwm.label-focused-background}
label-focused-underline = ${module/bspwm.label-focused-underline}
label-focused-padding = ${module/bspwm.label-focused-padding}
label-unfocused = %index%
label-unfocused-padding = ${module/bspwm.label-occupied-padding}
label-urgent = %index%!
label-urgent-background = ${module/bspwm.label-urgent-background}
label-urgent-padding = ${module/bspwm.label-urgent-padding}
label-visible = %index%
label-visible-background = ${self.label-focused-background}
label-visible-underline = ${self.label-focused-underline}
label-visible-padding = ${self.label-focused-padding}
[module/mpd]
type = internal/mpd
format-online = <label-song> <icon-prev> <icon-seekb> <icon-stop> <toggle> <icon-seekf> <icon-next> <icon-repeat> <icon-random>
label-song-maxlen = 25
label-song-ellipsis = true
icon-prev = 
icon-seekb = 
icon-stop = 
icon-play = 
icon-pause = 
icon-next = 
icon-seekf = 
icon-random = 
icon-repeat = 
toggle-on-foreground = ${colors.primary}
toggle-off-foreground = #66
[module/backlight]
type = internal/xbacklight
format = <label> <bar>
label = BL
bar-width = 10
bar-indicator = │
bar-indicator-foreground = #ff
bar-indicator-font = 2
bar-fill = ─
bar-fill-font = 2
bar-fill-foreground = #9f78e1
bar-empty = ─
bar-empty-font = 2
bar-empty-foreground = ${colors.foreground-alt}
[module/cpu]
type = internal/cpu
interval = 2
format-prefix = " "
format-prefix-foreground = ${colors.foreground-alt}
format-underline = #f90000
label = %percentage%
[module/memory]
type = internal/memory
interval = 2
format-prefix = " "
format-prefix-foreground = ${colors.foreground-alt}
format-underline = #4bffdc
label = %percentage_used%
[module/wlan]
type = internal/network
interface = net1
interval = 3.0
format-connected = <ramp-signal> <label-connected>
format-connected-underline = #9f78e1
format-disconnected-underline = ${self.format-connected-underline}
label-connected = %essid%
label-disconnected = %ifname% disconnected
label-disconnected-foreground = ${colors.foreground-alt}
ramp-signal-0 = 
ramp-signal-1 = 
ramp-signal-2 = 
ramp-signal-3 = 
ramp-signal-4 = 
ramp-signal-foreground = ${colors.foreground-alt}
[module/eth]
type = internal/network
interface = net0
interval = 3.0
format-connected-underline = #55aa55
format-connected-prefix = " "
format-connected-foreground-foreground = ${colors.foreground-alt}
label-connected = %local_ip%
format-disconnected-underline = ${self.format-connected-underline}
label-disconnected = %ifname% disconnected
label-disconnected-foreground = ${colors.foreground-alt}
[module/date]
type = internal/date
interval = 5
date =
date-alt = " %Y-%m-%d"
time = %H:%M
time-alt = %H:%M:%S
format-prefix = 
format-prefix-foreground = ${colors.foreground-alt}
format-underline = #0a6cf5
label = %date% %time%
[module/volume]
type = internal/volume
format-volume = <label-volume> <bar-volume>
label-volume = VOL
label-volume-foreground = ${root.foreground}
format-muted-prefix = " "
format-muted-foreground = ${colors.foreground-alt}
label-muted = sound muted
bar-volume-width = 10
bar-volume-foreground-0 = #55aa55
bar-volume-foreground-1 = #55aa55
bar-volume-foreground-2 = #55aa55
bar-volume-foreground-3 = #55aa55
bar-volume-foreground-4 = #55aa55
bar-volume-foreground-5 = #f5a70a
bar-volume-foreground-6 = #ff5555
bar-volume-gradient = false
bar-volume-indicator = │
bar-volume-indicator-font = 2
bar-volume-indicator-foreground = #ff
bar-volume-fill = ─
bar-volume-fill-font = 2
bar-volume-empty = ─
bar-volume-empty-font = 2
bar-volume-empty-foreground = ${colors.foreground-alt}
[module/battery]
type = internal/battery
battery = BAT0
adapter = ADP1
full-at = 98
format-charging = <animation-charging> <label-charging>
format-charging-underline = #ffb52a
format-discharging = <ramp-capacity> <label-discharging>
format-discharging-underline = ${self.format-charging-underline}
format-full-prefix = " "
format-full-prefix-foreground = ${colors.foreground-alt}
format-full-underline = ${self.format-charging-underline}
ramp-capacity-0 = 
ramp-capacity-1 = 
ramp-capacity-2 = 
ramp-capacity-foreground = ${colors.foreground-alt}
animation-charging-0 = 
animation-charging-1 = 
animation-charging-2 = 
animation-charging-foreground = ${colors.foreground-alt}
animation-charging-framerate = 750
[module/temperature]
type = internal/temperature
thermal-zone = 0
warn-temperature = 60
format = <ramp> <label>
format-underline = #f50a4d
format-warn = <ramp> <label-warn>
format-warn-underline = ${self.format-underline}
label = %temperature%
label-warn = %temperature%
label-warn-foreground = ${colors.secondary}
ramp-0 = 
ramp-1 = 
ramp-2 = 
ramp-foreground = ${colors.foreground-alt}
[module/powermenu]
type = custom/menu
label-open =  power
label-open-foreground = ${colors.secondary}
label-close =  cancel
label-close-foreground = ${colors.secondary}
label-separator = |
label-separator-foreground = ${colors.foreground-alt}
menu-0-0 = reboot
menu-0-0-exec = menu-open-1
menu-0-1 = power off
menu-0-1-exec = menu-open-2
menu-1-0 = cancel
menu-1-0-exec = menu-open-0
menu-1-1 = reboot
menu-1-1-exec = sudo reboot
menu-2-0 = power off
menu-2-0-exec = sudo poweroff
menu-2-1 = cancel
menu-2-1-exec = menu-open-0
; vim:ft=dosini

View File

@ -1,5 +1,4 @@
set(MAN_PAGES_1 polybar.1)
# set(MAN_PAGES_5 polybar_config.5)
INSTALL(FILES ${MAN_PAGES_1} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1 COMPONENT doc)
# INSTALL(FILES ${MAN_PAGES_5} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man5 COMPONENT doc)
INSTALL(FILES ${MAN_PAGES_1}
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1
COMPONENT doc)

View File

@ -6,7 +6,7 @@ VERSION = $(shell git describe --tags)
DATE = $(shell date +%Y-%m-%d)
# Sources
MAN_SOURCES = $(wildcard *.1 *.5)
MAN_SOURCES = $(wildcard *.1)
GZ_FILES = $(addsuffix .gz,$(MAN_SOURCES))
# Targets
all: $(GZ_FILES)
@ -17,7 +17,7 @@ update-versions:
@sed -i '1 s/"$(PROGRAM_NAME) [^"]*"/"$(PROGRAM_NAME) $(VERSION)"/' $(MAN_SOURCES)
update-dates:
@sed -i '1 s/[0-9]{4}\-[0-9]{2}\-[0-9]{2}/$(DATE)/' $(MAN_SOURCES)
@sed -r -i '1 s/[0-9]{4}\-[0-9]{2}\-[0-9]{2}/$(DATE)/' $(MAN_SOURCES)
# Documentation targets
%.1.gz: %.1
@ -31,9 +31,6 @@ update-dates:
polybar: polybar.1
mandoc -a $<
polybar_config: polybar_config.5
mandoc -a $<
clean:
@echo '[CLEAN]'
@rm -f $(GZ_FILES)

View File

@ -1,4 +1,4 @@
.TH polybar 1 2016-10-18 "polybar 2.0.0" "User Manual"
.TH polybar 1 2016-12-23 "polybar 2.4.2-1-g70bb6f6" "User Manual"
.SH NAME
\fBpolybar\fR \- A fast and easy-to-use tool status bar.
.SH SYNOPSIS
@ -7,9 +7,9 @@ polybar \fIBAR-NAME\fR [\fB\-c\fR \fICONFIG\fR|\fB\-l\fR \fILOG_LEVEL\fR|\fB\-d\
.P
polybar [\fB\-h\fR | \fB\-\-help\fR]
.SH DESCRIPTION
\fBPolybar\fR aims to help users build beautiful and highly customizable status bars without messing with named pipes, MacGyver-like scripting or non-blocking loops lobotomizing your CPU.
\fBPolybar\fR aims to help users build beautiful and highly customizable status bars for their desktop environment, without the need of having a black belt in shell scripting.
.P
Please not that the project is still in early development, so please report any anomalies by creating an issue on GitHub (\fIhttps://github.com/jaagr/polybar\fR).
Please report issues by creating a ticket on GitHub (\fIhttps://github.com/jaagr/polybar\fR).
.P
Mandatory arguments to long options are mandatory for short options too.
.TP
@ -20,7 +20,7 @@ Show help and program options.
Print version information.
.TP
\fB\-l\fR, \fB\-\-log\fR=\fILEVEL\fR
Set how verbose \fBpolybar\fR's logging is. \fILEVEL\fR must be one of: `warning` or `info`.
Set how verbose \fBpolybar\fR's logging is. \fILEVEL\fR must be one of: `error`, `warning` or `info`.
.TP
\fB\-q\fR, \fB\-\-quiet\fR
Be quiet (will override -l).
@ -39,9 +39,6 @@ Print the generated \fIWM_NAME\fR.
.TP
\fB\-s\fR, \fB\-\-stdout\fR
Dump content to stdout instead of rendering an X window.
.SH SEE ALSO
.TP
\fBpolybar_config\fR(5)
.RE
.SH HOMEPAGE
.sp

View File

@ -1,129 +0,0 @@
.TH polybar_config 5 2016-10-18 "polybar 2.0.0" "User Configuration"
.SH NAME
.\" This man page will need lots of updating as documentation about polybar
.\" configuration improves.
\fBpolybar_config\fR \- Configuration for a \fBpolybar\fR(1) bar.
.SH SYNOPSIS
.BR $XDG_CONFIG_HOME/.config/polybar/config
.P
.BR ~/.config/polybar/config
.SH SYNTAX
.nf
.TP
The configuration syntax is based on the \fIini\fR file format.
.TP
A sample config section with various field types:
[section/name]
str = My string
; Quote the value to keep surrounding spaces
str = " My string"
bool = true
bool = on
int = 10
float = 10.0
.TP
Values defined in another section can be referenced using:
key = \fI${bar/top.foreground}\fR
.TP
Read the value of an environment variable using:
key = \fI${env:MYVAR}\fR
.TP
Use BAR to target the section of the current bar:
key = \fI${BAR.foreground}\fR
.TP
Most modules define a format-N field. The formats define a set of tags. For example, the mpd module defines the following formats:
\fIformat-online\fR = ... <label-song> <icon-play> ...
\fIformat-offline\fR = the server is offline
.TP
The modules will toggle between the formats and only show the one defined for the current module state.
.TP
Each format contains the following fields:
format[-NAME]-padding = N (unit: whitespaces)
format[-NAME]-margin = N (unit: whitespaces)
format[-NAME]-spacing = N (unit: whitespaces)
format[-NAME]-offset = N (unit: pixels)
format[-NAME]-foreground = #aa[rrggbb]
format[-NAME]-background = #aa[rrggbb]
format[-NAME]-underline = #aa[rrggbb]
format[-NAME]-overline = #aa[rrggbb]
.TP
The rest of the drawtypes follow the same pattern.
.\" TODO: Describe the drawtypes
label-NAME[-(foreground|background|(under|over)line|font|padding|maxlen|ellipsis)] = ?
icon-NAME[-(foreground|background|(under|over)line|font|padding)] = ?
ramp-NAME-[0-9]+[-(foreground|background|(under|over)line|font|padding)] = ?
animation-NAME-[0-9]+[-(foreground|background|(under|over)line|font|padding)] = ?
bar-NAME-width = N (unit: characters)
bar-NAME-format = (tokens: %fill% %indicator% %empty%)
bar-NAME-foreground-[0-9]+ = #aarrggbb
bar-NAME-indicator[-(foreground|background|(under|over)line|font|padding)] =
bar-NAME-fill[-(foreground|background|(under|over)line|font|padding)] =
bar-NAME-empty[-(foreground|background|(under|over)line|font|padding)] =
.fi
.SH APPLICATION SETTINGS
These settings should exist in the `settings` section within the configuration file.
.TP
\fBthrottle-limit\fR and \fBthrottle-ms\fR
Limit the amount of update events within a set timeframe. Allow at most \fIthrottle-limit\fR updates within \fIthrottle-ms\fR milliseconds.
.SH BAR SETTINGS
These settings should be defined in the [bar/\fIBAR\-NAME\fR] section.
.TP
.BR monitor
Which display to output the bar to. You can get a list of available outputs by using the command `xrandr -q | grep " connected" | cut -d ' ' -f1`.
If unspecified, the application will pick the first one it finds.
.TP
\fBwidth\fR, \fBheight\fR
How large the bar should be. You can specify the values as a percentage of the screen, for example `85%`, or omit the `%` and give the dimension(s) in pixels.
.TP
\fBoffset-x\fR, \fBoffset-y\fR
The window offset value in pixels.
.TP
.BR bottom
Put the bar at the bottom of the screen.
.TP
.BR dock
If this boolean is set to `true`, then force the X window to dock itself.
If you are using \fBi3\fR(1) it is recommended to use the default value.
.TP
.BR spacing
This integer value is used as a multiplier when adding spaces between elements.
.TP
.BR lineheight
How high underlines and overlines should be.
.TP
\fBbackground\fR, \fBforeground\fR, \fBlinecolor\fR
Specify the colors used to draw the bar.
.TP
\fBpadding-left\fR, \fBpadding-right\fR
Specify the number of spaces to add at the start or end of the entire bar.
.TP
\fBmodule-margin-left\fR, \fBmodule-margin-right\fR
Specify the number of spaces to add before or after each module.
.TP
.BR font\-\fIid\fR
Here you can specify which fonts you wish to use. You need to set \fIid\fR to be a positive integer. The font should be specified in the following format: `\fIFONT\-NAME\fR:size=\fIFONT\-SIZE\fR;\fIOFFSET\fR`. For example, you could set `font\-0` to be `NotoSans-Regular:size=8;0`.
.TP
.BR wm-name
The value to set \fIWM_NAME\fR to when running. This defaults to `polybar\-\fIBAR-NAME\fR_\fIMONITOR\fR`.
.TP
.BR locale
Which locale to use.
.TP
\fBmodules-left\fR, \fBmodules-center\fR, \fBmodules-right\fR
Define which modules to use in the bar.
.SH EXAMPLES
.\" TODO add examples
There are no examples yet.
.SH SEE ALSO
.TP
\fBpolybar\fR(1)

View File

@ -476,18 +476,17 @@ bool controller::on(const sig_ev::process_update& evt) {
* Process eventqueue input event
*/
bool controller::on(const sig_ev::process_input& evt) {
string input{*evt()};
m_log.warn("Uncaught input event, forwarding to shell... (input: %s)", input);
try {
string input{*evt()};
m_log.warn("Uncaught input event, forwarding to shell... (input: %s)", input);
if (m_command) {
m_log.warn("Terminating previous shell command");
m_command->terminate();
}
m_log.info("Executing shell command: %s", input);
m_command = command_util::make_command(move(input));
m_command->exec();
m_command.reset();
@ -502,7 +501,7 @@ bool controller::on(const sig_ev::process_input& evt) {
* Process eventqueue quit event
*/
bool controller::on(const sig_ev::process_quit& evt) {
raise(evt.data()->flag ? SIGUSR1 : SIGALRM);
raise((*evt()).flag ? SIGUSR1 : SIGALRM);
return true;
}