Garuda Hyprland doesn't lock the screen and doesn't go sleep in idle

Hi.

My system does not lock the screen and does not go sleep/suspend mode.

In the waybar conf i did not change nothing.
After i realized that does not working i add this to the hyprland.conf

# Set Lock and Sleep
exec-once = ~/.config/hypr/scripts/sleep.sh

but still doesn’t go sleep or lock screen.

inxi:

System:
  Kernel: 6.7.2-zen1-1-zen arch: x86_64 bits: 64 compiler: gcc v: 13.2.1
    clocksource: tsc available: acpi_pm
    parameters: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen
    root=UUID=095c9f1d-4e23-42b2-aa42-36402880711e rw rootflags=subvol=@
    quiet resume=UUID=4b8a0d61-7df0-445b-9329-0c5cf2f2c346 loglevel=3
    ibt=off
  Desktop: Hyprland info: waybar vt: 1 dm: SDDM Distro: Garuda Linux
    base: Arch Linux
Machine:
  Type: Laptop System: Dell product: Vostro 3580 v: N/A
    serial: <superuser required> Chassis: type: 10 serial: <superuser required>
  Mobo: Dell model: 0PMTCG v: A00 serial: <superuser required> UEFI: Dell
    v: 1.27.0 date: 11/16/2023
Battery:
  ID-1: BAT0 charge: 29.3 Wh (100.0%) condition: 29.3/42.0 Wh (69.8%)
    volts: 12.7 min: 11.4 model: BYD DELL 1VX1H97 type: Li-ion serial: <filter>
    status: full
  Device-1: hidpp_battery_0 model: Logitech Wireless Keyboard
    serial: <filter> charge: 55% (should be ignored) rechargeable: yes
    status: discharging
CPU:
  Info: model: Intel Core i5-8265U bits: 64 type: MT MCP
    arch: Comet/Whiskey Lake note: check gen: core 8 level: v3 note: check
    built: 2018 process: Intel 14nm family: 6 model-id: 0x8E (142)
    stepping: 0xC (12) microcode: 0xF8
  Topology: cpus: 1x cores: 4 tpc: 2 threads: 8 smt: enabled cache:
    L1: 256 KiB desc: d-4x32 KiB; i-4x32 KiB L2: 1024 KiB desc: 4x256 KiB
    L3: 6 MiB desc: 1x6 MiB
  Speed (MHz): avg: 1615 high: 3746 min/max: 400/3900 scaling:
    driver: intel_pstate governor: performance cores: 1: 400 2: 3746 3: 3561
    4: 400 5: 400 6: 3614 7: 400 8: 400 bogomips: 28800
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
  Vulnerabilities: <filter>
Graphics:
  Device-1: Intel WhiskeyLake-U GT2 [UHD Graphics 620] vendor: Dell
    driver: i915 v: kernel arch: Gen-9.5 process: Intel 14nm built: 2016-20
    ports: active: HDMI-A-1,eDP-1 empty: DP-1,HDMI-A-2 bus-ID: 0000:00:02.0
    chip-ID: 8086:3ea0 class-ID: 0300
  Device-2: Sunplus Innovation Integrated_Webcam_HD driver: uvcvideo
    type: USB rev: 2.0 speed: 480 Mb/s lanes: 1 mode: 2.0 bus-ID: 1-6:3
    chip-ID: 1bcf:2b98 class-ID: 0e02
  Display: wayland server: X.org v: 1.21.1.11 with: Xwayland v: 23.2.4
    compositor: Hyprland driver: X: loaded: modesetting
    alternate: fbdev,intel,vesa dri: iris gpu: i915 d-rect: 4480x1080
    display-ID: 1
  Monitor-1: HDMI-A-1 pos: right model: LG (GoldStar) ULTRAWIDE
    serial: <filter> built: 2014 res: 2560x1080 hz: 60 dpi: 112 gamma: 1.2
    scale: 1 size: 677x290mm (26.65x11.42") diag: 628mm (24.7") modes:
    max: 2560x1080 min: 720x400
  Monitor-2: eDP-1 pos: primary,left model: AU Optronics 0x38ed built: 2015
    res: 1920x1080 hz: 60 dpi: 142 gamma: 1.2 scale: 1
    size: 344x193mm (13.54x7.6") diag: 394mm (15.5") ratio: 16:9
    modes: 1920x1080
  API: Vulkan v: 1.3.276 layers: 3 device: 0 type: integrated-gpu
    name: Intel UHD Graphics 620 (WHL GT2) driver: mesa intel v: 23.3.4-arch1.2
    device-ID: 8086:3ea0 surfaces: xcb,xlib,wayland device: 1 type: cpu
    name: llvmpipe (LLVM 16.0.6 256 bits) driver: mesa llvmpipe
    v: 23.3.4-arch1.2 (LLVM 16.0.6) device-ID: 10005:0000
    surfaces: xcb,xlib,wayland
  API: EGL Message: EGL data requires eglinfo. Check --recommends.
