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.58k stars 902 forks source link

Failed cocket connection from exec-once #6731

Closed Sniptzler closed 3 months ago

Sniptzler commented 4 months ago

Regression?

No

System Info and Version

System/Version info ```sh Hyprland, built from branch at commit 9e781040d9067c2711ec2e9f5b47b76ef70762b3 (props: bump version to 0.41.1). Date: Thu Jun 13 09:54:06 2024 Tag: v0.41.1, commits: 4818 flags: (if any) System Information: System name: Linux Node name: archlinux Release: 6.9.6-arch1-1 Version: #1 SMP PREEMPT_DYNAMIC Fri, 21 Jun 2024 19:49:19 +0000 GPU information: 63:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Phoenix1 [1002:15bf] (rev c7) (prog-if 00 [VGA controller]) os-release: NAME="Arch Linux" PRETTY_NAME="Arch Linux" ID=arch BUILD_ID=rolling ANSI_COLOR="38;2;23;147;209" HOME_URL="https://archlinux.org/" DOCUMENTATION_URL="https://wiki.archlinux.org/" SUPPORT_URL="https://bbs.archlinux.org/" BUG_REPORT_URL="https://gitlab.archlinux.org/groups/archlinux/-/issues" PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/" LOGO=archlinux-logo plugins: ======Config-Start====== Config File: /home/lukas/.config/hypr/hyprland.conf: Read Succeeded # Sourcing external config files # Default Configs $configs = $HOME/.config/hypr/configs source= $configs/settings.conf source= $configs/monitor.conf source= $configs/keybinds.conf source= $configs/startup.conf source= $configs/variables.conf source= $configs/window_rules.conf source= $configs/animations.conf Config File: /home/lukas/.config/hypr/configs/settings.conf: Read Succeeded source= ~/.cache/wal/colors-hyprland.conf # See https://wiki.hyprland.org/Configuring/Monitors/ monitor=,preferred,auto,auto # Orenhofen Monitors #monitor=DP-11,1920x1080@165,0x0,1 #workspace=DP-11,1 #monitor=DP-8,1920x1080@74.97,1920x0,1 #workspace=DP-8,2 # trigger when the switch is turning off bindl = , switch:off:Lid Switch,exec,hyprctl keyword monitor "eDP-1, auto, 0x0, auto" # trigger when the switch is turning on #bindl = , switch:on:Lid Switch,exec,hyprctl keyword monitor "eDP-1, disable" bindl = , switch:on:Lid Switch,exec, ~/.config/hypr/scripts/lidclose.sh # https://wiki.hyprland.org/Configuring/Variables/#general general { gaps_in = 8 gaps_out = 8 border_size = 2 # https://wiki.hyprland.org/Configuring/Variables/#variable-types for info about colors col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg col.inactive_border = rgba(595959aa) # Set to true enable resizing windows by clicking and dragging on borders and gaps resize_on_border = true # Please see https://wiki.hyprland.org/Configuring/Tearing/ before you turn this on allow_tearing = false col.active_border = $col6 $col3 90deg col.inactive_border = rgba(000000A0) layout = dwindle } # https://wiki.hyprland.org/Configuring/Variables/#decoration decoration { rounding = 10 # Change transparency of focused and unfocused windows active_opacity = 1.0 inactive_opacity = 1.0 drop_shadow = false #drop_shadow = true shadow_range = 4 shadow_render_power = 3 col.shadow = rgba(1a1a1aee) # https://wiki.hyprland.org/Configuring/Variables/#blur blur { # battery improvement? enabled = false #enabled = true size = 3 passes = 1 vibrancy = 0.1696 } } # https://wiki.hyprland.org/Configuring/Variables/#animations animations { enabled = true # Default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more bezier = myBezier, 0.05, 0.9, 0.1, 1.05 animation = windows, 1, 7, myBezier animation = windowsOut, 1, 7, default, popin 80% animation = border, 1, 10, default animation = borderangle, 1, 8, default animation = fade, 1, 7, default animation = workspaces, 1, 6, default } # See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more dwindle { pseudotile = true # Master switch for pseudotiling. Enabling is bound to mainMod + P in t> preserve_split = true # You probably want this } # See https://wiki.hyprland.org/Configuring/Master-Layout/ for more master { new_is_master = true } # https://wiki.hyprland.org/Configuring/Variables/#misc misc { force_default_wallpaper = -1 # Set to 0 or 1 to disable the anime mascot wallpapers disable_hyprland_logo = false # If true disables the random hyprland logo / anime girl ba> vfr = true } # https://wiki.hyprland.org/Configuring/Variables/#input input { kb_layout = de kb_variant = kb_model = kb_options = kb_rules = follow_mouse = 1 accel_profile = flat sensitivity = 0 # -1.0 - 1.0, 0 means no modification. touchpad { natural_scroll = true } } # https://wiki.hyprland.org/Configuring/Variables/#gestures gestures { workspace_swipe = true } # Example per-device config # See https://wiki.hyprland.org/Configuring/Keywords/#per-device-input-configs for more device { name = syna2ba6:00-06cb:cef5-touchpad sensitivity = 0.1 accel_profile = adaptive } Config File: /home/lukas/.cache/wal/colors-hyprland.conf: Read Succeeded $background = rgb(0F161E) $foreground = rgb(8ae1c1) $color0 = rgb(0F161E) $color1 = rgb(32514E) $color2 = rgb(595A59) $color3 = rgb(B85154) $color4 = rgb(30A95B) $color5 = rgb(B6A743) $color6 = rgb(94439B) $color7 = rgb(8ae1c1) $color8 = rgb(609d87) $color9 = rgb(32514E) $color10 = rgb(595A59) $color11 = rgb(B85154) $color12 = rgb(30A95B) $color13 = rgb(B6A743) $color14 = rgb(94439B) $color15 = rgb(8ae1c1) Config File: /home/lukas/.config/hypr/configs/monitor.conf: Read Succeeded monitor=desc:California Institute of Technology 0x1416,22280x1800@60,0x0,2 monitor=desc:HP Inc. HP X34 6CM15009NW,3440x1440@60,auto,1 #monitor=desc:California Institute of Technology 0x1416,22280x1800@60,0x0,2 Config File: /home/lukas/.config/hypr/configs/keybinds.conf: Read Succeeded $mainMod = SUPER $scripts = $HOME/.config/hypr/scripts $configs = $HOME/.config/hypr/configs $files = thunar $term = kitty # Windows control ------------------------------------------------------------ # Commands bind = $mainMod, Q, killactive, bind = $mainMod, F, fullscreen bind = $mainMod SHIFT, F, togglefloating, # Actual window float bind = $mainMod ALT, F, exec, hyprctl dispatch workspaceopt allfloat # All windows float # Move focus with mainMod + arrow keys bind = $mainMod, left, movefocus, l bind = $mainMod, right, movefocus, r bind = $mainMod, up, movefocus, u bind = $mainMod, down, movefocus, d # Resize binde = $mainMod CTRL, left, resizeactive,-50 0 binde = $mainMod CTRL, right, resizeactive,50 0 binde = $mainMod CTRL, up, resizeactive,0 -50 binde = $mainMod CTRL, down, resizeactive,0 50 # Move/resize windows with mainMod + LMB/RMB and dragging bindm = $mainMod, mouse:272, movewindow bindm = $mainMod, mouse:273, resizewindow # Move bind = $mainMod SHIFT, left, movewindow, l bind = $mainMod SHIFT, right, movewindow, r bind = $mainMod SHIFT, up, movewindow, u bind = $mainMod SHIFT, down, movewindow, d # Master Layout #bind = $mainMod CTRL, D, layoutmsg, removemaster #bind = $mainMod, I, layoutmsg, addmaster #bind = $mainMod, J, layoutmsg, cyclenext #bind = $mainMod, K, layoutmsg, cycleprev #bind = $mainMod, M, exec, hyprctl dispatch splitratio 0.3 # Groups bind = $mainMod, G, togglegroup bind = ALT, tab, changegroupactive #change focus to another window # Move active window and follow to workspace mainMod + SHIFT [0-9] bind = $mainMod SHIFT, 1, movetoworkspace, 1 bind = $mainMod SHIFT, 2, movetoworkspace, 2 bind = $mainMod SHIFT, 3, movetoworkspace, 3 bind = $mainMod SHIFT, 4, movetoworkspace, 4 bind = $mainMod SHIFT, 5, movetoworkspace, 5 bind = $mainMod SHIFT, 5, movetoworkspace, 6 bind = $mainMod SHIFT, 7, movetoworkspace, 7 bind = $mainMod SHIFT, 8, movetoworkspace, 8 bind = $mainMod SHIFT, 9, movetoworkspace, 9 bind = $mainMod SHIFT, 0, movetoworkspace, 10 # Move active window to a workspace silently mainMod + CTRL [0-9] bind = $mainMod CTRL, 1, movetoworkspacesilent, 1 bind = $mainMod CTRL, 2, movetoworkspacesilent, 2 bind = $mainMod CTRL, 3, movetoworkspacesilent, 3 bind = $mainMod CTRL, 4, movetoworkspacesilent, 4 bind = $mainMod CTRL, 5, movetoworkspacesilent, 5 bind = $mainMod CTRL, 6, movetoworkspacesilent, 6 bind = $mainMod CTRL, 7, movetoworkspacesilent, 7 bind = $mainMod CTRL, 8, movetoworkspacesilent, 8 bind = $mainMod CTRL, 9, movetoworkspacesilent, 9 bind = $mainMod CTRL, 0, movetoworkspacesilent, 10 # Workspaces ------------------------------------------------------------------ # The following mappings use the key codes to better support various keyboard layouts # 1 is code:10, 2 is code 11, etc # Switch workspaces with mainMod + [0-9] bind = $mainMod, code:10, workspace, 1 bind = $mainMod, code:11, workspace, 2 bind = $mainMod, code:12, workspace, 3 bind = $mainMod, code:13, workspace, 4 bind = $mainMod, code:14, workspace, 5 bind = $mainMod, code:15, workspace, 6 bind = $mainMod, code:16, workspace, 7 bind = $mainMod, code:17, workspace, 8 bind = $mainMod, code:18, workspace, 9 bind = $mainMod, code:19, workspace, 10 # Move using tab bind = $mainMod, tab, workspace, m+1 bind = $mainMod SHIFT, tab, workspace, m-1 # Scroll through existing workspaces with mainMod + scroll bind = $mainMod, mouse_down, workspace, e+1 bind = $mainMod, mouse_up, workspace, e-1 bind = $mainMod, period, workspace, e+1 bind = $mainMod, comma, workspace, e-1 # Special workspace bind = $mainMod SHIFT, U, movetoworkspace, special bind = $mainMod, U, togglespecialworkspace, # Scripts ------------------------------------------------------------------------ # Sound control #bind = , xf86audioraisevolume, exec, $scripts/volume_control.sh --inc #volume up #bind = $mainMod, Z, exec, $scripts/volume_control.sh --dec #volume down #bind = $mainMod, SPACE, exec, $scripts/media_control.sh --pause #bind = $mainMod, C, exec, $scripts/media_control.sh --nxt #bind = $mainMod, X, exec, $scripts/media_control.sh --prv # Brightness controll bind=,XF86MonBrightnessDown,exec,brightnessctl set 15- bind=,XF86MonBrightnessUp,exec,brightnessctl set 15+ binde =, XF86AudioRaiseVolume, exec, wpctl set-volume -l 1.4 @DEFAULT_AUDIO_SINK@ 5%+ binde =, XF86AudioLowerVolume, exec, wpctl set-volume -l 1.4 @DEFAULT_AUDIO_SINK@ 5%- bind =, XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle # Wallpapers bind = $mainMod, W, exec, $scripts/wallpaperSelect.sh # Select wallpaper to apply # Screenshot keybindings NOTE: You may need to press Fn key as well #bind = $mainMod, Print, exec, $scripts/screenshot.sh --now #bind = $mainMod SHIFT, Print, exec, $scripts/screenshot.sh --area #bind = $mainMod CTRL, Print, exec, $scripts/screenshot.sh --in5 #screenshot in 5 secs # screenshot with swappy (another screenshot tool) #bind = $mainMod SHIFT, S, exec, $scripts/screenshot.sh --swappy # Launchers bindr = $mainMod, D, exec, pkill rofi || rofi -show drun -modi drun,filebrowser,run,window # Rofi bind = $mainMod, Return, exec, $term # Launch terminal bind = $mainMod, T, exec, $files # File manager bind = $mainMod ALT, R, exec, $scripts/refresh.sh # Refresh waybar, swaync, rofi bind = $mainMod ALT, V, exec, $scripts/clipManager.sh # Clipboard Manager bind = $mainMod SHIFT, N, exec, swaync-client -t -sw # swayNC panel # Waybar / Bar related bind = $mainMod, B, exec, killall -SIGUSR1 waybar # Toggle hide/show waybar bind = $mainMod CTRL, B, exec, $scripts/waybarStyles.sh # Waybar Styles Menu bind = $mainMod ALT, B, exec, $scripts/waybarLayout.sh # Waybar Layout Menu # Misc bind = $mainMod ALT, L, exec, $scripts/changeLayout.sh # Toggle Master or Dwindle Layout # For passthrough keyboard into a VM # bind = $mainMod ALT, P, submap, passthru #submap = passthru # to unbind #bind = $mainMod ALT, P, submap, reset #submap = reset # Hyprland --------------------------------------------------------- bind = CTRL ALT, Delete, exec, hyprctl dispatch exit 0 Config File: /home/lukas/.config/hypr/configs/startup.conf: Read Succeeded # Startup exec-once = dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP exec-once = systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP # startup apps exec-once = waybar exec-once = nm-applet --indicator exec-once = swaync exec-once = hypridle exec-once = sww-daemon exec-once = wal -R #exec-once = hyprpaper exec-once=~/.config/hypr/scripts/monitors.sh --run exec-once=~/.config/hypr/scripts/monitors.sh &> custom-output Config File: /home/lukas/.config/hypr/configs/variables.conf: Read Succeeded env = XCURSOR_SIZE,24 env = HYPRCURSOR_SIZE,24 # vulkan #env = WLR_RENDERER,vulkan # firefox env = MOZ_ENABLE_WAYLAND,1 Config File: /home/lukas/.config/hypr/configs/window_rules.conf: Read Succeeded # See https://wiki.hyprland.org/Configuring/Window-Rules/ for more # See https://wiki.hyprland.org/Configuring/Workspace-Rules/ for workspace rules # Example windowrule v1 # windowrule = float, ^(kitty)$ # Example windowrule v2 # windowrulev2 = float,class:^(kitty)$,title:^(kitty)$ windowrulev2 = suppressevent maximize, class:.* # You'll probably like this. Config File: /home/lukas/.config/hypr/configs/animations.conf: Read Succeeded animations { enabled = yes bezier = shot, 0.2, 1.0, 0.2, 1.0 bezier = swipe, 0.6, 0.0, 0.2, 1.05 bezier = linear, 0.0, 0.0, 1.0, 1.0 bezier = progressive, 1.0, 0.0, 0.6, 1.0 animation = windows, 1, 6, shot, slide animation = workspaces, 1, 6, swipe, slide animation = fade, 1, 4, progressive animation = border, 1, 6, linear animation = borderangle, 1, 180, linear, loop #used by rainbow borders and rotating colors } ======Config-End======== ```

