当前位置: 首页 > 工具软件 > i3WM > 使用案例 >

arcolinux使用i3wm窗口管理器

师腾
2023-12-01

arcolinux使用i3wm窗口管理器

i3wm手册

安装i3 一条命令

sudo pacman -S i3

然后在arcolinux里面自己选择窗口管理器。

arcolinux的文件管理器默认是 dolphin

Dolphin使用就是直接

Dolphin <目标目录>
# 就会自动用类似windows macos 文件管理器打开

1. i3wm配置

arcolinux 使用 ctrl+; 会调出剪贴版历史

archwiki-i3wm

1.1 安装依赖

安装edge浏览器 (使用这个浏览器是因为安装相应插件更快)

yay -S microsoft-edge-dev-bin
# i3 默认启动软件器
sudo pacman -S dmenu
# 启动器类似utool,mac alfred
sudo pacman -S rofi
# install alacritty terminal
sudo pacman -S alacritty	

sample .vimrc

在linux中修改文件是离不开vim,那么我们就需要使用一个好的配置

syntax on
set nu
set rnu
set hlsearch
set incsearch
set ignorecase
set noswapfile
set so=8
set mouse=a

let mapleader=" "
set timeoutlen=500

" I hate click this key
nnoremap H ^
nnoremap L $
vnoremap H ^
vnoremap L $
nnoremap > >>
nnoremap < <<

nnoremap Y y$
nnoremap <leader>h :nohl<cr>
nnoremap <leader>q :qa!<cr>

" use system clipboard
nnoremap <leader>Y "+Y
nnoremap <leader>P "+P
nnoremap <leader>y "+y
nnoremap <leader>p "+p

" auto change input method fcitx5
autocmd InsertLeave * :silent !fcitx5-remote -c " 退出插入模式时禁用输入法
autocmd BufCreate *  :silent !fcitx5-remote -c " 创建 Buf 时禁用输入法
autocmd BufEnter *  :silent !fcitx5-remote -c " 进入 Buf 时禁用输入法
autocmd BufLeave *  :silent !fcitx5-remote -c " 离开 Buf 时禁用输入法

1.3 配置文件

i3wm 配置在 ~/.config/i3/config

# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#

# i3 config file (v4)
#
# Please see https://i3wm.org/docs/userguide.html for a complete reference!

# mod4 is windows in linux is super
# mod1 is alt
set $mod Mod1

# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
# make this font larger
font pango:monospace 12

# 设置壁纸(根据时间自动更换)
exec_always --no-startup-id ~/feh/feh.sh

# 系统闲置333秒后灭屏,666秒后系统挂起。
exec --no-startup-id xset dpms 333 666
# 登录自动启动软件
# fcitx5输入法
exec --no-startup-id fcitx5
# 终端透明
exec --no-startup-id picom

#设置窗口边框等等
new_window none
new_float normal
hide_edge_borders both

#设置窗口间距
gaps inner 9
gaps outer 10

# This font is widely installed, provides lots of unicode glyphs, right-to-left
# text rendering and scalability on retina/hidpi displays (thanks to pango).
#font pango:DejaVu Sans Mono 8

# Start XDG autostart .desktop files using dex. See also
# https://wiki.archlinux.org/index.php/XDG_Autostart
exec --no-startup-id dex --autostart --environment i3

# The combination of xss-lock, nm-applet and pactl is a popular choice, so
# they are included here as an example. Modify as you see fit.

# xss-lock grabs a logind suspend inhibit lock and will use i3lock to lock the
# screen before suspend. Use loginctl lock-session to lock your screen.
exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock --nofork

# NetworkManager is the most popular way to manage wireless networks on Linux,
# and nm-applet is a desktop environment-independent system tray GUI for it.
exec --no-startup-id nm-applet

# Use pactl to adjust volume in PulseAudio.
set $refresh_i3status killall -SIGUSR1 i3status
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% && $refresh_i3status
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% && $refresh_i3status
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status
bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status

# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod

# start a terminal
# bindsym $mod+Return exec i3-sensible-terminal
bindsym $mod+Return exec alacritty

# kill focused window
bindsym $mod+Shift+q kill

# start dmenu (a program launcher)
bindsym $mod+d exec --no-startup-id dmenu_run
# A more modern dmenu replacement is rofi:
# bindcode $mod+40 exec "rofi -modi drun,run -show drun"
# There also is i3-dmenu-desktop which only displays applications shipping a
# .desktop file. It is a wrapper around dmenu, so you need that installed.
# bindcode $mod+40 exec --no-startup-id i3-dmenu-desktop

# change focus
bindsym $mod+h focus left
bindsym $mod+j focus down
bindsym $mod+k focus up
bindsym $mod+l focus right

# alternatively, you can use the cursor keys:
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right

# move focused window
bindsym $mod+Shift+h move left
bindsym $mod+Shift+j move down
bindsym $mod+Shift+k move up
bindsym $mod+Shift+l move right

# alternatively, you can use the cursor keys:
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right

# split in horizontal orientation (like vim vsplit)
bindsym $mod+v split h

# split in vertical orientation (like vim hsplit)
bindsym $mod+g split v

# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle

# use rofi serach exit window application
bindsym $mod+w exec rofi -show window
# use rofi as swicth windows tool
bindsym $mod+s exec "rofi -modi drun,run -show drun"
# use super+space like macos afried
bindsym Mod4+space exec "rofi -modi drun,run -show drun"

