当前位置: 首页 > news >正文

ArchLinux Wayland 安裝Sway

1. 先安裝 NVIDIA 驅動

2. 啟用 DRM Kernel Mode Setting(最重要!)

確認目前狀態

cat /sys/module/nvidia_drm/parameters/modeset

應該顯示 Y(新版驅動預設已開)

3. 安裝 Sway 與必要套件

sudo pacman -S sway swaybg swaylock swayidle
sudo pacman -S waybar wofi foot wl-clipboard xorg-xwayland

4. 啟動 Sway(關鍵步驟)

推薦先在終端測試 sway --unsupported-gpu
修改桌面檔(用 Display Manager 時)

sudo vim /usr/share/wayland-sessions/sway.desktop

[Desktop Entry]
Name=Sway
Comment=An i3-compatible Wayland compositor
Exec=sway --unsupported-gpu
Type=Application
DesktopNames=sway;wlroots

6. 基本設定檔入門

複製範本,詳細文檔見本文底部。

mkdir -p ~/.config/sway
cp /etc/sway/config ~/.config/sway/config

config文件內容 ~/.config/sway/config

# Default config for sway
#
# Copy this to ~/.config/sway/config and edit it to your liking.
#
# Read `man 5 sway` for a complete reference.output eDP-1 scale 1.25 # output HDMI-A-1 scale 1### Variables
#
# Logo key. Use Mod1 for Alt.
set $mod Mod4
# Home row direction keys, like vim
set $left h
set $down j
set $up k
set $right l
# Your preferred terminal emulator
set $term foot
# Your preferred application launcher
#set $menu wmenu-run
set $menu wofi --show### Output configuration
#
# Default wallpaper (more resolutions are available in /usr/share/backgrounds/sway/)
#output * bg /usr/share/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
output * bg /usr/share/wallpapers/Nexus/contents/images_dark/5120x2880.png fill
#
# Example configuration:
#
#   output HDMI-A-1 resolution 1920x1080 position 1920,0
#
# 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:
#
#   input type:touchpad {
#       dwt enabled
#       tap enabled
#       natural_scroll enabled
#       middle_emulation enabled
#   }
#
#   input type:keyboard {
#       xkb_layout "eu"
#   }
#
input * {xkb_layout us
}# You can also configure each device individually.
# Read `man 5 sway-input` for more information about this section.### Key bindings
#
# Basics:
## Start a terminalbindsym $mod+Return exec $term# Kill focused window#bindsym $mod+Shift+q killbindsym $mod+q kill# Start your launcherbindsym $mod+d exec $menu# 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# Reload the configuration filebindsym $mod+Shift+c reload# 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'
#
# Moving around:
## Move your focus aroundbindsym $mod+$left focus leftbindsym $mod+$down focus downbindsym $mod+$up focus upbindsym $mod+$right focus right# Or use $mod+[up|down|left|right]bindsym $mod+Left focus leftbindsym $mod+Down focus downbindsym $mod+Up focus upbindsym $mod+Right focus right# Move the focused window with the same, but add Shiftbindsym $mod+Shift+$left move leftbindsym $mod+Shift+$down move downbindsym $mod+Shift+$up move upbindsym $mod+Shift+$right move right# Ditto, with arrow keysbindsym $mod+Shift+Left move leftbindsym $mod+Shift+Down move downbindsym $mod+Shift+Up move upbindsym $mod+Shift+Right move right
#
# Workspaces:
## Switch to workspacebindsym $mod+1 workspace number 1bindsym $mod+2 workspace number 2bindsym $mod+3 workspace number 3bindsym $mod+4 workspace number 4bindsym $mod+5 workspace number 5bindsym $mod+6 workspace number 6bindsym $mod+7 workspace number 7bindsym $mod+8 workspace number 8bindsym $mod+9 workspace number 9bindsym $mod+0 workspace number 10# Move focused container to workspacebindsym $mod+Shift+1 move container to workspace number 1bindsym $mod+Shift+2 move container to workspace number 2bindsym $mod+Shift+3 move container to workspace number 3bindsym $mod+Shift+4 move container to workspace number 4bindsym $mod+Shift+5 move container to workspace number 5bindsym $mod+Shift+6 move container to workspace number 6bindsym $mod+Shift+7 move container to workspace number 7bindsym $mod+Shift+8 move container to workspace number 8bindsym $mod+Shift+9 move container to workspace number 9bindsym $mod+Shift+0 move container to workspace number 10# Note: workspaces can have any name you want, not just numbers.# We just use 1-10 as the default.# 前後切換工作區(非常實用)bindsym $mod+comma workspace prevbindsym $mod+period workspace next
#
# Layout stuff:
## You can "split" the current object of your focus with# $mod+b or $mod+v, for horizontal and vertical splits# respectively.bindsym $mod+b splithbindsym $mod+v splitv# Switch the current container between different layout stylesbindsym $mod+s layout stackingbindsym $mod+w layout tabbedbindsym $mod+e layout toggle split# Make the current focus fullscreenbindsym $mod+f fullscreen# Toggle the current focus between tiling and floating modebindsym $mod+Shift+space floating toggle# Swap focus between the tiling area and the floating areabindsym $mod+space focus mode_toggle# Move focus to the parent containerbindsym $mod+a focus parent
#
# Scratchpad:
## Sway has a "scratchpad", which is a bag of holding for windows.# You can send windows there and get them back later.# Move the currently focused window to the scratchpadbindsym $mod+Shift+minus move scratchpad# Show the next scratchpad window or hide the focused scratchpad window.# If there are multiple scratchpad windows, this command cycles through them.bindsym $mod+minus scratchpad show
#
# Resizing containers:
#
mode "resize" {# left will shrink the containers width# right will grow the containers width# up will shrink the containers height# down will grow the containers heightbindsym $left resize shrink width 10pxbindsym $down resize grow height 10pxbindsym $up resize shrink height 10pxbindsym $right resize grow width 10px# Ditto, with arrow keysbindsym Left resize shrink width 10pxbindsym Down resize grow height 10pxbindsym Up resize shrink height 10pxbindsym Right resize grow width 10px# Return to default modebindsym Return mode "default"bindsym Escape mode "default"
}
bindsym $mod+r mode "resize"
#
# Utilities:
## Special keys to adjust volume via PulseAudiobindsym --locked XF86AudioMute exec pactl set-sink-mute \@DEFAULT_SINK@ togglebindsym --locked XF86AudioLowerVolume exec pactl set-sink-volume \@DEFAULT_SINK@ -5%bindsym --locked XF86AudioRaiseVolume exec pactl set-sink-volume \@DEFAULT_SINK@ +5%bindsym --locked XF86AudioMicMute exec pactl set-source-mute \@DEFAULT_SOURCE@ toggle# Special keys to control media via playerctlbindsym --locked XF86AudioPlay exec playerctl play-pausebindsym --locked XF86AudioPause exec playerctl play-pausebindsym --locked XF86AudioPrev exec playerctl previousbindsym --locked XF86AudioNext exec playerctl nextbindsym --locked XF86AudioStop exec playerctl stop# Special keys to adjust brightness via brightnessctlbindsym --locked XF86MonBrightnessDown exec brightnessctl set 5%-bindsym --locked XF86MonBrightnessUp exec brightnessctl set 5%+# Special key to take a screenshot with grimbindsym Print exec grim#
# Status Bar:
#
# Read `man 5 sway-bar` for more information about this section.
#bar {
#    position top
#
#    # 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
#
#    colors {
#        statusline #ffffff
#        background #323232
#        inactive_workspace #32323200 #32323200 #5c5c5c
#    }
#}bar {swaybar_command waybar
}# Rime / Fcitx5
set $fcitx5_env GTK_IM_MODULE=fcitx QT_IM_MODULE=fcitx XMODIFIERS=@im=fcitx SDL_IM_MODULE=fcitxexec --no-startup-id fcitx5 -d --replace# 閒置 300 秒(5分鐘)後鎖定螢幕,再過 600 秒(16分鐘總計)後讓系統進入睡眠
exec swayidle -w \timeout 120 'swaylock -f -c 000000' \timeout 300 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \timeout 900 'systemctl suspend' \before-sleep 'pgrep swaylock || swaylock -f -c 000000'# 設定 $mod + Shift + h 為休眠
# 建議搭配 swaylock 鎖定螢幕,確保資料安全
#bindsym $mod+Shift+h exec swaylock --daemonize && systemctl hibernateset $screenshot /usr/bin/grimshot
### Screenshot
bindsym {# Capture the currently active output$mod+Print       exec $screenshot --notify save output# Capture the currently active window$mod+Shift+Print   exec $screenshot --notify save active# Select and capture a custom rectangular area$mod+Ctrl+Print  exec $screenshot --notify save area
}
# 隱藏waybar
bindsym $mod+Ctrl+b exec "pkill -USR1 waybar"# 无标题栏
default_border pixel 1
default_floating_border pixel 1
hide_edge_borders both# 網絡
exec nm-applet --indicatorinclude /etc/sway/config.d/*
http://www.jsqmd.com/news/984968/

相关文章:

  • (2026|NVIDIA,图像生成,超分辨率,流匹配,矫直流,蒸馏)PiD:基于像素扩散的快速高分辨率潜在解码
  • Gemini生成word再牛逼,导出那一刻格式崩成狗,还不是像个小丑?这届AI的遮羞布,被‘AI导出鸭’一把扯下!
  • 深圳民办高中办学硬实力与口碑家长疑问解答 - 奔跑123
  • 3、【AI产品经理概述】AI产品经理与传统产品经理的区别
  • 武威市2026年黄金回收+白银回收+铂金回收+彩金回收品牌门店推荐及联系方式+地址+电话+靠谱店铺指南 - 盛世金银回收
  • 2026鄂尔多斯防水补漏哪家靠谱?正规公司排名及避坑价格指南 - 苏易修缮
  • [LC优选算法#2] 滑动窗口 | 长度最小的子数组 | 无重复字符的最长子串 | 最大连续1的个数
  • 从水质到景观——生态水族缸系统建设的几个关键节点 - 深度智识库
  • 项目实训个人博客:AI调用设计
  • 荆州黄金回收六大门店实测排行 - 余生黄金回收
  • N_m3u8DL-RE:跨平台流媒体下载器的技术深度解析
  • 昭通市2026年黄金回收+白银回收+铂金回收+彩金回收品牌门店推荐及联系方式+地址+电话+靠谱店铺指南 - 盛世金银回收
  • 对外经济贸易大学考研辅导班正规机构,全维度榜单推荐 - 推荐评测师
  • 2026 黄山厨卫屋面地下室漏水瓷砖空鼓测评:吉修匠 99.8 分五星榜首 - 吉修匠
  • 4、【AI产品经理概述】AI产品经理的核心价值
  • 郑州大学考研辅导班正规机构,全维度榜单推荐 - 推荐评测师
  • 人工智能专业术语详解(E)
  • AI工具概述
  • OpenMetadata企业级元数据治理:构建可扩展的数据血缘与质量监控体系
  • SQL/NoSQL数据库为何成为TVA的记忆系统(9)
  • 辨别专业的化妆学校——六个可以用来衡量培训机构的硬指标 - 深度智识库
  • Java IO 流文件复制全解:字符缓冲流 vs 字节缓冲流
  • 2026 三明厨卫屋面地下室漏水瓷砖空鼓测评:吉修匠 99.8 分五星榜首 - 吉修匠
  • 【JAVA毕设源码分享】基于springboot+vue的教师调停课管理系统的设计与实现(程序+文档+代码讲解+一条龙定制)
  • 盒马鲜生购物卡回收新玩法,轻松变废为宝! - 团团收购物卡回收
  • 【信息科学与工程学】【物理/化学科学和工程技术】第八篇 光学07
  • IGBT全桥逆变电路基础知识及Multisim电路仿真
  • Java程序设计(第3版)第四章——继承的调用
  • 2026年装修设计机构推荐榜:这10家方案最实用 - 速递信息
  • 西安市2026年黄金回收+白银回收+铂金回收+彩金回收品牌门店推荐及联系方式+地址+电话+靠谱店铺指南 - 盛世金银回收