Audio:
  Device-1: Intel Cannon Point-LP High Definition Audio vendor: Dell
    driver: snd_hda_intel v: kernel
    alternate: snd_soc_skl,snd_sof_pci_intel_cnl bus-ID: 0000:00:1f.3
    chip-ID: 8086:9dc8 class-ID: 0403
  API: ALSA v: k6.7.2-zen1-1-zen status: kernel-api tools: N/A
  Server-1: sndiod v: N/A status: off tools: aucat,midicat,sndioctl
  Server-2: PipeWire v: 1.0.1 status: active with: 1: pipewire-pulse
    status: active 2: wireplumber status: active 3: pipewire-alsa type: plugin
    4: pw-jack type: plugin tools: pactl,pw-cat,pw-cli,wpctl
Network:
  Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet
    vendor: Dell driver: r8169 v: kernel port: 3000 bus-ID: 0000:01:00.0
    chip-ID: 10ec:8168 class-ID: 0200
  IF: enp1s0 state: down mac: <filter>
  Device-2: Qualcomm Atheros QCA9377 802.11ac Wireless Network Adapter
    vendor: Dell driver: ath10k_pci v: kernel bus-ID: 0000:02:00.0
    chip-ID: 168c:0042 class-ID: 0280
  IF: wlp2s0 state: up mac: <filter>
  IF-ID-1: wguk133t state: unknown speed: N/A duplex: N/A mac: N/A
Bluetooth:
  Device-1: Qualcomm Atheros driver: btusb v: 0.8 type: USB rev: 2.0
    speed: 12 Mb/s lanes: 1 mode: 1.1 bus-ID: 1-10:4 chip-ID: 0cf3:e009
    class-ID: e001
  Report: btmgmt ID: hci0 rfk-id: 0 state: down bt-service: enabled,running
    rfk-block: hardware: no software: yes address: <filter> bt-v: 4.2 lmp-v: 8
    status: discoverable: no pairing: no
RAID:
  Hardware-1: Intel 82801 Mobile SATA Controller [RAID mode]
    driver: intel_nvme_remap v: N/A port: 4060 bus-ID: 0000:00:17.0
    chip-ID: 8086:282a rev: N/A class-ID: 0104
Drives:
  Local Storage: total: 1.36 TiB used: 565.1 GiB (40.6%)
  SMART Message: Required tool smartctl not installed. Check --recommends
  ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Toshiba
    model: KBG40ZNS256G NVMe 256GB size: 238.47 GiB block-size: physical: 512 B
    logical: 512 B tech: SSD serial: <filter> fw-rev: 10410106 temp: 23.9 C
    scheme: GPT
  ID-2: /dev/sda maj-min: 8:0 vendor: A-Data model: SU630 size: 223.57 GiB
    block-size: physical: 512 B logical: 512 B speed: 6.0 Gb/s tech: SSD
    serial: <filter> fw-rev: 3R17 scheme: GPT
  ID-3: /dev/sdb maj-min: 8:16 vendor: Samsung model: ST1000LM 024 HN-M101M
    size: 931.51 GiB block-size: physical: 4096 B logical: 512 B type: USB
    rev: 3.0 spd: 5 Gb/s lanes: 1 mode: 3.2 gen-1x1 tech: N/A
    serial: <filter> fw-rev: 2AR2 scheme: MBR
