Code Monkey home page Code Monkey logo

nwg-bar's Introduction

Hi, I’m Piotr - a middle-aged clerk and after-hours FOSS developer. I’m interested in Linux, Wayland & GTK.

  • I use sway and Hyprland on Arch Linux;
  • I have been working on the GTK shell for sway and Hyprland called nwg-shell;
  • I prefer python to shell scripting and golang to C.

How to reach me:

  • Join the nwg-shell Discussions, or
  • submit an issue on GitHub on the appropriate project page, or
  • find me in the nwg-shell Matrix space, or
  • drop me a line by email.

Do not invite me to a live chat, unless you have diction like sir John Vincent Hurt. I'm quite useless at listening to English.

If you'd like to buy me a coffee, you may use GitHub Sponsors (link in the left column) or Liberapay:

Donate using Liberapay

nwg-bar's People

Contributors

dungeonseeker avatar jovanlanik avatar liocasio avatar mikekneeb avatar nwg-piotr avatar spfabgerman avatar t0fik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nwg-bar's Issues

Add a way to disable icons

Hi,

Here are some ideas of how this could be implemented:

  • An argument for the command
  • Setting icon to "disabled" or similar
  • Disabling if icon not specified in config

The above will allow the label to be centered as there is no way to hide the icons with gtk css
I'm using font awesome to display icons and then changing the font size in the style.css

image

Thanks!

CSS transform doesn't work?

I was styling the menu, and wanted to make it so when I hover, the icon grows slightly bigger. I tried using transform: scale(1.2), but that didn't work, and said that there was an error in CSS file and it fell back to GTK theme. Out of curiosity I also tried transform: rotate(20deg);, and that also caused it to fail.

Add option --config

Could you add the --config option to point to a different folder/file?

I like to keep everything in one folder like sway or hyprland.

Then we can have different wayland desktops next to each other.

feature req: way to determine when bar is fully loaded from a cli script

I've run into an issue where, if I put some exec-once directives in my hyprland config to launch apps on login, they start loading before nwg-bar is finished loading (and thus the notification area is ready and available), and the apps crash or are inaccessible because they can't do notification area stuff. it'd be super useful to have something I can call from the cli that verifies nwg-bar is fully loaded, then put that at the start of a startup script, that I then run via exec-once.

Invalid CSS prints file not found

When you try to load a CSS which has an invalid syntax it's classified as "file not found" when you try to run nwg-bar with that css.

[asbachb@arch-t14s nwg-bar]$ nwg-bar -t ~/.config/nwg-bar/bar-reboot.json -s /home/asbachb/.config/nwg-bar/style-reboot.css 
2 items loaded from template /home/asbachb/.config/nwg-bar/bar-reboot.json
Preferring dark theme variants
/home/asbachb/.config/nwg-bar/style-reboot.css file not found, using GTK styling

Feature request: fast selection

I was just thinking that it could be handy to have a fast keyboard-driven way to select the items in the menu, so that you don't either have to click or move across the bar with the arrow keys. Perhaps the number keys 1..,9,0 could permit the quick selection of an option, or custom shortcuts registered in the config file.

Would be interested in hearing thoughts :)

Load config files from /etc/nwg-bar/

Currently nwg-bar only supports user-level config file locations, but not at the system level. Even so, data is loaded from /usr/share under certain circumstances.

I propose that nwg-bar first check $XDG_CONFIG_HOME/nwg-bar or $HOME/.config/nwg-bar based on the environment variable, as is the current behaviour, but fall back to /etc/nwg-bar if that directory does not exist.

This is fairly standard behaviour, and would help out anyone configuring their desktop environment system-wide for multiple users.

Reducing keystroke distance

When having more items in nwg-bar, it takes many keystrokes to get to the last ones using arrow keys. When many items are used frequently, simply changing order of of them does not solve the problem.

This could be improved by adding cyclic motion and/or setting default item focused at the start (one of the middle ones, or one selected by user in config file). Either option can half the maximum distance needed to travel.

[Request] Allow referencing user in bar.json

To allow a kind of universal "logout", I tried setting this in bar.json:

