Skip to content

Conversation

@patrick96
Copy link
Member

@patrick96 patrick96 commented Sep 28, 2021

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update
  • Other: Replace this with a description of the type of this PR

Description

I created a default config for polybar that should work everywhere (doesn't use any machine specific settings):

default

We ship it in /etc/polybar/config.ini and also now search for configs in XDG_CONFIG_DIRS/polybar and /etc/polybar.

The default config uses the following modules:

  • xworkspaces
  • xwindow
  • fs with just the root directory which should be its own partition hopefully
  • pulseaudio. Should work on most systems
  • xkeyboard
  • memory
  • cpu
  • network with interface-type (both wired and wireless)
  • date

It has pseudo-transparency enabled so that the transparent border works and uses the monospace font which should resolve to a sane font on most systems.

TODO:

  • Implement the config fallback (with .ini only) in the zsh and bash completion and fix the bash error

Related Issues & Documents

Closes #2405
Closes #2016

Documentation (check all applicable)

  • This PR requires changes to the Wiki documentation (describe the changes)
  • This PR requires changes to the documentation inside the git repo (please add them to the PR).
  • Does not require documentation changes

After the release:

We need to update the README and tell people, just running polybar example should work (because it will load the config in /etc/polybar/config.ini.

We should also update any mention of polybar/doc/config and use polybar/doc/examples/config.ini (or /etc/polybar/config.ini).

After the PR is merged, we can just update the wiki and mention that the default config can be found in /etc/polybar/config.ini if you are using the latest unreleased version.

We should also update any mention of config with config.ini

Update any mention of the "example config" or "sample config" with default config.

Remove any mention of the siji, misc-fixed, and unifont from the wiki and potentially adapt to the default config.

@patrick96 patrick96 added this to the 3.6.0 milestone Sep 28, 2021
@patrick96
Copy link
Member Author

@samueloph Mind reviewing the config and see if it works the same for you? As well as check that the fallback mechanism for /etc is as you imagined.

@codecov
Copy link

codecov bot commented Sep 28, 2021

Codecov Report

Merging #2511 (8900456) into master (98dffc2) will increase coverage by 0.02%.
The diff coverage is 16.66%.

❗ Current head 8900456 differs from pull request most recent head d697e91. Consider uploading reports for the commit d697e91 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2511      +/-   ##
==========================================
+ Coverage   10.44%   10.47%   +0.02%     
==========================================
  Files         147      147              
  Lines       10155    10166      +11     
==========================================
+ Hits         1061     1065       +4     
- Misses       9094     9101       +7     
Flag Coverage Δ
unittests 10.47% <16.66%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
include/utils/string.hpp 30.76% <ø> (ø)
src/main.cpp 0.00% <0.00%> (ø)
src/utils/file.cpp 27.92% <0.00%> (-0.94%) ⬇️
src/utils/string.cpp 92.64% <100.00%> (+0.22%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 98dffc2...d697e91. Read the comment docs.

@samueloph
Copy link
Contributor

@patrick96 Oh hey, that's pretty cool!
I will arrange some time during the weekend to test it and give feedback, thanks a lot!

@patrick96
Copy link
Member Author

Thanks for taking the time :)

It was actually quite nice building a new config from scratch.

@samueloph
Copy link
Contributor

@patrick96 Awesome PR, tested here and it's working fine, I just noticed one small issue:
If the folder ~/.config/polybar doesn't exist (I think that's gonna be the default), then bash autocomplete throws an error when:

$ polybar e[TAB]
$ polybar ebash: cd: /home/samueloph/.config/polybar: No such file or directory

And autocomplete doesn't fetch example when the folder is there (with or without the file), I'm not sure if it was supposed to fetch the names of the configurations, but it seems a good idea to fix the issue when the folder doesn't exist.

Thank you!

PS.: I did the stupidest thing when testing this and accidentally removed my whole ~/.config folder 😱

@patrick96
Copy link
Member Author

Thanks for the review 😃

That bash error must have been here since the bash completion was introduced because that part never changed. But this PR is probably a good place to fix that since I still need to implement the config fallback logic into the completion scripts as well.

PS.: I did the stupidest thing when testing this and accidentally removed my whole ~/.config folder scream

Oh no 😱 I hope you had a backup

@dvermd
Copy link
Contributor

dvermd commented Oct 4, 2021

I confirm the bar also displays correctly on my machine.
Though I have an error when using --config.
Using the option as it should (with =) works `bin/polybar --config=../doc/config.ini example'

$ cd build
$ bin/polybar -c ../doc/config.ini example   
notice: Parsing config file: ../doc/config.ini
notice: pulseaudio: using default sink bluez_sink.2C_41_A1_86_F9_19.a2dp_sink
notice: module/wlan: Discovered wireless interface wlp2s0
notice: module/eth: Discovered wired interface enp1s0
notice: Loaded font "monospace" (name=DejaVu Sans Mono, offset=2, file=/usr/share/fonts/TTF/DejaVuSansMono.ttf)
notice: Received signal(2): Interrupt
notice: Termination signal received, shutting down...

$ bin/polybar --config ../doc/config.ini example
error: Missing argument for option --config

Edit: self explain my mistake


Details on how to setup and configure the bar and each module have been moved to [the wiki](https://github.com/polybar/polybar/wiki/Configuration).

#### Install the example configuration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to be consistent and stick to default configuration instead of example. Even if the bar is called example.
The same may go for config -> configuration

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The readme does not reflect this yet because this is not part of a release yet and I don't want new users installing the latest version (which won't have a default config until 3.6 is released) thinking there is a default config.

The readme will be updated, together with the wiki on the next minor release.

@samueloph
Copy link
Contributor

samueloph commented Oct 4, 2021

Oh, I forgot to mention, I didn't test it on my laptop, but I think I didn't see anything related to battery usage.
Now, I understand it might be tricky to do it in the default config, but if it's easy, it might be worthy to show battery usage (when there's one).
I believe that's the default for i3's bar (though I'm not 100% sure because I might have added that myself).

PS.: Didn't have a backup for my .config folder, but everything's fine XD

@patrick96
Copy link
Member Author

There is no battery module because polybar can't auto-detect batteries (yet). You're right i3status does detect the battery by default.

Once battery can be auto-detected we can add it to the default config.

@patrick96
Copy link
Member Author

Alright, I updated both the zsh and bash completion to also show you the bars in /etc.

@patrick96 patrick96 merged commit 282b0f4 into polybar:master Oct 5, 2021
@patrick96 patrick96 deleted the default-config branch October 5, 2021 11:07
quentino18 pushed a commit to quentino18/polybar that referenced this pull request Oct 6, 2021
* Create default config and install to /etc/polybar

Closes polybar#2405

* Search for config in /etc

We search in XDG_CONFIG_DIRS, /etc/xdg, and /etc but only for config.ini

Closes polybar#2016

* Remove config installation from build.sh

* Remove userconfig cmake file

* Cleanup

* Cleanup default config

* Update CHANGELOG.md

Co-authored-by: dvermd <315743+dvermd@users.noreply.github.com>

* Update src/main.cpp

Co-authored-by: dvermd <315743+dvermd@users.noreply.github.com>

* Add tests for string functions

* Support loading bars from fallbacks in /etc

* Combine duplicate string_util::contains test

Co-authored-by: dvermd <315743+dvermd@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature request] provide generic configuration for first time users Check for configuration file at /etc/polybar/config as a fallback

3 participants