Partition:
  ID-1: / raw-size: 60 GiB size: 60 GiB (100.00%) used: 8.81 GiB (14.7%)
    fs: btrfs dev: /dev/nvme0n1p3 maj-min: 259:3
  ID-2: /boot/efi raw-size: 300 MiB size: 299.4 MiB (99.80%)
    used: 584 KiB (0.2%) fs: vfat dev: /dev/nvme0n1p2 maj-min: 259:2
  ID-3: /home raw-size: 162.16 GiB size: 162.16 GiB (100.00%)
    used: 9.46 GiB (5.8%) fs: btrfs dev: /dev/nvme0n1p4 maj-min: 259:4
  ID-4: /var/log raw-size: 60 GiB size: 60 GiB (100.00%)
    used: 8.81 GiB (14.7%) fs: btrfs dev: /dev/nvme0n1p3 maj-min: 259:3
  ID-5: /var/tmp raw-size: 60 GiB size: 60 GiB (100.00%)
    used: 8.81 GiB (14.7%) fs: btrfs dev: /dev/nvme0n1p3 maj-min: 259:3
Swap:
  Kernel: swappiness: 133 (default 60) cache-pressure: 100 (default)
    zswap: no
  ID-1: swap-1 type: zram size: 7.63 GiB used: 1.23 GiB (16.1%)
    priority: 100 comp: zstd avail: lzo,lzo-rle,lz4,lz4hc,842 max-streams: 8
    dev: /dev/zram0
  ID-2: swap-2 type: partition size: 16.01 GiB used: 0 KiB (0.0%)
    priority: -2 dev: /dev/nvme0n1p5 maj-min: 259:5
Sensors:
  System Temperatures: cpu: 61.0 C pch: 57.0 C mobo: 43.0 C
  Fan Speeds (rpm): cpu: 0
Info:
  Processes: 308 Uptime: 43m wakeups: 0 Memory: total: 8 GiB
  available: 7.63 GiB used: 4.54 GiB (59.5%) Init: systemd v: 255
  default: graphical tool: systemctl Compilers: gcc: 13.2.1 Packages:
  pm: pacman pkgs: 1439 libs: 417 tools: paru Shell: fish v: 3.7.0
  running-in: foot inxi: 3.3.31
Garuda (2.6.22-1):
  System install date:     2024-01-21
  Last full system update: 2024-01-28
  Is partially upgraded:   No
  Relevant software:       snapper NetworkManager dracut
  Windows dual boot:       Probably (Run as root to verify)
  Failed units:            

thank you.

Read that script. For that script to work you need swayidle swayidle(1) — Arch manual pages which is not installed by default. Install it. That command will put your system to sleep if no activity is going on for a set period of time.

To manually go to sleep you can use the nwg-drawer at top and click on suspend but you will notice that it doesn’t lock your screen you have to set appropriate systemd service files for that so that the system locks screen before going to sleep.

Read this archwiki article to understand how to setup sleep hooks, Power management - ArchWiki

here is mine suspend hook for locking screen before sleeping. I haven’t made any resume hook since I didn’t need it. Read archwiki to understand where to place it and how to enable it.

[Unit]
Description=User suspend actions
Before=sleep.target

[Service]
User=%I
Type=forking
Environment=DISPLAY=:1 XDG_RUNTIME_DIR=/run/user/1000 WAYLAND_DISPLAY=wayland-1
ExecStart=/usr/bin/swaylock -f
ExecStartPost=/usr/bin/sleep 1

[Install]
WantedBy=sleep.target
3 Likes

Thank you, i just installed now.

yes i noticed it, it will missing, i will have a look.

thank you the links and your example.

the swayidle now working, but the lock.sh script in the “.config/hypr/script/” is not. i get this error:

╰─λ ./sleep.sh
Updated device 'intel_backlight':
Device 'intel_backlight' of class 'backlight':
	Current brightness: 15314 (13%)
	Max brightness: 120000