{
  "label": "Logout",
  "exec": "loginctl terminate-user $USER",
  "icon": "/usr/share/nwg-bar/images/system-log-out.svg"
}

but as expected environment variables aren't parsed. I also tried moving that code into a script and calling the executable using "exec", but that didn't work either when using Sway.

This isn't really a request to add environment variable parsing, but I believe being able to reference the current user would be helpful for this situation and others, potentially.

Source tarball ships with bundled binary

Firstly, thanks so much for your work on this project!
I'm working on a package for alpine, and noticed that v0.0.1 contains a pre-compiled binary in the source files, which obviously isn't compatible with all architectures. Could we remove this for the next version?

What does -f option actually do?

I am a bit confused by what the -f option for "take Full screen width/height" actually does?

I noticed an issue here, saying that you did not want to support full screen: #30

I want to have "fullscreen" so I can have a dimmed background for the entire screen around the bar when logging out / shutting down / etc. The -f option does not appear to do that, so not sure what it actually is doing (if anything).

The only way I have figured out to do this was a hacky workaround with margin. It doesn't seem like you are allowed to use values of 100% in the CSS anywhere like window, outer-box, or inner-box.

window {
        background-color: rgba (0, 0, 0, 0.2)
}

/* Inner bar container, surrounds buttons */
#inner-box {
	margin: 4000px;
}

If this behavior is out of scope -- understood. Was just confused by the -f option and that old issue.

And thanks for your great projects and contributions to the community!

EDIT for clarity: just running with the default CSS and -foptions seems to have the same appearance as without. Perhaps this is not the case on sway, as I am using labwc...

-s and -t options do not respect absolute paths

-t and -s options assume ~/.config/<file_name>, and do not respect absolute path like ~/custom_config_path/<file_name>.

nwg-bar/main.go

Line 106 in 306b632

p := filepath.Join(configDir(), *templateFileName)

This interprets my argument as ~/.config/custom_config_path/<file_name>
A simple check for the leading / would suffice for now, if the templateFileName starts with /, instead of joining it with configDir, it should just use it by itself. Same thing for css file.

nwg-bar/main.go

Line 117 in 306b632

cssFile := filepath.Join(configDirectory, *cssFileName)

Also notice that one code snippet uses configDir() and other uses configDirectory, this should also be fixed.

Same thing should also be done for https://github.com/nwg-piotr/nwg-drawer

Sleep button

Based on #6 I added this to my config:

  {
    "label": "Sleep",
    "exec": "systemctl hybrid-sleep",
    "icon": "/usr/share/nwg-bar/images/sleep-light.svg"
  },

It'd be good if this were a default configuration option I think, but either way I wanted to create this issue as documentation in case anyone else is also interested in how to do this.

More documentation on systemd sleep options. I think hybrid-sleep makes the most sense but suspend might be slightly less at risk for adverse effects as it's just suspend to RAM.

nwg-bar ignores light/dark theme prefrences

I am trying to create a CSS style for nwg-bar so that the colors always follow the system GTK theme (set using nwg-look). As I was editing the file and testing the changes, I noticed the colors were not what I expected. Running it on the command line reveals that nwg-bar ignores the user's set preferences and uses the dark variant of the theme anyway. In the output is Preferring dark theme variants.

It would be nice if by default it did not ignore the user-made selection. Is there a way to alter this behavior in a config file or at runtime?

icons not shown

Hello,

Installed nwg-bar 0.1.3 on nixos (via configuration.nix) and even go, gtk-layer-shell and gtk3 but buttons are not shown only boxes.
Running hyprland.

icons shown in bar.json are available, for instance:
"icon": "/nix/store/pfwerf23fw3efr23fe3fefg42t23-nwg-bar-0.1.3/share/nwg-bar/images/system-lock-screen.svg"

Sleep button (or sleep icon request)

I'd really like to add a "sleep" button to my instance of nwg-bar. Would you let me know where the icons are derived from so that I could add one that fits with the theme of the rest of the icons?

Additionally, would you consider the integration of a sleep button into the default bar?

Text shadow styling

I think this is probably related to the css styling, but by default the text seems to have a weird white shadow for me. I checked the css and didn't find an immediately likely culprit. Any ideas as to what would likely cause it?

New release