Description

I have made my one little script to change monitor configurations based on what monitors are plugged in. It hooks in to the socket2 and listens for monitorremoved/added. Like this https://wiki.hyprland.org/Configuring/Expanding-functionality/. The problem is that I am not able to start my script via exec-once. There is no error but I m not able to connect to the socket. It works just fine if executed from the shell. What alternative is there to start my script?

#!/bin/sh
# ~/.config/hypr/scripts/monitor.sh

CONFIG="/home/lukas/.config/hypr/configs"
FILES="${CONFIG}/monitors/*"

function configure_monitors() {
  monitors_json=$(hyprctl monitors -j)
  monitors=($(echo $monitors_json | jq -r '. | sort_by(.description) | .[].description'))
  echo ${monitors[*]}
  success="false"
  # for monitor in ${monitors[@]}; do
  #   echo $monitor
  # done
  for f in $FILES
  do
    #echo "Processing $f"
    declare -a readmoni_arr=()
    while IFS= read -r line
    do

      if [[ $line == "monitor=desc:"* ]]; then
        line2="${line##*:}"
        line3="${line2%%,*}"
        readmoni_arr+=("${line3}")
      fi

    done < "$f"
    #echo ${readmoni_arr[*]}
    var1=$( IFS=$' '; echo "${monitors[*]}" )
    var2=$( IFS=$' '; echo "${readmoni_arr[*]}" )

    #echo "potential match:$var1::$var2"

    if  [[ $var1 == $var2 ]]; then
      success="true"
      echo "success, linking new monitor config file"
      echo "$f"
      rm ${CONFIG}/monitor.conf
      ln -s $f ${CONFIG}/monitor.conf
      hyprctl reload
      hyprctl notify 1 10000 0 "chnaged monitor.conf to:$f"
    fi
  done
  if [[ $success == "false" ]]; then
    echo "linking default monitor config"
    rm ${CONFIG}/monitor.conf
    ln -s ${CONFIG}/default.conf ${CONFIG}/monitor.conf
    sleep 1
    hyprctl reload
    sleep 1
    hyprctl notify 1 8000 0 "chnaged monitor.conf to:deafult.conf"
  fi
  }