swaylock: unrecognized option '--screenshots'
Usage: swaylock [options...]

  -C, --config <config_file>       Path to the config file.
  -c, --color <color>              Turn the screen into the given color instead of white.
  -d, --debug                      Enable debugging output.
  -e, --ignore-empty-password      When an empty password is provided, do not validate it.
  -F, --show-failed-attempts       Show current count of failed authentication attempts.
  -f, --daemonize                  Detach from the controlling terminal after locking.
  -h, --help                       Show help message and quit.
  -i, --image [[<output>]:]<path>  Display the given image, optionally only on the given output.
  -k, --show-keyboard-layout       Display the current xkb layout while typing.
  -K, --hide-keyboard-layout       Hide the current xkb layout while typing.
  -L, --disable-caps-lock-text     Disable the Caps Lock text.
  -l, --indicator-caps-lock        Show the current Caps Lock state also on the indicator.
  -s, --scaling <mode>             Image scaling mode: stretch, fill, fit, center, tile, solid_color.
  -t, --tiling                     Same as --scaling=tile.
  -u, --no-unlock-indicator        Disable the unlock indicator.
  -v, --version                    Show the version number and quit.
  --bs-hl-color <color>            Sets the color of backspace highlight segments.
  --caps-lock-bs-hl-color <color>  Sets the color of backspace highlight segments when Caps Lock is active.
  --caps-lock-key-hl-color <color> Sets the color of the key press highlight segments when Caps Lock is active.
  --font <font>                    Sets the font of the text.
  --font-size <size>               Sets a fixed font size for the indicator text.
  --indicator-idle-visible         Sets the indicator to show even if idle.
  --indicator-radius <radius>      Sets the indicator radius.
  --indicator-thickness <thick>    Sets the indicator thickness.
  --indicator-x-position <x>       Sets the horizontal position of the indicator.
  --indicator-y-position <y>       Sets the vertical position of the indicator.
  --inside-color <color>           Sets the color of the inside of the indicator.
  --inside-clear-color <color>     Sets the color of the inside of the indicator when cleared.
  --inside-caps-lock-color <color> Sets the color of the inside of the indicator when Caps Lock is active.
  --inside-ver-color <color>       Sets the color of the inside of the indicator when verifying.
  --inside-wrong-color <color>     Sets the color of the inside of the indicator when invalid.
  --key-hl-color <color>           Sets the color of the key press highlight segments.
  --layout-bg-color <color>        Sets the background color of the box containing the layout text.
  --layout-border-color <color>    Sets the color of the border of the box containing the layout text.
  --layout-text-color <color>      Sets the color of the layout text.
  --line-color <color>             Sets the color of the line between the inside and ring.
  --line-clear-color <color>       Sets the color of the line between the inside and ring when cleared.
  --line-caps-lock-color <color>   Sets the color of the line between the inside and ring when Caps Lock is active.
  --line-ver-color <color>         Sets the color of the line between the inside and ring when verifying.
  --line-wrong-color <color>       Sets the color of the line between the inside and ring when invalid.
  -n, --line-uses-inside           Use the inside color for the line between the inside and ring.
  -r, --line-uses-ring             Use the ring color for the line between the inside and ring.
  --ring-color <color>             Sets the color of the ring of the indicator.
  --ring-clear-color <color>       Sets the color of the ring of the indicator when cleared.
  --ring-caps-lock-color <color>   Sets the color of the ring of the indicator when Caps Lock is active.
  --ring-ver-color <color>         Sets the color of the ring of the indicator when verifying.
  --ring-wrong-color <color>       Sets the color of the ring of the indicator when invalid.
  --separator-color <color>        Sets the color of the lines that separate highlight segments.
  --text-color <color>             Sets the color of the text.
  --text-clear-color <color>       Sets the color of the text when cleared.
  --text-caps-lock-color <color>   Sets the color of the text when Caps Lock is active.
  --text-ver-color <color>         Sets the color of the text when verifying.
  --text-wrong-color <color>       Sets the color of the text when invalid.

All <color> options are of the form <rrggbb[aa]>.
ok

Updated device 'intel_backlight':
Device 'intel_backlight' of class 'backlight':
	Current brightness: 30628 (26%)
	Max brightness: 120000

ok

I tried just run

swaylock -f

this is locked the screen but i got a full white background, not the same what i get from the power menu. I am not a very advanced user, but if you tell me where are the config file i will figure it out.

