hyprwm / Hyprland

Hyprland is an independent, highly customizable, dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
https://hyprland.org
BSD 3-Clause "New" or "Revised" License
21.52k stars 900 forks source link

exec-once doesn't start waybar on startup #1906

Closed Incognitux closed 9 months ago

Incognitux commented 1 year ago

Steps to reproduce

Example configuration:

exec-once = waybar

Expected outcome

Noted outcome

Additional info

Configuration file

########################################################################################
 _   _                  _                 _    ____             __ _       
| | | |_   _ _ __  _ __| | __ _ _ __   __| |  / ___|___  _ __  / _(_) __ _ 
| |_| | | | | '_ \| '__| |/ _` | '_ \ / _` | | |   / _ \| '_ \| |_| |/ _` |
|  _  | |_| | |_) | |  | | (_| | | | | (_| | | |__| (_) | | | |  _| | (_| |
|_| |_|\__, | .__/|_|  |_|\__,_|_| |_|\__,_|  \____\___/|_| |_|_| |_|\__, |
       |___/|_|                                                      |___/ 

#########################################################################################

# You have to change this based on your monitor (run "hyprctl monitors")
monitor = eDP-1,1366x768@60,0x0,1

# Window rules and keybinds
source = ~/.config/hypr/src/windowRules.conf
source = ~/.config/hypr/src/keybinds.conf

#Notification 
exec-once = dunst 
# Status Bar
exec-once = waybar
#Polkit
exec-once = lxpolkit
# Wallpaper
exec-once = swaybg -o \* -i ~/Pictures/Wallpapers/Aenami7pmMocha1.png -m fill

# For keyboard 
#exec-once=fcitx5 -D

# For lockscreen
exec-once = swayidle -w timeout 200 'swaylock --fade-in 2'
# mpdris mpd
exec-once = mpDris2
# clipboard
#exec-once = wl-paste --watch cliphist store
exec-once = copyq

# Foot terminal daemon 
exec-once = foot --server 

# Night Light
exec-once = gammastep

# Bluetooth
#exec-once=blueman-applet # Make sure you have installed blueman

# Screen Sharing and Screen Recording
exec-once = dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP
#exec-once = ~/.config/hypr/scripts/screensharing.sh

# Apply GTK themes (or use nwg-look https://github.com/nwg-piotr/nwg-look)
#exec-once = ~/.config/hypr/scripts/import-gsettings

input {
  # Remap Capslock -> Esc for Vim users  
  #kb_options=caps:escape 
  repeat_rate = 25
  repeat_delay = 269

  touchpad {
    scroll_factor = 0.8
    disable_while_typing = 1
    natural_scroll = 1
    clickfinger_behavior = 1
    middle_button_emulation = 0
    tap-to-click = 1
  }
}

# Example per-device config
# See https://wiki.hyprland.org/Configuring/Keywords/#executing for more
 device:gaming-mouse {
    sensitivity = 0
    accel_profile = flat
}

gestures { 
  workspace_swipe = true 
  workspace_swipe_min_speed_to_force = 5
}

general {
    layout = dwindle
    gaps_in = 3
    gaps_out = 5
    border_size = 3
    col.active_border = 0xffEBA0AC
    col.inactive_border = 0xffB4BEFE
    col.group_border = 0xfffab387
    col.group_border_active = 0xffa6e3a1
    resize_on_border = true
}

decoration {
    multisample_edges  =  true
    blur_new_optimizations  =  true
    rounding = 6
    blur = 0
    blur_size = 2 # minimum 1
    blur_passes = 2 # minimum 1, more passes  =  more resource intensive.  
    # Your blur "amount" is blur_size * blur_passes, but high blur_size (over around 5-ish) will produce artifacts.
    # if you want heavy blur, you need to up the blur_passes.
    # the more passes, the more you can up the blur_size without noticing artifacts.
    drop_shadow = true
    shadow_range = 15
    col.shadow = 0xffEBA0AC
    col.shadow_inactive = 0x50000000
}

animations {
    enabled = 1
    # bezier=overshot,0.05,0.9,0.1,1.1
    bezier = buz, -0.09, 0, 0.19, 1
    bezier = linear, 0,0,1,1
    bezier = md3_decel, 0.05, 0.7, 0.1, 1
    bezier = overshot,0.13,0.99,0.29,1.1
    bezier = smoothOut, 0.36, 0, 0.66, -0.56
    bezier = smoothIn, 0.25, 1, 0.5, 1
    animation = windows,1,5,overshot,popin
    animation = windowsOut,1,6,md3_decel,popin
    animation = windowsMove, 1, 4, buz
    animation = fade, 1, 5, smoothIn
    animation = workspaces,1,6,overshot,slide
    animation = border,1,10,default
}

dwindle {
    pseudotile=1 # enable pseudotiling on dwindle
    force_split=0
    no_gaps_when_only = false
}

master {
  new_on_top = true
  no_gaps_when_only = false
}

misc {
  focus_on_activate = true
  disable_hyprland_logo = true
  disable_splash_rendering = true
  mouse_move_enables_dpms = true
  vrr = 0 # variable refresh rate
  vfr = 1 # variable frame rate
  animate_manual_resizes = true
  animate_mouse_windowdragging = true
}

debug:overlay=0
vaxerski commented 1 year ago

dunno, works for me and like everyone else. Try appending 2>&1 > ~/somelog.txt and inspecting the logs

Incognitux commented 1 year ago

do that for waybar or hyprland? If hyprland how would I do so?

Incognitux commented 1 year ago
[LOG] Executing WAYLAND_DISPLAY=wayland-1 DISPLAY=:0 waybar
[LOG] Process Created with pid 325914

this is what the logs say but there is no process with the pid running when i cross check, so is it crashing as soon as it starts?

vaxerski commented 1 year ago

do that for waybar or hyprland? If hyprland how would I do so?

waybar, it's obviously crashing.

Incognitux commented 1 year ago

so I did

exec-once = waybar 2>&1 > ~/somelog.txt

and it outputs an empty file, does this mean it doesn't even start?

vaxerski commented 1 year ago

probably. If other apps in exec-once work, it's an issue with your system. (Which it seems like to me)

Incognitux commented 1 year ago

uh so other apps like eww (exec-once = eww daemon), mpd(exec-once = mpd) also don't seem to be working

Fxzzi commented 1 year ago

try the full path to the executable. Maybe it's some strange issue with your PATH

Incognitux commented 1 year ago

executing in the terminal works tho I will try nonetheless

Incognitux commented 1 year ago

nope, did not work

ModestTom commented 1 year ago

I am currently experiencing this issue with only two executables. Eww (same as @Incognitux ) and gammastep. I have tried hard pathing to them and attempting to get a ouput log like exec-once = /usr/bin/eww daemon 2>&1 > ~/eww-crash.txt and exec-once = /usr/bin/gammastep 2>&1 > ~/gammastep-crash.txt. Neither produced and output log. @Incognitux have you tried any other executables since this post ?

uh so other apps like eww (exec-once = eww daemon), mpd(exec-once = mpd) also don't seem to be working

Incognitux commented 1 year ago

@ModestTom I use gammastep as well and it works completely fine for me.

LizzyFleckenstein03 commented 1 year ago

I have the same issue with waybar and pkexec swhkd. They work when executed in a shell, but not when started with exec-once or the exec dispatch. Other commands work fine.

There is no log output. I also tried running them in a script and dumping the environment variables beforehand; the environment variables do not differ from those in my shell (with the exception of some irrelevant ones, like LS_COLORS).

In case it helps, I use artix linux with OpenRC (no systemd).

niksingh710 commented 1 year ago

I have the same issue with waybar and pkexec swhkd. They work when executed in a shell, but not when started with exec-once or the exec dispatch. Other commands work fine.

There is no log output. I also tried running them in a script and dumping the environment variables beforehand; the environment variables do not differ from those in my shell (with the exception of some irrelevant ones, like LS_COLORS).

In case it helps, I use artix linux with OpenRC (no systemd).

have you tried to echo some random texts to a file for checking if the script that you tried to put in exec-once to run waybar is getting executed? and from which part of the script the execution stops of give error?

LizzyFleckenstein03 commented 1 year ago

I managed to solve the issue by running dbus-update-activation-environment --all at startup. It seems like Hyprland won't update the dbus environment if compiled with systemd support but the system wasn't booted with systemd.

https://github.com/hyprwm/Hyprland/blob/9f8c5cb63c239ffd09b69cb0c635e8870dbd667e/src/config/ConfigManager.cpp#L1218C1-L1222

siddharthroy12 commented 1 year ago

@LizzyFleckenstein03 Where did you put dbus-update-activation-environment --all ? In hyperland.config?

Estebiu commented 1 year ago

@LizzyFleckenstein03 Where did you put dbus-update-activation-environment --all ? In hyperland.config?

I think he did ´´´exec-once=dbus-update-activation-environment --all´´´

siddharthroy12 commented 1 year ago

@LizzyFleckenstein03 Where did you put dbus-update-activation-environment --all ? In hyperland.config?

I think he did ´´´exec-once=dbus-update-activation-environment --all´´´

This didn't work for me

Incognitux commented 1 year ago

I managed to solve the issue by running dbus-update-activation-environment --all at startup. It seems like Hyprland won't update the dbus environment if compiled with systemd support but the system wasn't booted with systemd.

9f8c5cb/src/config/ConfigManager.cpp#L1218C1-L1222

doesn't work, on latest build as of posting

hughesjs commented 1 year ago

Any updates on this? Not being able to launch waybar is a pretty big dealbreaker for me

siddharthroy12 commented 1 year ago

This issue is fixed for me after switching to arch Linux and installing this from pacman

hughesjs commented 1 year ago

@siddharthroy12 - hyprland or hyprland-git?

romanstingler commented 1 year ago

@hughesjs both work fine just install

hyprland-git r3004.2295bbdd-1
waybar-hyprland-git 0.9.18.r31.gd367b7e1-1
xdg-desktop-portal-hyprland-git 1:r285.4d9ff0c-1

could you please reply if you could resolve the issue, thx

whkelvin commented 1 year ago

Here is what I did to get Eww bar to show up. I am using the fish shell but I don't see why bash or sh wouldn't work.

  1. In hyprland.conf, add this:
    exec-once=fish ~/.config/hypr/launch-bar.fish
  2. Create ~/.config/hypr/launch-bar.fish
    eww daemon --restart
    eww open {your bar name}
  3. chmod +x launch-bar.fish
  4. Voilà
pescepalla commented 1 year ago

Had the same issue with i3bar-river. Solved by adding short pause before starting the bar: exec-once = sleep 2 && i3bar-river

romanstingler commented 1 year ago

did you resolve this issue?

Incognitux commented 1 year ago

@romanstingler unfortunately no, mentioned workarounds also didn't seem to work

niksingh710 commented 1 year ago

Add these environment variable.

# XDG
env = XDG_CURRENT_DESKTOP,Hyprland
env = XDG_SESSION_TYPE,wayland
env = XDG_SESSION_DESKTOP,Hyprland

# QT
env = QT_AUTO_SCREEN_SCALE_FACTOR,1
env = QT_QPA_PLATFORM=wayland;xcb    # Not yet working for onlyoffice-editor
env = QT_WAYLAND_DISABLE_WINDOWDECORATION,1
env = QT_QPA_PLATFORMTHEME,qt6ct

# Toolkit
env = SDL_VIDEODRIVER,wayland
env = _JAVA_AWT_WM_NONEREPARENTING,1
env = CLUTTER_BACKEND,wayland
env = GDK_BACKEND,wayland,x11

Make sure to have these in top (first execution)

# Responsible for imporitng environment variable for GTK applications
exec-once = systemctl --user import-environment XDG_SESSION_TYPE XDG_CURRENT_DESKTOP
exec-once = dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP

Then add waybar launch command

exec-once = killall -q waybar;sleep .5 && waybar

and if on arch linux have waybar-hyprland-git installed reboot once to get env working and it should launch waybar as expected

romanstingler commented 1 year ago

@Incognitux are you starting hyprland from tty or inside tmux or from a login manager?

Incognitux commented 1 year ago

@romanstingler I am using a login manager, specifically GDM

Incognitux commented 1 year ago

Starting from TTY seems to fix the issue, can others facing the issue verify this?

niksingh710 commented 1 year ago

Starting from TTY seems to fix the issue, can others facing the issue verify this?

I was using sddm never faced it .....

But can't say as now I just put Hyprland in ~/.zprofile

1094 commented 1 year ago

Add these environment variable.

# XDG
env = XDG_CURRENT_DESKTOP,Hyprland
env = XDG_SESSION_TYPE,wayland
env = XDG_SESSION_DESKTOP,Hyprland

# QT
env = QT_AUTO_SCREEN_SCALE_FACTOR,1
env = QT_QPA_PLATFORM=wayland;xcb    # Not yet working for onlyoffice-editor
env = QT_WAYLAND_DISABLE_WINDOWDECORATION,1
env = QT_QPA_PLATFORMTHEME,qt6ct

# Toolkit
env = SDL_VIDEODRIVER,wayland
env = _JAVA_AWT_WM_NONEREPARENTING,1
env = CLUTTER_BACKEND,wayland
env = GDK_BACKEND,wayland,x11

I'm having the same problem and I'd like to add these environment variables; however, I'm not sure where to put them. I tried putting them to my hyprland.conf but the problem is still happening. The exec-once is ignored and if I try to run it from the terminal I get [error] Bar need to run under Wayland.

Thanks.

UPDATE: I reinstalled my OS (all the same config files) and waybar started working as expected.

alexanderhunterking commented 1 year ago

I had the same issue of waybar not working correctly on launch. I found that it was because i wasn't running the native resolution.

SamuelHDieterich commented 1 year ago

Starting from TTY seems to fix the issue, can others facing the issue verify this?

I'm in the same boat as @Incognitux. I tried many different ways to spawn eww daemon without any luck: adding & at the end of the command; invoking a sh/bash script; inserting some sleeps (similar to what the documentation mentions for resetting the XDG portal). I was using SDDM as my login manager but I just tested it with Ly and got the same unfortunate result. However, when I tried starting Hyprland from the terminal, the eww daemon was running as I would expected. Really odd.

SamuelHDieterich commented 1 year ago

UPDATE: So, for my end, the issue seems to be only related to eww itself. I tried to even start the daemon from a SystemD service and it was not properly working (more details later). However, I had the binary installed on a custom path (~/.local/bin/eww) and apparently, there is some part of the daemon that expects the executable to be on the path unless you run it on a terminal emulator, at least I don't get the same issue when I started the service manually. Now, I can start it as expected suign exec-once = eww daemon.

[!NOTE] For those who are interested in the issue I was having specifically with eww, continue the reading.

Although the server can start automatically when you try to open a specific window, in my case, a powermenu I was experimenting with (I don't have a bar yet), the eventbox was not working properly (maybe other widgets too). I have coded my widget to open on the active monitor (by not declaring the monitor in the yuck file and using the --screen 0 flag) and close if I move away from it or click away anywhere but the buttons displayed (by using an eventbox). However, although I could see the powermenu, these "close triggers" were not working (to be honest, I did not test the buttons themself). So, I found out that when you start the server by opening a window with the daemon not running, those features don't actually work (maybe something related to IPC?).

tl;dr: If you manually build EWW and are facing some issues, try copying the executable to a default PATh like /usr/local/bin.

UltraBlackLinux commented 1 year ago

I think this problem is linked to some other autostart issues of mine. Recently, autostart broke, and applications started behaving as if I didn't use dbus-update-activation-environment at all, showing all the symptoms thereof. I knew that the execution order was correct, as I had experimented with that when that problem first popped up before disapapearing shortly after only to return and stay around (dbus-update-activation-environment below GUI applications).

Any idea what else it could be?

Edit 2: Ignore what I said about it working. Apparently the environment variables set in hyprland are set for the whole system or something like that. After a reboot, everything is back to problems

GenericConfluent commented 11 months ago

I've been having a similar issue for the past couple of weeks. I'm not sure what I did but one day waybar suddenly decided to take 10s to appear every time I started Hyprland for the first time after each boot. It still appears eventually, but it takes a noticeably long time to get up and running. The weird thing is that the lag only happens the first time, if I exit Hyprland then start it again waybar starts instantaneously.

UltraBlackLinux commented 11 months ago

is screen recording working for any of you? OBS is either never opening or not showing the screen selector. Other screen recorders behave similarly. (I'm also getting this: UnknownMethod: No such interface "org.freedesktop.portal.ScreenCast")

If this is really just an environment variable issue, then this would probably be the confirmation.

GenericConfluent commented 11 months ago

is screen recording working for any of you? OBS is either never opening or not showing the screen selector. Other screen recorders behave similarly. (I'm also getting this: UnknownMethod: No such interface "org.freedesktop.portal.ScreenCast")

If this is really just an environment variable issue, then this would probably be the confirmation.

Also having screen recording issues. Though for me it wasn't Hyprland related since obs also stopped working for me in GNOME. "obs failed to initialize video your GPU may not be supported" or something along those lines, so in my case it was probably due to me updating my nvidia drivers.

UltraBlackLinux commented 10 months ago

ok this DOES seem to be an environment variable issue! first I noticed that waybar complains about the desktop portal not being initialized. Then I noticed that the nuclear option script for the hyprland destop portal uses /usr/libexec but it should be /usr/lib, and then I noticed that I was missing the sdbus-cpp library from my system, which xdg-desktop-portal-hyprland wants! I installed that and it's now starting. It should finally be able to set the environment variables!

I'm on arch

wjstarrsiii commented 10 months ago

Having the same problem for weeks on arch. Installing sdbus-cpp fixed it for me. Thanks, @UltraBlackLinux

DisasterlyDisco commented 10 months ago

Had somewhat similar problems. Waybar and swww didn't show visually on my desktop after starting Hyprland. Both were simply initiated with the exec-once command in my config. I assumed that the problem was the same for both programs, but while Waybar didn't start up at all, swww did start, but for some reason didn't display.

It is all currently working now after applying @niksingh710's solution, although I'm omitting the half a second sleep as that is too slow for me.

I'm writing this though, not to confirm that there is a working solution, but to introduce the idea that this might be some race condition bullshit. I have about two handfuls of exec-once statements in my config, and whether or not Wyabar and swww works depends very much on where in this order they are (even after implementing the @niksingh710's solution). Adding sleeps always fixes the problem.

Is there anyone more well versed in Hyprlands startup behavior who can point to where any asynchronous operations is happening?

Spatchy commented 9 months ago

I just want to comment for dummies like myself who somehow missed it - The exec-once line in the default auto generated config file is commented out.

This is almost certainly not the reason many people in this thread are experiencing an issue, but if I stumbled across this thread before I realised, there's a chance others might too. We're all blind to the blatantly obvious sometimes, but feel free to laugh at me.

rb-one commented 9 months ago

My problem was with the dsplog library and waybar, what I did... install a downgrade library pacman, apt, whatever you use to spdlog=1.12.0, then install waybar-git, that fixed for me

vaxerski commented 9 months ago

I think this can be closed as it's turned into a fiesta of people with broken waybars.

asan720 commented 8 months ago

Добавьте эту переменную среды.

# XDG
env = XDG_CURRENT_DESKTOP,Hyprland
env = XDG_SESSION_TYPE,wayland
env = XDG_SESSION_DESKTOP,Hyprland

# QT
env = QT_AUTO_SCREEN_SCALE_FACTOR,1
env = QT_QPA_PLATFORM=wayland;xcb    # Not yet working for onlyoffice-editor
env = QT_WAYLAND_DISABLE_WINDOWDECORATION,1
env = QT_QPA_PLATFORMTHEME,qt6ct

# Toolkit
env = SDL_VIDEODRIVER,wayland
env = _JAVA_AWT_WM_NONEREPARENTING,1
env = CLUTTER_BACKEND,wayland
env = GDK_BACKEND,wayland,x11

У меня та же проблема, и я хотел бы добавить эти переменные среды; однако я не уверен, куда их поместить. Я попробовал поместить их в свой hyprland.confно проблема все еще происходит. exec-onceигнорируется, и если я попытаюсь запустить его с терминала, я получу [error] Bar need to run under Wayland.

Спасибо.

ОБНОВЛЕНИЕ: Я переустановил свою ОС (все те же файлы конфигурации), и панель навигации начала работать как положено.

Settings were not changed during installstion?

HaidYi commented 4 months ago

Maybe try install pipewire first. I solve this problem by installing the pipewire, then the waybar can be shown after that.