I'm looking to use the fast selection feature here, but it seems that it's still in branch accel and not main. Also it seems that there's a commit in that branch to bump the version number to 0.1.1, but the commit wasn't tagged nor is it in main.

Would you wiling to merge the accel commit into main and release the new version?

Deprecated GObjects hinders installation

I can't succeed with installing this package. I've tried both yay --sync nwg-bar and cloning the repository and compiling the binary myself.
I'm left hanging with the info about two deprecated functions.

❯ yay --sync nwg-bar
:: Checking for conflicts...
:: Checking for inner conflicts...
[Aur:1]  nwg-bar-0.1.1-1

  1 nwg-bar                                  (Build Files Exist)
==> Packages to cleanBuild?
==> [N]one [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)
==> A
:: Deleting (1/1): /home/mark/.cache/yay/nwg-bar
:: (1/1) Downloaded PKGBUILD: nwg-bar
  1 nwg-bar                                  (Build Files Exist)
==> Diffs to show?
==> [N]one [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)
==> N
:: (1/1) Parsing SRCINFO: nwg-bar
==> Making package: nwg-bar 0.1.1-1 (Fri 17 Mar 2023 08:28:40 PM CET)
==> Retrieving sources...
  -> Downloading nwg-bar-0.1.1.tar.gz...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 10670    0 10670    0     0  16236      0 --:--:-- --:--:-- --:--:-- 16236
==> Validating source files with md5sums...
    nwg-bar-0.1.1.tar.gz ... Passed
==> Making package: nwg-bar 0.1.1-1 (Fri 17 Mar 2023 08:28:41 PM CET)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Found nwg-bar-0.1.1.tar.gz
==> Validating source files with md5sums...
    nwg-bar-0.1.1.tar.gz ... Passed
==> Removing existing $srcdir/ directory...
==> Extracting sources...
  -> Extracting nwg-bar-0.1.1.tar.gz with bsdtar
==> Sources are ready.
==> Making package: nwg-bar 0.1.1-1 (Fri 17 Mar 2023 08:28:43 PM CET)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> WARNING: Using existing $srcdir/ tree
==> Starting build()...
go: downloading github.com/gotk3/gotk3 v0.6.1
go: downloading github.com/dlasky/gotk3-layershell v0.0.0-20210331230524-5cca0b819261
go: downloading github.com/allan-simon/go-singleinstance v0.0.0-20210120080615-d0997106ab37
go: downloading github.com/joshuarubin/go-sway v0.0.4
go: downloading github.com/joshuarubin/lifecycle v1.0.0
go: downloading go.uber.org/multierr v1.1.0
go: downloading golang.org/x/sync v0.0.0-20190412183630-56d357773e84
go: downloading go.uber.org/atomic v1.3.2
# github.com/gotk3/gotk3/glib
cgo-gcc-prolog: In function ‘_cgo_200740c87a77_Cfunc_g_binding_get_source’:
cgo-gcc-prolog:71:2: warning: ‘g_binding_get_source’ is deprecated: Use 'g_binding_dup_source' instead [-Wdeprecated-declarations]
In file included from /usr/include/glib-2.0/glib-object.h:24,
                 from /usr/include/glib-2.0/gio/gioenums.h:30,
                 from /usr/include/glib-2.0/gio/giotypes.h:30,
                 from /usr/include/glib-2.0/gio/gio.h:28,
                 from ../go/pkg/mod/github.com/gotk3/[email protected]/glib/gbinding.go:3:
/usr/include/glib-2.0/gobject/gbinding.h:115:23: note: declared here
  115 | GObject *             g_binding_get_source          (GBinding *binding);
      |                       ^~~~~~~~~~~~~~~~~~~~
cgo-gcc-prolog: In function ‘_cgo_200740c87a77_Cfunc_g_binding_get_target’:
cgo-gcc-prolog:107:2: warning: ‘g_binding_get_target’ is deprecated: Use 'g_binding_dup_target' instead [-Wdeprecated-declarations]
/usr/include/glib-2.0/gobject/gbinding.h:119:23: note: declared here
  119 | GObject *             g_binding_get_target          (GBinding *binding);
      |                       ^~~~~~~~~~~~~~~~~~~~
