Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use swayidle & swaylock #12

Merged
merged 2 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions includes.container/etc/sway/config.vanillaos
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,6 @@ output * bg /usr/share/backgrounds/vanilla/petals_light.webp stretch
#
# You can get the names of your outputs by running: swaymsg -t get_outputs

### Idle configuration
#
# Example configuration:
#
# exec swayidle -w \
# timeout 300 'swaylock -f -c 000000' \
# timeout 600 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \
# before-sleep 'swaylock -f -c 000000'
#
# This will lock your screen after 300 seconds of inactivity, then turn off
# your displays after another 300 seconds, and turn your screens back on when
# resumed. It will also lock your screen before your computer goes to sleep.

### Input configuration
#
# Example configuration:
Expand Down Expand Up @@ -209,7 +196,7 @@ bar {

# When the status_command prints a new line to stdout, swaybar updates.
# The default just shows the current date and time.
status_command while date +'%Y-%m-%d %X'; do sleep 1; done
status_command /usr/bin/swayrbar

colors {
statusline #ffffff
Expand Down
6 changes: 6 additions & 0 deletions includes.container/etc/xdg/swayidle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
before-sleep 'systemctl --user start swaylock'
lock 'systemctl --user start swaylock'
unlock 'swaymsg "output * dpms on"'
after-resume 'swaymsg "output * dpms on"'
timeout 300 'systemctl --user start swaylock'
timeout 600 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"'
1 change: 1 addition & 0 deletions includes.container/etc/xdg/swaylock/config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
color=303638
68 changes: 68 additions & 0 deletions includes.container/etc/xdg/swayrbar/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
refresh_interval = 1000

[[modules]]
name = "window"
instance = "0"
format = "🪟 {title} — {app_name}"
html_escape = false

[modules.on_click]
Left = [
"swayr",
"switch-to-urgent-or-lru-window",
]
Right = [
"kill",
"{pid}",
]

[[modules]]
name = "sysinfo"
instance = "0"
format = "💻 CPU: {cpu_usage:{:5.1}}% Mem: {mem_usage:{:5.1}}% Load: {load_avg_1:{:5.2}} / {load_avg_5:{:5.2}} / {load_avg_15:{:5.2}}"
html_escape = false

[modules.on_click]
Left = [
"foot",
"htop",
]

[[modules]]
name = "battery"
instance = "0"
format = "🔋 Bat: {state_of_charge:{:5.1}}%, {state}, Health: {state_of_health:{:5.1}}%"
html_escape = false

[[modules]]
name = "pactl"
instance = "0"
format = "🔈 Vol: {volume:{:3}}%{muted}"
html_escape = true

[modules.on_click]
Right = [
"pactl",
"set-sink-mute",
"@DEFAULT_SINK@",
"toggle",
]
WheelUp = [
"pactl",
"set-sink-volume",
"@DEFAULT_SINK@",
"+1%",
]
WheelDown = [
"pactl",
"set-sink-volume",
"@DEFAULT_SINK@",
"-1%",
]
Left = ["pavucontrol"]

[[modules]]
name = "date"
instance = "0"
format = "⏰ %F %X"
html_escape = false
11 changes: 11 additions & 0 deletions includes.container/usr/lib/systemd/user/swayidle.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Idle manager for Wayland
Documentation=man:swayidle(1)
PartOf=graphical-session.target

[Service]
Type=simple
ExecStart=/usr/bin/swayidle -w -d -C /etc/xdg/swayidle/config

[Install]
WantedBy=sway-session.target
12 changes: 12 additions & 0 deletions includes.container/usr/lib/systemd/user/swaylock.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Screen locker for Wayland
Documentation=man:swaylock(1)
PartOf=graphical-session.target
After=sway-session.target

[Service]
Type=simple
ExecStart=/usr/bin/swaylock -d
# SIGUSR1: Unlock the screen and exit.
KillSignal=SIGUSR1
Restart=on-failure
21 changes: 21 additions & 0 deletions recipe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ stages:
- swaylock
- fonts-font-awesome
- fuzzel
- pulseaudio-utils # pactl

- name: sway-config-overwrite
type: shell
Expand All @@ -49,6 +50,26 @@ stages:
- rm -rv /wayland-sessions
- echo Sway session updated for Vanilla-OS

# swaylock starts /sbin/unix_chkpwd as user via pam.
# unix_chkpwd tries to read /etc/shadow but only root is allowed to.
# The quick solution is to set the s-bit for the root of /sbin/unix_chkpwd.
# The more secure solution would be that swaylock uses saslauthd.
# Note: Changing the group of /etc/shadow does not help.
- name: swaylock-fix
type: shell
commands:
- ls -l /sbin/unix_chkpwd /etc/shadow
# ```console
# -rwxr-sr-x 1 root shadow /sbin/unix_chkpwd
# -rw-r----- 1 root root /etc/shadow
# ```
- chmod u+s /sbin/unix_chkpwd
- ls -l /sbin/unix_chkpwd /etc/shadow
# ```console
# -rwsr-sr-x 1 root shadow /sbin/unix_chkpwd
# -rw-r----- 1 root root /etc/shadow
# ```

# Put your custom actions before this comment

- name: set-image-name-abroot
Expand Down
Loading