程序员的资源宝库

网站首页 > gitee 正文

i3wm配置记录 i3配置表

sanyeah 2024-03-29 16:14:06 gitee 18 ℃ 0 评论

在此记录一下i3wm和i3status的配置

i3wm

# 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!

set $mod Mod4

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

# 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@ +2% && $refresh_i3status
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -2% && $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

# 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+j focus left
#bindsym $mod+k focus down
#bindsym $mod+l focus up
#bindsym $mod+semicolon 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+j move left
#bindsym $mod+Shift+k move down
#bindsym $mod+Shift+l move up
#bindsym $mod+Shift+semicolon 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
#bindsym $mod+h split h

# split in vertical orientation
#bindsym $mod+v split v

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

# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split

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

# change focus between tiling / floating windows
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

# 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 j resize shrink width 1 px or 1 ppt
        # bindsym k resize grow height 1 px or 1 ppt
        # bindsym l resize shrink height 1 px or 1 ppt
        # bindsym semicolon resize grow width 1 px or 1 ppt

        # same bindings, but for the arrow keys
		# shift + 方向键 进行像素级微调
		# 单方向键进行百分比调整
        bindsym Left resize shrink width 1 px or 1 ppt
        bindsym Down resize grow height 1 px or 1 ppt
        bindsym Up resize shrink height 1 px or 1 ppt
        bindsym Right resize grow width 1 px or 1 ppt
		bindsym Shift+Left resize shrink width 1 px
        bindsym Shift+Down resize grow height 1 px
        bindsym Shift+Up resize shrink height 1 px
        bindsym Shift+Right resize grow width 1 px

        # 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 {
		id bar-1
		tray_output primary
		workspace_buttons yes
		status_command i3status
		
		# 通过右键工作区栏来截图
   	 	# bindsym --release button3 exec --no-startup-id import /tmp/latest-screenshot.png
		# 通过右键工具栏切换随机壁纸
		bindsym --release button3 exec --no-startup-id feh --randomize --no-fehbg --bg-fill /home/zzt/图片/壁纸/
        #position top
        #status_command i3blocks
        #status_command /home/zzt/i3/contrib/net-speed.sh
        #mode hide
        #hidden_state hide
}

# user add list

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

#设置窗口间距
gaps inner 0
gaps outer 0

bindsym $mod+Return exec konsole
# bindsym $mod+p exec --no-startup-id firefox
bindsym $mod+o exec --no-startup-id dolphin
bindsym $mod+m exec --no-startup-id electron-netease-cloud-music
bindsym $mod+t exec --no-startup-id xsensors

# exec_always --no-startup-id remmina
exec_always --no-startup-id "/home/zzt/bin/yakuake_start.sh"
exec_always --no-startup-id feh --randomize --no-fehbg --bg-fill /home/zzt/图片/壁纸/
#登录时启动fcitx5
exec_always --no-startup-id fcitx5
#支持透明
exec_always --no-startup-id picom

#程序目录
bindsym $mod+d exec "rofi -modi drun,run,window -show-icons true -show drun run window -theme my-config"

#设置背光亮度
#bindsym XF86MonBrightnessUp exec "xbacklight -inc 5; notify-send 'brightness up 5%'"
#bindsym XF86MonBrightnessDown exec "xbacklight -dec 5; notify-send 'brightness down 5%'"
bindsym XF86MonBrightnessUp exec "/home/zzt/bin/brightness.sh up && $refresh_i3status"
bindsym XF86MonBrightnessDown exec "/home/zzt/bin/brightness.sh down && $refresh_i3status"

#自动布局
exec_always --no-startup-id "autotiling -w 1 2 3 4 5 6 7 8 9"

#方案二  经测试后面的值为6550+- 刚好每次加减音量10%,如果有强迫证建议修改
#bindsym XF86AudioRaiseVolume exec amixer set Master playback 5000+
#bindsym XF86AudioLowerVolume exec amixer set Master playback 5000-
#bindsym XF86AudioMute exec amixer set Master toglde

#设置应用程序所属默认位置
## 终端
assign [class="URxvt"] $ws1
assign [class="konsole"] $ws1
assign [class="Terminator"] $ws1
assign [class="XTerm"] $ws1
assign [class="Alacritty"] $ws1

## vscode
assign [class="Code"] $ws2
###assign [class="Notepadqq"] $ws2

## 浏览器界面
assign [class="firefox"] $ws3
assign [class="Chromium"] $ws3
assign [class="Microsoft-edge-dev"] $ws3

## 思源笔记
assign [class="SiYuan"] $ws4

## freeplane思维导图
assign [class="org-knopflerfish-framework-BundleThread"] $ws5

assign [class="mpv"] $ws9
assign [class="vlc"] $ws9