i checked the .config/swaylock/config but when i chaged that, not really get what i changed…

thank you.

If you read the script it’s calling for lock.sh which calls swaylock with a bunch of options that don’t really exist for swaylock. This is not a problem as swaylock will still work as I had stated before this script is supposed to timeout your screen after an interval rather than immediately lock it. That’s what swayidle does, look for when system is idle.

If you define ~/.config/swaylock/config then you won’t need to pass config options to swaylock manually all the time as done in lock.sh,

cat config 
File: config
indicator-caps-lock
font=FiraSans
indicator-radius=125
line-color=#3b4252
text-color=#d8dee9
inside-color=#2e344098
inside-ver-color=#5e81ac
line-ver-color=#5e81ac
ring-ver-color=#5e81ac98
ring-color=#4c566a
key-hl-color=#5e81ac
separator-color=#4c566a
layout-text-color=#eceff4
line-wrong-color=#d08770
show-failed-attempts
image='/usr/share/wallpapers/garuda-wallpapers/Garuda-TilliDie-cube-105.png'

here is my script put this in the config file I mentioned (~/.config/swaylock/config)

then perform

swaylock -f

and see it will not give you a whitescreen anymore. I don’t quite remember the name of the project that takes all the extended options provided in the lock.sh config file but I suppose you can find that on your own as well.

1 Like

Yes, now i got the same lock screen. and changed the sleep.sh

#!/bin/sh
swayidle -w \
                timeout 60 'temp=$(brightnessctl g); brightnessctl set $((temp / 2))' \
                    resume 'temp=$(brightnessctl g); brightnessctl set $((temp * 2))' \
                timeout 120 'swaylock -f & sleep 1 && hyprctl dispatch dpms off' \
                    resume 'hyprctl dispatch dpms on' \
                timeout 420 'systemctl suspend'

Working perfectly.

Next i will check you previous comment, about suspend hook.

Thank you.

edit:
why not accept the swaylock this in the config file?

clock
timestr=%R
datestr=%a, %e of %B

i check a couple dot files and a lot of them has it but here doesnt accept it. i just get a white background when i add to the config. :upside_down_face:

Try this version of swaylock, GitHub - mortie/swaylock-effects: Swaylock, with fancy effects

Download using pacman. I think you would have to remove swaylock to use swaylock effects. This is bascially a fancier implementation of swaylock. It will use the same config file and same commands to do the same things the original swaylock did just with more customization options.

So probably your errors should go away with this.

3 Likes

Now is fine, thank you.

I like this Hyprland version of Garuda.

2 Likes

##Lock screen and Suspend in idle on Hyprland##

I would like detail here how i set up lock the screen with the instructions what @NaN gave me above.

  1. replace swaylock with swaylock-effects and install swayidle
sudo pacman -R swaylock
sudo pacman -S swaylock-effects swayidle
  1. edit the swaylock config file at “/home/[your username]/.config/swaylock/”
cd /home/[your username]/.config/swaylock/

this is my config:

# Caps Lock indicator
indicator-caps-lock

# Font setting
font=FiraSans

# Show date and time
clock
timestr=%R
datestr=%a, %e of %B

# Add current screenshot as wallpaper
screenshots

# Add a picture as wallpaper
# image='/usr/share/wallpapers/garuda-wallpapers/Garuda-TilliDie-cube-105.png'

# Effect for background
effect-blur=5x2
effect-greyscale
# effect-pixelate=5

# Show/Hide indicator circle
indicator
indicator-thickness=20
indicator-caps-lock
indicator-radius=125

# Colors
line-color=#3b4252
text-color=#d8dee9
inside-color=#2e344098
inside-ver-color=#5e81ac
line-ver-color=#5e81ac
ring-ver-color=#5e81ac98
ring-color=#4c566a
key-hl-color=#5e81ac
separator-color=#4c566a
layout-text-color=#eceff4
line-wrong-color=#d08770

# Show wrong typed password
show-failed-attempts
  1. edit the sleep.sh file at "/home/[your username]/.config/hypr/scripts/
    you don’t need do nothing with the lock.sh, later on will have a solution for screen lock.