function list() {
  hyprctl monitors
}

function listen() {
  while true
  do
    echo "trying socat"
    socat - "UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" | while read -r line; do handle "$line"; done
    sleep 2
  done
}

function handle {

  if [[ ${1:0:13} == "monitoradded>" ]]; then
    echo "Event detected: monitor added"
    configure_monitors
  elif [[ ${1:0:14} == "monitorremoved" ]]; then
    echo "Event detected: monitor removed"
    configure_monitors
  fi
}

# Execute accordingly
if [[ "$1" == "--run" ]]; then
    configure_monitors
else
  listen

How to reproduce

Running the attached script via exec-once.

Crash reports, logs, images, videos

No response

ikalco commented 4 months ago

i get the expected output from these two exec-once so the sockets should be working

exec-once = hyprctl monitors > ~/test1.log
exec-once = socat - "UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" | while read -r line; do echo "$line"; done > ~/test2.log
Sniptzler commented 4 months ago

For me the output of ~/test2.log is empty when trying you're exact example. And test1.log is just filled with a repeating "trying socat" which i assume means that it failes opening the socket. Any idea why it's not working for me? For now this behavior only occurs when running via exec-once.

ikalco commented 4 months ago

turns out its broken on v0.41.1, update to v0.41.2 or git actually only fixed in git