assign [class="qv2ray"] $ws10

# win+数字切换工作区,第二次返回之前的工作区
workspace_auto_back_and_forth yes
# 循环切换工作区
bindsym $mod+Tab workspace next
bindsym $mod+Shift+Tab workspace prev

#锁屏配置
#bindsym $mod+l exec "i3lock -i /home/zzt/图片/壁纸.png"
#使用模糊进行锁屏
bindsym $mod+l exec "i3lockr -p 1 -b 15"
#10分钟自动锁屏
#exec_always "xautolock -time 10 -locker 'i3lock -i /home/zzt/图片/壁纸.png'"
exec_always --no-startup-id "xautolock -time 10 -locker 'i3lockr -p 1 -b 15'"

#关机操作表
set $mode_system 注消(O)|休眠(L)|重启(R)|关机(S)|退出(Esc)
bindsym $mod+minus mode "$mode_system"
mode "$mode_system" {
    bindsym o exec --no-startup-id i3-msg exit
    bindsym l exec --no-startup-id i3exit suspend, mode "default"
    bindsym r exec --no-startup-id systemctl reboot
    bindsym s exec --no-startup-id systemctl poweroff
    bindsym Escape mode "default"
}

#浏览器操作表
set $mode_s Edge(E)|火狐(F)|谷歌(C)|退出(Esc)
bindsym $mod+p mode "$mode_s"
mode "$mode_s" {
	bindsym e exec --no-startup-id microsoft-edge-dev; mode "default"
    bindsym f exec --no-startup-id firefox; mode "default"
    bindsym Return exec --no-startup-id microsoft-edge-dev; mode "default"
    bindsym c exec --no-startup-id chromium; mode "default"
    # back to normal: Enter or Escape or $mod+p
    bindsym Escape mode "default"
    bindsym $mod+p mode "default"
}

#键盘锁显示
exec "/home/zzt/bin/lock_key_status.sh"
bindsym Caps_Lock exec "sleep 200e-3;/home/zzt/bin/lock_key_dunstify.sh c && $refresh_i3status"
##bindsym Num_Lock exec "home/zzt/bin/lock_key_dunstify.sh n && $refresh_i3status"

#通知
exec_always --no-startup-id dunst

#自动护眼模式
exec_always --no-startup-id "/home/zzt/bin/xflux_my.sh"

#xed编辑器快捷键
bindsym $mod+x exec xed

#系统监视器
bindsym $mod+i exec systemmonitor
bindsym $mod+u exec st glances

#网速显示
exec_always --no-startup-id "/home/zzt/bin/net_speed_zzt.sh"

#粘贴板管理器
exec_always --no-startup-id "klipper"

#使能壁纸自动切换脚本
exec "/home/zzt/bin/wallpaper.sh"

i3status

general {
	output_format = i3bar
	colors = true
	interval = 1
	color_good = "#fcf16e" #黄檗色
	color_bad = "#f05b72" #蔷薇色
	color_degraded = "#afb4db" #藤色
}

# order += "ipv6"
#order += "read_file light"
order += "read_file keyLock"
order += "read_file netSpeed"
## 显示cpu温度
order += "cpu_temperature 0"
order += "cpu_usage"
order += "memory"
## 取消显示硬盘使用情况
# order += "disk /"
# order += "disk /home"
## 无线网络信息使用默认参数 _first_ 可能无法找到无线信息,这里直接制定我的无线网络的名称,可以使用 ip addr查看,相当于ifconfig
#order += "wireless _first_"
order += "wireless wlp8s0"
order += "wireless enp9s0f1"
#order += "ethernet _first_"
#order += "load"
order += "battery all"
order += "volume master"
order += "time"

## 定制无线网络信息
wireless wlp8s0 {
	format_up = "??%ip"
	###format_up = "??%quality,%essid,%bitrate,%frequency,%ip"
	format_down = "??未连接"
}

wireless enp9s0f1 {
	format_up = "??%ip"
	format_down = "??未连接"
}

cpu_usage {
	format = "??%usage"
}

load {
	format = " load %1min "
	# max_threshold = 0.3
}

disk "/" {
	# format = " hdd %avail "
	format = " Disk:%avail "
}

ethernet _first_ {
# if you use %speed, i3status requires root privileges
	format_up = " lan: %ip %speed "
	format_down = " no lan "
}

battery all {
	#format = "%status %percentage %remaining %emptytime"
	format = "%status%percentage"
	format_down = "No battery"
	last_full_capacity = true
	integer_battery_capacity = true
	#status_chr = "?"
	status_chr = "?"
	status_bat = "??"
	# status_bat = "☉"
	# status_bat = "?"
	# status_unk = "?"
	status_unk = "?"
	status_full = "??"
	#status_full = "?"
	low_threshold = 15
	threshold_type = time
}