[...]
❯ make build
go build -o bin/nwg-bar .
# github.com/gotk3/gotk3/glib
cgo-gcc-prolog: In function ‘_cgo_200740c87a77_Cfunc_g_binding_get_source’:
cgo-gcc-prolog:71:2: warning: ‘g_binding_get_source’ is deprecated: Use 'g_binding_dup_source' instead [-Wdeprecated-declarations]
In file included from /usr/include/glib-2.0/glib-object.h:24,
                 from /usr/include/glib-2.0/gio/gioenums.h:30,
                 from /usr/include/glib-2.0/gio/giotypes.h:30,
                 from /usr/include/glib-2.0/gio/gio.h:28,
                 from ../../go/pkg/mod/github.com/gotk3/[email protected]/glib/gbinding.go:3:
/usr/include/glib-2.0/gobject/gbinding.h:115:23: note: declared here
  115 | GObject *             g_binding_get_source          (GBinding *binding);
      |                       ^~~~~~~~~~~~~~~~~~~~
cgo-gcc-prolog: In function ‘_cgo_200740c87a77_Cfunc_g_binding_get_target’:
cgo-gcc-prolog:107:2: warning: ‘g_binding_get_target’ is deprecated: Use 'g_binding_dup_target' instead [-Wdeprecated-declarations]
/usr/include/glib-2.0/gobject/gbinding.h:119:23: note: declared here
  119 | GObject *             g_binding_get_target          (GBinding *binding);
      |                       ^~~~~~~~~~~~~~~~~~~~

Cosmetic Consideration For Dual Headed Nerds

Current setup is a FreeBSD box, running OpenBox, with a NVidia Quadro P1000 GPU with 2x 27-inch LCD panels attached.
This is a First World Problem, I know.

Is there any way to have both panels dim when running nwg-bar?
Currently what happens, is when nwg-bar runs, only the most recently selected desktop will dim & display the buttons lock/exit/reboot/shutdown; whilst the other display remains displaying as if nwg-bar is not running --- no dimming etc.

Any pointers on how to achieve, if at all possible, this cosmetic adjustment?
There doesn't appear to be anything obvious in the config files / manual on how to achieve this. There is absolutely nothing amiss with nwg-bar itself, of course, it runs & executes as intended & this 'issue' would only affect the few super-nerds who insist that more than 1 monitor is absolutely required.

Question/Feature: Multilayer bars

I try to implement a sub bar "Reboot to...". So the idea would be to open a new bar to be able to boot into Windows or to Bios.

  {
    "label": "Reboot to...",
    "exec": "/usr/bin/nwg-bar nwg-bar -t /home/asbachb/.config/nwg-bar/bar-reboot.json -s /home/asbachb/.config/nwg-bar/style-reboot.css",
    "icon": "/usr/share/nwg-bar/images/system-reboot.svg"
  },

I tried it this way, but the new bar is not showing up.

nwg-bar tries to copy configuration file from bogus location

On a clean install of 0.1.1, nwg-bar fails to start:

> nwg-bar
Copying file: /home/hugo/.config/nwg-bar/style.css
Copying file: /home/hugo/.config/nwg-bar/bar.json
2023/09/28 12:58:13 open /home/hugo/.config/nwg-bar/bar.json: no such file or directory

I have no configuration file, and nwg-bar tries to create one but that fails.

I inspected this a bit. In main.go, if the configuration file doesn't exist, it is copied over from $XDG_DATA_HOME (see getDataHome() in tools.go).

However, the file does not exist in $XDG_DATA_HOME. There is no way for a downstream package to include an example configuration file in this location, because this location in inside the current user's home directory. Mine is a pretty standard setup:

> echo $XDG_DATA_HOME
/home/hugo/.local/share

I don't think that using $XDG_DATA_HOME is ever correct or can ever work (at least not without manual user intervention first; which defeats the purpose of this functionality).

The function getDataHome() has a hard-coded fallback of /usr/share/. This works fine for distribution packages, but won't work for people installing manually (e.g.: into /usr/local.

A working approach might be to search for the sample file in all of xdg.DataDirs (e.g.: with the github.com/adrg/xdg module).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.