# Hyprland Getting-Started: Configure Screen Lock, Brightness, Volume, Authentication and More

You can find the bash scripts and configurations at [`https://github.com/FlareXes/dotfiles`](https://github.com/FlareXes/dotfiles). New scripts are regularly added, and existing ones are kept up to date. Feel free to explore the repository. If you have any questions, I'm here to help!

## Screen Lock

Install `hyprlock`

```bash
sudo pacman -S hyprlock
```

Edit `hyprland.conf` under `~/.config/hypr/hyprland.conf`, to lock screen on `super + l`.

```ini
# Mute and lock the system
bind = $mainMod, L, exec, pactl set-sink-mute @DEFAULT_SINK@ 1 && hyprlock
```

You can learn more about `hyprlock` configuration at [Hyprland Wiki](https://wiki.hyprland.org/Hypr-Ecosystem/hyprlock/).

### Screen Lock on Timeout

Install `hypridle`

```bash
sudo pacman -S hypridle
```

Create `hypridle.conf` under `~/.config/hypr/hypridle.conf`, to configure idle state.

```ini
general {
    lock_cmd = pidof hyprlock || hyprlock
    before_sleep_cmd = loginctl lock-session    # lock before suspend
    after_sleep_cmd = hyprctl dispatch dpms on
}

# Lock the screen (10 min)
listener {
    timeout = 600
    on-timeout = loginctl lock-session
}

# Turn off screen (15 min)
listener {
    timeout = 900
    on-timeout = hyprctl dispatch dpms off
    on-resume = hyprctl dispatch dpms on
}

# Suspend the system (30 min)
listener {
    timeout = 1800
    on-timeout = systemctl suspend
}
```

* `lock_cmd`: only execute `hyprlock` if not running, to avoid multiple instance of `hyprlock`.
    
* Lock screen after 10 minutes without turning off the screen.
    
* Turn off the screen after 15 minutes and turn on when activity is detected.
    
* Suspend the system after 30 minutes to save power.
    

Edit `~/.config/hypr/hyprland.conf` to autostart `hypridle` once user login.

```ini
exec-once = hypridle
```

You can learn more about `hypridle` configuration at [Hyprland Wiki](https://wiki.hyprland.org/Hypr-Ecosystem/hypridle/).

## Brightness Adjustment

Install

* `brightnessctl` for brightness adjustments, *required*.
    

```bash
sudo pacman -S bc brightnessctl
```

Edit `~/.config/hypr/hyprland.conf` to control brightness via keyboard function keys.

```ini
bind = , code:232, exec, brightnessctl set 5%-
bind = , code:233, exec, brightnessctl set +5%
```

## Volume Adjustment

Install

* `playerctl` media player controller for wide range of application. Here, required to pause audio/video.
    

Edit `~/.config/hypr/hyprland.conf` to control volume levels via keyboard function keys.

```ini
bindl = , XF86AudioPlay, exec, playerctl play-pause                                         # Pause audio/video
bindl = , XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle                   # Mute audio
bindel = , XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 10%-           # Decrease volume
bindel = , XF86AudioRaiseVolume, exec, wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 10%+    # Increase volume upto 150
```

## Take Screenshots

For screenshots I use my own script [Hyprshot](https://github.com/FlareXes/hyprshot/) available on GitHub.

Install

* `slurp` to select a region for screenshot.
    
* `grim` a screenshot utility for Wayland.
    
* `satty` to edit/annotate screenshots.
    
* `wl-clipboard` to copy to clipboard.
    

```bash
sudo pacman -S slurp grim satty wl-clipboard
```

Create [`hyprshot.sh`](http://screenshot.sh) script under `~/.local/bin/hyprshot.sh`

```bash
#!/usr/bin/env bash
set -euo pipefail
#
# Notes:
#   - Press Esc to cancel selection.
#   - Output directory is fixed at: ~/Pictures/Screenshots 

SCREENSHOT_DIR="$HOME/Pictures/Screenshots"
DATE_FMT="%Y-%m-%d_%H-%M-%S"
FILE_PREFIX="screenshot"
OUTFILE="$SCREENSHOT_DIR/${FILE_PREFIX}-$(date +"$DATE_FMT").png"

# Checking and installing dependencies
dependencies=("slurp" "grim" "satty" "wl-copy")
for dep in "${dependencies[@]}"; do
    command -v "$dep" &> /dev/null || { echo "$dep not found, please install it."; exit 1; }
done

# Ensure screenshot directory exists
mkdir -p "$SCREENSHOT_DIR"

# Kill slurp if already running
pkill -x slurp && exit 0

# Capture screenshot
screenshot="$(slurp || true)"

# Cancel if user esc
[ -z "$screenshot" ] && exit 0

# Take screenshot -> open in satty -> save file + copy to clipboard
grim -g "$screenshot" - | satty --filename - \
    --output-filename "$OUTFILE" \
    --early-exit \
    --actions-on-enter save-to-clipboard \
    --copy-command 'wl-copy'
```

Edit `~/.config/hypr/hyprland.conf` to add keybinding to take screenshot on `super + s`.

```ini
bind = $mainMod, S, exec, ~/.local/bin/hyprshot.sh
```

You can also visit my GitHub to get the up-to date copy of [hyprshot](https://github.com/FlareXes/hyprshot/).

## Change Wallpaper from Command-line

Install

* `swww` to change wallpaper.
    

```bash
sudo pacman -S swww
```

Edit `~/.config/hypr/hyprland.conf` to autostart `swww-daemon` once user login.

```bash
exec-once = swww-daemon
```

To change wallpaper run:

```bash
swww img <wallpaper_file.png>
```

To change wallpaper with smooth transition run:

```bash
swww img --transition-type random --transition-fps 60 <wallpaper_file.png>
```

## Color Picker

Install

* `hyprpicker`, color picker
    
* `wl-clipboard` to copy hex code to clipboard.
    

Edit `~/.config/hypr/hyprland.conf` to add keybinding to launch color picker on `super + p`.

```ini
bind = $mainMod, P, exec, hyprpicker --autocopy
```

That’s it.

Script to color picker in **hex**, **rgb**, **hsl**, **hsv**, **cmyk** format with selection/dmenu mode.

Save it under `~/.local/bin/` as `hyprpicker.sh`

```bash
#!/usr/bin/env bash

# Available formats
FORMATS="hex\nrgb\nhsl\nhsv\ncmyk"

# Show wofi menu
FORMAT=$(echo -e "$FORMATS" | rofi -dmenu -p "Format")

# Exit if nothing selected
[ -z "$FORMAT" ] && exit 0

# Run hyprpicker with selected format
hyprpicker -a -f "$FORMAT"
```

Edit `~/.config/hypr/hyprland.conf` to add keybinding to launch color picker on `super + shift + p`.

```ini
bind = $mainMod SHIFT, P, exec, bash ~/.local/bin/hyprpicker.sh
```

## Quick and Easy

### Screen Sharing

```bash
sudo pacman -S xdg-desktop-portal-hyprland
```

### Turn Off Laptop Display on Lid Close

Edit `~/.config/hypr/hyprland.conf`.

```ini
bindl = , switch:on:Lid Switch, exec, hyprctl dispatch dpms off
bindl = , switch:off:Lid Switch, exec, hyprctl dispatch dpms on
```

### GUI Authentication

`polkit-gnome` is a polkit authentication daemon. It is required for GUI applications to request elevated privileges.

```bash
sudo pacman -S polkit-gnome
```

Edit `~/.config/hypr/hyprland.conf` to autostart `polkit-gnome` once user login.

```ini
exec-once = /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1
```

### **Further Reading**

* [Fix Missing Directories & External Drives in Thunar File Manager on Hyprland](https://flarexes.com/fix-missing-directories-and-external-drives-in-thunar-file-manager-on-hyprland)
