This commit is contained in:
nnduc
2026-09-21 19:05:35 +07:00
parent ca45037e65
commit 55cb16f74c
7 changed files with 270 additions and 127 deletions
+45 -26
View File
@@ -14,40 +14,50 @@ set $mod Mod1
#set $up k
#set $right l
# Your preferred terminal emulator
set $term xfce4-terminal
set $term alacritty
# Your preferred application launcher
# Note: pass the final command to swaymsg so that the resulting window can be opened
# on the original workspace that the command was run on.
#set $menu wofi --show drun
set $menu rofi -show drun
# Font for window titles.
font pango:NotoSans 12
### Output configuration
#
# Default wallpaper (more resolutions are available in /usr/share/backgrounds/sway/)
set $bg /data/sync/images/wallpapers/0002.png
set $screenlock 'swaylock -i $bg'
set $images $(xdg-user-dir PICTURES)/$(date +'%s_grim.png')
set $wallpaper_dir /media/sync/images/wallpapers
set $screenlock '~/.config/sway/scripts/lock-now $wallpaper_dir'
#
exec --no-startup-id swaybg -m fill -i $bg
exec --no-startup-id ~/.config/sway/scripts/wallpaper-rotate $wallpaper_dir
# Example configuration:
#
#output HDMI-A-1 resolution 1920x1080@120hz position 1920,0
#
# You can get the names of your outputs by running: swaymsg -t get_outputs
output DP-2 adaptive_sync on
### Idle configuration
#
# Import the compositor socket into the systemd --user environment. Without
# this, systemd-managed services (and dbus-activated apps like portals) can't
# reach the compositor at all - this is why swayidle silently failed to run
# after being restarted via systemd earlier.
exec --no-startup-id systemctl --user import-environment WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP DISPLAY
exec --no-startup-id hash dbus-update-activation-environment 2>/dev/null && dbus-update-activation-environment --systemd WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP DISPLAY
#
# Example configuration:
#
exec swayidle -w \
timeout 900 $screenlock \
timeout 1800 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \
timeout 300 $screenlock \
timeout 900 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \
before-sleep $screenlock
#
# 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.
# This will lock your screen after 300 seconds (5 min) of inactivity, then
# turn off your displays after 900 seconds (15 min), and turn your screens
# back on when resumed. It will also lock your screen before your computer
# goes to sleep.
### Input configuration
input "type:touchpad" {
@@ -70,7 +80,7 @@ exec swayidle -w \
input "2:7:SynPS/2_Synaptics_TouchPad" {
events disabled_on_external_mouse
}
input "5426:156:Razer_Razer_DeathAdder_V2_X_HyperSpeed" {
input "5426:156:Razer_Razer_DeathAdder_V2_X_HyperSpeed_Mouse" {
accel_profile "flat" # disable mouse acceleration (enabled by default; to set it manually, use "adaptive" instead of "flat")
pointer_accel 0.5 # set mouse sensitivity (between -1 and 1)
}
@@ -117,8 +127,8 @@ bindsym $mod+Shift+comma exec playerctl previous
bindsym $mod+Shift+period exec playerctl next
bindsym $mod+Shift+slash exec playerctl play-pause
bindsym Print exec grim -g "$(slurp)" - | wl-copy
bindsym $mod+Print exec grim -o $images
bindsym Print exec --no-startup-id bash -c 'f="$(xdg-user-dir PICTURES)/$(date +%s_grim.png)" && grim -g "$(slurp)" "$f" && wl-copy < "$f" && notify-send "Screenshot saved" "$f"'
bindsym $mod+Print exec --no-startup-id bash -c 'f="$(xdg-user-dir PICTURES)/$(date +%s_grim.png)" && grim "$f" && wl-copy < "$f" && notify-send "Screenshot saved" "$f"'
### Key bindings
#
# Basics:
@@ -132,16 +142,19 @@ bindsym $mod+Shift+q kill
# Start your launcher
bindsym $mod+d exec $menu
#
bindsym $mod+l exec $screenlock
bindsym $mod+l exec ~/.config/sway/scripts/lock-now $wallpaper_dir
bindsym $mod+Shift+o exec ~/.config/sway/scripts/lock-now $wallpaper_dir && systemctl suspend
# Drag floating windows by holding down $mod and left mouse button.
# Resize them with right mouse button + $mod.
# Despite the name, also works for non-floating windows.
# Change normal to inverse to use left mouse button for resizing and right
# mouse button for dragging.
floating_modifier $mod normal
floating_modifier $mod
# Reload the configuration file
bindsym $mod+Shift+c reload
# restart sway in place (preserves your layout/session, can be used to upgrade sway)
bindsym $mod+Shift+r restart
# Exit sway (logs you out of your Wayland session)
#bindsym $mod+Shift+e exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -B 'Yes, exit sway' 'swaymsg exit'
@@ -197,10 +210,10 @@ bindsym $mod+Shift+0 move container to workspace number 10
# Layout stuff:
#
# You can "split" the current object of your focus with
# $mod+b or $mod+v, for horizontal and vertical splits
# $mod+h or $mod+v, for horizontal and vertical splits
# respectively.
bindsym $mod+b splith
bindsym $mod+v splitv
bindsym $mod+h split h
bindsym $mod+v split v
# Switch the current container between different layout styles
bindsym $mod+s layout stacking
@@ -208,7 +221,7 @@ bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split
# Make the current focus fullscreen
bindsym $mod+Shift+space fullscreen
bindsym $mod+Shift+space fullscreen toggle
# Toggle the current focus between tiling and floating mode
bindsym $mod+f floating toggle
@@ -259,15 +272,21 @@ mode "resize" {
}
bindsym $mod+r mode "resize"
#
# Status Bar:
#
# Read `man 5 sway-bar` for more information about this section.
bar {
}
# Status bar is provided by waybar (started above); no built-in sway bar.
# class border bground text indicator child_border
client.focused #3A7CA5 #3A7CA5 #E2EBF0 #0D1B27 #3A7CA5
client.placeholder #0D1B27 #0D1B27 #BDD5E4 #0D1B27 #0D1B27
client.unfocused #0D1B27 #152535 #6A8DA0 #0D1B27 #152535
client.focused_inactive #1A3347 #1A3347 #6A8DA0 #1A3347 #1A3347
for_window [class="^.*"] border pixel 1
# Don't lock or blank the screen while a fullscreen window (game, video,
# presentation) is focused - ties into the same idle protocol swayidle uses.
for_window [app_id="^.*"] inhibit_idle fullscreen
for_window [class="^.*"] inhibit_idle fullscreen
#floating
for_window [app_id="signal"] floating enable
for_window [app_id="fluffychat"] floating enable
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash
wall_dir="${1:?wallpaper directory required}"
img=$(find "$wall_dir" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) | shuf -n1)
if [ -n "$img" ]; then
exec swaylock -i "$img"
else
exec swaylock
fi
+48
View File
@@ -0,0 +1,48 @@
#!/bin/bash
wall_dir="${1:?wallpaper directory required}"
interval="${2:-1800}"
pick_wall() {
find "$wall_dir" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) | shuf -n1
}
set_wall() {
[ -n "$1" ] || return
pkill -x swaybg
swaybg -m fill -i "$1" &
}
has_fullscreen() {
python3 - <<'EOF'
import json, subprocess, sys
def is_fullscreen(node):
if node.get('window') and node.get('fullscreen_mode', 0) > 0: return True
return any(is_fullscreen(c) for c in node.get('nodes', []) + node.get('floating_nodes', []))
def find_ws(node, name):
if node.get('type') == 'workspace' and node.get('name') == name: return node
for c in node.get('nodes', []) + node.get('floating_nodes', []):
r = find_ws(c, name)
if r: return r
try:
wss = json.loads(subprocess.check_output(['swaymsg', '-t', 'get_workspaces'], stderr=subprocess.DEVNULL))
tree = json.loads(subprocess.check_output(['swaymsg', '-t', 'get_tree'], stderr=subprocess.DEVNULL))
for ws in wss:
if ws.get('visible'):
node = find_ws(tree, ws['name'])
if node and is_fullscreen(node):
sys.exit(0)
except Exception:
pass
sys.exit(1)
EOF
}
# Initial wallpaper
set_wall "$(pick_wall)"
while sleep "$interval"; do
has_fullscreen || set_wall "$(pick_wall)"
done
+1 -2
View File
@@ -1,5 +1,4 @@
# Set a background image
image=/data/sync/images/wallpapers/0002.png
# Background image is picked at lock time by scripts/lock-now (-i flag)
# Set the scaling mode for the image
scaling=fill