cd /home/[your username]/.config/hypr/scripts

this is my script:

#!/bin/sh
swayidle -w \
                timeout 60 'temp=$(brightnessctl g); brightnessctl set $((temp / 2))' \
                    resume 'temp=$(brightnessctl g); brightnessctl set $((temp * 2))' \
                timeout 90 'swaylock -f & sleep 1' \
                timeout 180 'hyprctl dispatch dpms off' \
                    resume 'hyprctl dispatch dpms on' \
                timeout 420 'systemctl suspend'

  1. give “x” permission for sleep.sh
sudo chmod +x sleep.sh
  1. edit hyprland.conf. Add this line to your conf file.
# Set Lock and Sleep
exec-once = ~/.config/hypr/scripts/sleep.sh

Don’t forget switch to deactivate the small eye icon next to the calendar!

Save and log out and log in or restart your system and it will woks.

##Lock the screen before suspend!##

So when you click on the suspend in the power menu the system only suspend but not lock the system. I followed the link and i used the file what @NaN provided in the comments above. Here is the steps how i did.
Power management - ArchWiki

  1. make a text file and name it “[email protected]
    add to this and save it (this is from @NaN ):
[Unit]
Description=User suspend actions
Before=sleep.target

[Service]
User=%I
Type=forking
Environment=DISPLAY=:1 XDG_RUNTIME_DIR=/run/user/1000 WAYLAND_DISPLAY=wayland-1
ExecStart=/usr/bin/swaylock -f
ExecStartPost=/usr/bin/sleep 1

[Install]
WantedBy=sleep.target
  1. Copy the file to “/etc/systemd/system/”
    Make sure you are in the folder where you made the file and copy
sudo cp [email protected] /etc/systemd/system/
  1. Enable and start the service
sudo systemctl enable sleep@[your username] && systemctl start sleep@[your username]

If you did everything right, now your system will lock before suspend.

##Lock screen and suspend when lid is closed.##
Hyprland Wiki Switches

  1. Check the name of the lid switch on your laptop.
hyprctl devices

probably on the bottom you will find something like that

Switches:
	Switch Device at 63124b016280:
		Lid Switch

In my case the name is “Lid Switch”

  1. Add this to the hyprland.conf. Note that the switch name is case sensitive!
# lock the screen when close the lid
#bindl=,switch:on:[your switch name],exec,swaylock -l

# lock the screen and suspend when close the lid (need sleep hook)
bindl=,switch:on:[your switch name],exec,systemctl suspend

choose witch settings you need.

If everything was right now should working fine the screen lock and suspend in idle and when closed the laptop lid.

I hope this will helpful for others is well.

Thank you for the help from @NaN

5 Likes

Thank you your help. Now working perfectly the screen lock and suspend function is well. I wrote a summery of the settings above.

1 Like

@NaN @SGS
I am wondering if there is any chance to implement all of this into the Garuda-Hyprland ISO?
It would be nice if it worked out of the box.

I also wonder why nobody from the team has tested and implemented it within the last 21 hours? Why is there no MR from you in Gitlab yet?

Maybe i used not the best word for this. I don’t urge nobody. It was more like a question for the future.

Hmmm, there is a point. I don’t have Gitlab yet. I will set up an account and i will do. I will help how much i can.

3 Likes

Are you open to MR’s in hyprland now? Because I would like to change the default volume control from pactl to pamixer.

The current config allows you to increase speaker volume to infinity which is dangerous for speakers and users might unintentionally do that.

Last time I suggested this you guys were not open to new features.

1 Like

Maybe I misunderstood it last time :thinking:

Yeah, I change to Sway now :smiley: , its nice grey, and has not the pinky pink way … :rofl:

3 Likes

I know it is little off topic here now, but i have a quick question about gitlab. I dont use before so i just check it now.
So i need find the project, make a fork of it, made the changes and open an MR? Did I get the basic?

Yup you are right. For garuda hyprland I believe the repo is this one,

1 Like

Thanks, i found the this earlier.

We highly appreciate contributions of any sort! :blush: To do so, please follow these steps:

We will then review the changes and eventually merge them.

1 Like

I found this on gitlab so i start read and check. thanks.