# use flameshot to screenshot
bindsym $mod+Shift+a exec "flameshot gui"


# use alt tab to switch recent workspace
bindsym $mod+Tab workspaceback_and_forth

# change container layout (stacked, tabbed, toggle split)
# 上下标签栏(推叠式)
bindsym $mod+Shift+t layout stacking
# 左右标签栏(标签式)
bindsym $mod+t layout tabbed
# 启动i3分屏
bindsym $mod+e layout toggle split

# toggle tiling / floating
bindsym $mod+Shift+f floating toggle

# change focus between tiling / floating windows
# 平铺桌面和浮动桌面进行切换 user super+space
bindsym $mod+space focus mode_toggle

# focus the parent container
bindsym $mod+a focus parent

# focus the child container
#bindsym $mod+d focus child

# Define names for default workspaces for which we configure key bindings later on.
# We use variables to avoid repeating the names in multiple places.
set $ws1 "1"
set $ws2 "2"
set $ws3 "3"
set $ws4 "4"
set $ws5 "5"
set $ws6 "6"
set $ws7 "7"
set $ws8 "8"
set $ws9 "9"
set $ws10 "10"

# switch to workspace
bindsym $mod+1 workspace number $ws1
bindsym $mod+2 workspace number $ws2
bindsym $mod+3 workspace number $ws3
bindsym $mod+4 workspace number $ws4
bindsym $mod+5 workspace number $ws5
bindsym $mod+6 workspace number $ws6
bindsym $mod+7 workspace number $ws7
bindsym $mod+8 workspace number $ws8
bindsym $mod+9 workspace number $ws9
bindsym $mod+0 workspace number $ws10

# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace number $ws1
bindsym $mod+Shift+2 move container to workspace number $ws2
bindsym $mod+Shift+3 move container to workspace number $ws3
bindsym $mod+Shift+4 move container to workspace number $ws4
bindsym $mod+Shift+5 move container to workspace number $ws5
bindsym $mod+Shift+6 move container to workspace number $ws6
bindsym $mod+Shift+7 move container to workspace number $ws7
bindsym $mod+Shift+8 move container to workspace number $ws8
bindsym $mod+Shift+9 move container to workspace number $ws9
bindsym $mod+Shift+0 move container to workspace number $ws10

# 指定在指定窗口启动
assign [class="firefox"] $ws9


# reload the configuration file
bindsym $mod+Shift+c reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r restart
# exit i3 (logs you out of your X session)
bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"

# resize window (you can also use the mouse for that)
mode "resize" {
        # These bindings trigger as soon as you enter the resize mode

        # Pressing left will shrink the window’s width.
        # Pressing right will grow the window’s width.
        # Pressing up will shrink the window’s height.
        # Pressing down will grow the window’s height.
        bindsym h resize shrink width 10 px or 10 ppt
        bindsym j resize grow height 10 px or 10 ppt
        bindsym k resize shrink height 10 px or 10 ppt
        bindsym l resize grow width 10 px or 10 ppt

        # same bindings, but for the arrow keyshhh
        bindsym Left resize shrink width 10 px or 10 ppt
        bindsym Down resize grow height 10 px or 10 ppt
        bindsym Up resize shrink height 10 px or 10 ppt
        bindsym Right resize grow width 10 px or 10 ppt

        # back to normal: Enter or Escape or $mod+r
        bindsym Return mode "default"
        bindsym Escape mode "default"
        bindsym $mod+r mode "default"
}

bindsym $mod+r mode "resize"

# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
        status_command i3status
        # set i3status on top
        position top
        # set i3status color
        colors {
        background #000000
        statusline #ffffff

        focused_workspace  #ffffff #285577
        active_workspace   #ffffff #333333
        inactive_workspace #888888 #222222
        urgent_workspace   #ffffff #900000
}
}

2. i3status

archwiki-i3status
i3status的配置在 ~/.config/i3status/config

3. rofi

rofi 是一个启动软件用来快速启动应用。

3.1 Install

sudo pacman -S rofi

4. ploybar

5. feh (i3wm 配置壁纸)

feh是个设置桌面壁纸的程序,默认的i3是没有壁纸实在是太难看了,看不下去。

  • install
sudo pacman -S feh

写一个脚本fech.sh脚本来执行自动更换壁纸

#!/bin/sh

while true; do
	find ~/feh-picture -type f \( -name '*.jpg' -o -name '*.png' \) -print0 |
		shuf -n1 -z | xargs -0 feh --bg-scale
	sleep 15m
done

上面的15m是15分钟,你也可以设置15s为15秒。
创建好之后,设置权限。

chmode +x ./feh.sh

然后在i3配置文件里加上这一句:

exec_always --no-startup-id ~/feh/feh.sh

路径就是脚本的路径

两种方法最后都使用$mod+shift+r重启i3就可以了

6. picom 终端透明渲染工具

archwiki-picom

6.1 Install

sudo pacman -S picom

6.2 配置 picom

他的默认配置位置在/etc/xdg/picom.conf,你要先用默认配置可以先:

cp ~/etc/xdg/picom.conf ~/.config/picom/picom.conf

然后在i3的配置文件里加上这么一行,配置自启动。

exec_always --no-startup-id picom 

7. 参考博客

 类似资料: