您尚未登录。

#1 2025-03-20 14:43:23

atlas
会员
注册时间: 2025-03-13
帖子: 9

[已解决]双屏幕下dwm的分辨率调节

我的笔记本外接了一个显示器,使用的dwm窗口管理器。显示器信息如下

[*@* ~]$ xrandr
Screen 0: minimum 320 x 200, current 5040 x 1620, maximum 16384 x 16384
eDP-1 connected primary 2160x1440+0+0 (normal left inverted
right x axis y axis) 296mm x 197mm
   2160x1440     60.00*+
   1920x1440     60.00
   1856x1392     60.01
   1792x1344     60.01
   2048x1152     59.99    59.98    59.90    59.91
   1920x1200     59.88    59.95
   1920x1080     60.01    59.97    59.96    59.93
   1600x1200     60.00
   1680x1050     59.95    59.88
   1400x1050     59.98
   1600x900      59.99    59.94    59.95    59.82
   1280x1024     60.02
   1400x900      59.96    59.88
   1280x960      60.00
   1440x810      60.00    59.97
   1368x768      59.88    59.85
   1280x800      59.99    59.97    59.81    59.91
   1280x720      60.00    59.99    59.86    59.74
   1024x768      60.04    60.00
   960x720       60.00
   928x696       60.05
   896x672       60.01
   1024x576      59.95    59.96    59.90    59.82
   960x600       59.93    60.00
   960x540       59.96    59.99    59.63    59.82
   800x600       60.00    60.32    56.25
   840x525       60.01    59.88
   864x486       59.92    59.57
   700x525       59.98
   800x450       59.95    59.82
   640x512       60.02
   700x450       59.96    59.88
   640x480       60.00    59.94
   720x405       59.51    58.99
   684x384       59.88    59.85
   640x400       59.88    59.98
   640x360       59.86    59.83    59.84    59.32
   512x384       60.00
   512x288       60.00    59.92
   480x270       59.63    59.82
   400x300       60.32    56.34
   432x243       59.92    59.57
   320x240       60.05
   360x202       59.51    59.13
   320x180       59.84    59.32
DP-1 disconnected (normal left inverted right x axis y axis)
HDMI-1 disconnected (normal left inverted right x axis y axis)
HDMI-2 connected 2880x1620+2160+0 (normal left inverted right x axis y axis) 527mm x 296mm
   1920x1080     60.00*+  74.97    50.00    59.94
   1600x900      60.00
   1280x1024     75.02    60.02
   1152x864      75.00
   1280x720      60.00    50.00    59.94
   1024x768      75.03    60.00
   800x600       75.00    60.32
   720x576       50.00
   720x480       60.00    59.94
   640x480       75.00    60.00    59.94
   720x400       70.08

默认情况下笔记本屏幕的字体会很小,所以我设置了dpi,在~/.Xresources里加入如下代码

Xft.dpi: 144

但这样又会导致副屏字很大,在网上找了半天,遇到了一个解决方案, 按照37楼的想法,先将屏幕放大了 150%,然后通过 xrandr 将外接显示器缩小 1.5 倍。
也就是在~/.xinitrc里面加上如下代码

xrandr --output HDMI-2 --off &
xrandr --output eDP-1 --auto --primary --output HDMI-2 --auto --set "Broadcast RGB" "Full" -r 60.00 --scale 1.5x1.5 --right-of eDP-1 &

现在副屏字体大小正常了,打开各个软件也完全正常,但只有一点很奇怪,屏幕的壁纸变成了这种样子,而且dwm的状态栏也只在屏幕上面显示大概五分之四,后面一段信息全没了,如下图:

wechat-2025-03-20-135827-296.png


请问有什么办法解决这个问题吗?
我的~/.xinitrc文件内容如下

#!/bin/sh

export LANG=zh_CN.UTF-8
export LANGUAGE=zh_CN:en_US
export LC_CTYPE=en_US.UTF-8

prefix="/usr"
exec_prefix="${prefix}"
xrdb="xrdb"
xinitdir="/etc/X11/xinit"
xmodmap="xmodmap"

userresources="$HOME/.Xresources"
usermodmap="$HOME/.Xmodmap"
sysresources="$xinitdir/.Xresources"
sysmodmap="$xinitdir/.Xmodmap"

# merge in defaults and keymaps

if [ -f "$sysresources" ]; then
    if [ -x /usr/bin/cpp ] ; then
        "$xrdb" -merge "$sysresources"
    else
         "$xrdb" -nocpp -merge "$sysresources"
    fi
fi

if [ -f "$sysmodmap" ]; then
    "$xmodmap" "$sysmodmap"
fi

if [ -f "$userresources" ]; then
    if [ -x /usr/bin/cpp ] ; then
        "$xrdb" -merge "$userresources"
    else
        "$xrdb" -nocpp -merge "$userresources"
    fi
fi

if [ -f "$usermodmap" ]; then
    "$xmodmap" "$usermodmap"
fi

# start some nice programs

if [ -d "$xinitdir"/xinitrc.d ] ; then
	for f in "$xinitdir/xinitrc.d"/?*.sh ; do
		[ -x "$f" ] && . "$f"
	done
	unset f
fi



fcitx5 &
exec dwmblocks & 
exec xcompmgr &

xrandr --output HDMI-2 --off &
xrandr --output eDP-1 --auto --primary --output HDMI-2 --auto --set "Broadcast RGB" "Full" -r 60.00 --scale 1.5x1.5 --right-of eDP-1 &

feh --bg-fill --no-fehbg --randomize /usr/share/backgrounds/archlinux/* --no-xinerama &


exec dwm

最近编辑记录 atlas (2025-03-26 16:27:43)

离线

#2 2025-03-20 15:02:38

GalaxySnail
会员
注册时间: 2023-09-10
帖子: 9

Re: [已解决]双屏幕下dwm的分辨率调节

不建议在 X11 多屏幕分辨率上浪费时间,X11 的设计决定了它不可能得到良好解决,建议换 wayland(比如 sway)

离线

#3 2025-03-20 15:05:14

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 9,168
个人网站

Re: [已解决]双屏幕下dwm的分辨率调节

截图我没看懂。你自己调一下 --pos 吧。
另外双屏幕且 DPI 不一致的话,推荐使用 Wayland。

离线

#4 2025-03-20 15:12:50

atlas
会员
注册时间: 2025-03-13
帖子: 9

Re: [已解决]双屏幕下dwm的分辨率调节

好的谢谢两位!

离线

#5 2025-03-26 16:25:38

atlas
会员
注册时间: 2025-03-13
帖子: 9

Re: [已解决]双屏幕下dwm的分辨率调节

今天更新壁纸的时候无意间发现,打开dwm之后再运行feh的壁纸命令问题就修复了。盲猜可能是某种初始化还没结束就运行feh导致的错误。
因此处理方法是,在xrandr命令后停顿一下,比如1秒,再运行feh设置壁纸命令。

另外壁纸问题解决后,原链接里提到的屏幕先关再开的命令就不再需要了,将其删除或者注释掉,注释掉之后意外发现dwm的状态栏也没问题了。

以下是修复后的~/.xinitrc 文件,供参考。

#!/bin/sh

export LANG=zh_CN.UTF-8
export LANGUAGE=zh_CN:en_US
export LC_CTYPE=en_US.UTF-8

prefix="/usr"
exec_prefix="${prefix}"
xrdb="xrdb"
xinitdir="/etc/X11/xinit"
xmodmap="xmodmap"

userresources="$HOME/.Xresources"
usermodmap="$HOME/.Xmodmap"
sysresources="$xinitdir/.Xresources"
sysmodmap="$xinitdir/.Xmodmap"

# merge in defaults and keymaps

if [ -f "$sysresources" ]; then
    if [ -x /usr/bin/cpp ] ; then
        "$xrdb" -merge "$sysresources"
    else
         "$xrdb" -nocpp -merge "$sysresources"
    fi
fi

if [ -f "$sysmodmap" ]; then
    "$xmodmap" "$sysmodmap"
fi

if [ -f "$userresources" ]; then
    if [ -x /usr/bin/cpp ] ; then
        "$xrdb" -merge "$userresources"
    else
        "$xrdb" -nocpp -merge "$userresources"
    fi
fi

if [ -f "$usermodmap" ]; then
    "$xmodmap" "$usermodmap"
fi

# start some nice programs

if [ -d "$xinitdir"/xinitrc.d ] ; then
	for f in "$xinitdir/xinitrc.d"/?*.sh ; do
		[ -x "$f" ] && . "$f"
	done
	unset f
fi



fcitx5 &
exec dwmblocks & 
exec xcompmgr &

#xrandr --output HDMI-2 --off &
xrandr --output eDP-1 --auto --primary --output HDMI-2 --auto --set "Broadcast RGB" "Full" -r 60.00 --scale 1.5x1.5 --right-of eDP-1 &

sleep 1
feh --bg-fill --no-fehbg --randomize /usr/share/backgrounds/archlinux/* --no-xinerama &


exec dwm

最近编辑记录 atlas (2025-03-26 16:25:55)

离线

页脚