memory {
	format = "Mem:%used"
	#format = "Mem:%used-%percentage_used used, %percentage_free free, %percentage_shared shared"
	threshold_degraded = "1G"
	format_degraded = "MEMORY < %available"
}

## 日期改成自己喜欢的格式
time {
	# format = "%Y-%m-%d %H:%M:%S %A"
	format = "%Y/%m/%d %H:%M:%S %A"
}

#tztime berlin {
#	format = "<span foreground='#ffffff'>time:</span> %time"
#	format_time = "%H:%M %Z"
#	timezone = "Europe/Berlin"
#	hide_if_equals_localtime = true
#}

## 定制温度控制器
cpu_temperature 0 {
	format = "??%degrees°C"
	max_threshold = 85
	path = "/sys/class/thermal/thermal_zone0/temp"
}

## 音量大小
volume master {
	format = "?%volume"
	format_muted = "?静音(%volume)"
	device = "default"
	mixer = "Master"
	mixer_idx = 0
}

## 显示屏亮度
read_file light {
	#format = "%title: %content"
	format = "BL:%content"
	path = "/sys/class/backlight/intel_backlight/brightness"
	Max_characters = 10
}

## 键盘锁
read_file keyLock {
	#format = "%title: %content"
	format = "%content"
	path = "/home/zzt/.config/ram_disk/lock_key_status_file"
	Max_characters = 4
}

## 网络速度监控
read_file netSpeed {
	format = "%content"
	path = "/home/zzt/.config/ram_disk/net_info_file"
	Max_characters = 30
}

附加程序源码

用于刷新大小写和数字区锁定

lock_key_status.c

/*
 * @Description:
 * @Version: 2.0
 * @Autor: ZZT
 * @Date: 2022-02-15 19:29:07
 * @LastEditors: ZZT
 * @LastEditTime: 2022-02-15 21:23:32
 */

#include <X11/XKBlib.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        printf("you must input one arg as file want to write!\n");
        return 0;
    }
    else
    {
        Display *d = XOpenDisplay((char *)0);
        FILE *fp;
        fp = fopen(argv[1], "w");
        if (d && fp)
        {
            unsigned caplk;
            char strc[2], strn[2];
            char str[5];
            XkbGetIndicatorState(d, XkbUseCoreKbd, &caplk);
            snprintf(strc, 2, "%c", (caplk & 1) ? 'A' : 'a');
            snprintf(strn, 2, "%c", (caplk & 2) ? 'N' : 'n');
            snprintf(str, 5, "%s:%s\n", strc, strn);
            fwrite(str, sizeof(str)-1, 1, fp);
        }
        fclose(fp);
        return 0;
    }
}

lock_key_status.sh

#/bin/bash

while (( 1==1 ))
do
/home/zzt/bin/lock_key_status /home/zzt/.config/ram_disk/lock_key_status_file
sleep 200e-3
done

lock_key_dunstify.sh

#/bin/bash

if [[ $1 == "c" ]];
then
	summary=$(/home/zzt/bin/lock_key_status_nofile c);
	#echo ${summary};
	dunstify -u 0 "Caps Lock ${summary}";
	$refresh_i3status;
	exit 0;
fi

if [[ $1 == "n" ]];
then
	summary=$(/home/zzt/bin/lock_key_status_nofile n);
	#echo ${summary}
	dunstify -u 0 "Num Lock ${summary}";
	$refresh_i3status;
	exit 0;
fi

自动刷新壁纸

#/bin/bash

while (( 1==1 ))
do
        feh --bg-fill --no-fehbg --randomize /home/zzt/图片/壁纸/
        sleep 30
done

自动护眼模式

#/bin/bash

killall -9 xflux

#纬度
latitude=39.275092
#经度
longitude=117.108185

xflux -l ${latitude} -g ${longitude}

设置屏幕亮度

lightnum=$(xbacklight -get)
#echo "当前屏幕亮度"
#echo ${lightnum}
#echo ${1}
if [ "$1" = "up" ];then
	#echo "switch 1"
	if [ "${lightnum}" = "100" ];then
		exit 0;
	fi
	xbacklight -inc 5;
	lightnum=$(xbacklight -get)
	notify-send "屏幕亮度增加 ${lightnum}%" -u low --icon=dialog-information;
	#notify-send -u 0 'brightness up 5%'
elif [ "$1" = "down" ];then
	#echo "switch 2"
	if [ "${lightnum}" = "0" ];then
		exit 0;
	fi
	xbacklight -dec 5;
	lightnum=$(xbacklight -get)
	notify-send "屏幕亮度降低 ${lightnum}%" -u low --icon=dialog-information;
	#notify-send -u 0 'brightness down 5%'
fi

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表