Dwm/fa
dwm(کوتاه شده dynamic window manager) یک window manager پویا برای X11 از suckless.org. است. dwm فایل تک باینری هست که کد منبعش هیچوقت بیشتر از ۲۰۰۰ خط نشده است. SLOC.
dwm با ویرایش کد منبع C و کامپایل دوباره آن پیکربندی می شود. وب سایت suckless می گوید که پروژه روی کابران پیشرفته و با تجربه کامپیوتر تمرکز می کند ، و شاید به خاطر همین شخصی سازی از طریق ویرایش کد منبع "آن را کوچیک و و برتر از همه می کند" .
حالت پنجره
dwm یک مدیر پنجره پویا هست، پنجره ها را در حالت های کاشیوار، تک پنجره و حالت شناور مدیریت می کند. همه حالت ها به طور پویا کنار هم قابل استفاده هستند که باعث بهینه شدن محیط برای برنامه در حال اجرا و کار در حال انجام می شود.
تعدای ترمینال با Shift+Alt+Enter اجرا کنید و dwm پنجرهها را بین پنجره اصلی و دسته، کاشی وار میچنید. ترمینال جدید در پنجره اصلی ظاهر می شود. پنجرههای باز در سمت راست صفحه میروند و حالت پشته به خود میگیرند. Alt+Enter پنجره ها را بین حالت اصلی و پشته جا به جا میکند.
+------+----------------------------------+--------+
| tags | title | status + +------+---------------------+------------+--------+ | | | | | | | | | | | | | master | stack | | | | | | | | | | | | | +----------------------------+---------------------+
نصب
USE flag ها
USE flags for x11-wm/dwm a dynamic window manager for X11
savedconfig
|
Use this to restore your config from /etc/portage/savedconfig ${CATEGORY}/${PN}. Make sure your USE flags allow for appropriate dependencies |
xinerama
|
Add support for querying multi-monitor screen geometry through the Xinerama API |
کابران باید فعال کردن USE flag
savedconfig
را در نظر بگیرند تا در ویرایش های بعدی فایل پیکربندی شخصی سازی شده را در
/etc/portage/savedconfig/x11-wm/dwm-6.0.h
ذخیره کنند.
root #
euse --enable savedconfig
کابران با مانیتور چندگانه باید USE flag xinerama
را
فعال کنند چه Xinerama استفاده شود یا نشود.
root #
euse --enable xinerama
Emerge
Install x11-wm/dwm:
root #
emerge --ask x11-wm/dwm
پیکربندی
شروع کردن
برای شروع dwm از یک display manager یا دستور startx استفاده کنید.
آنهایی که میخواهند از مسیر startx بروند باید فایل زیر را ایجاد کنند:
exec dbus-launch --sh-syntax --exit-with-session dwm
فایل اصلی پیکربندی dwm (dwm.h فایل)
همان طور که قبلا اشاره شد فایل پیکربندی اصلی dwm فایل /etc/portage/savedconfig/x11-wm/dwm-6.0 هست که پس از هر تغییر باید دوباره کامپایل شود تا نتیجه بدهد.
برای اینکه ویرایشگر به درستی برجسته سازی نحو برای کد C را نشان دهد، یک symlink با هدر فایل زبان سی (h.) ایجاد کنید.
root #
ln -s /etc/portage/savedconfig/x11-wm/dwm-6.0 /etc/portage/savedconfig/x11-wm/dwm-6.0.h
یا به اسناد ویرایشگر خودتان مراجعه کنید تا برجسته سازی نحو فارغ از پسوند فایل را تغییر دهید.
برای استفاده از پیکربندی جدید بعد از کامپیال کردن دوباره، اگر dwm در حال اجرا باشد، با (Mod+Shift+Q) از آن خارج شوید و دوباره اجرا کنید تا فایل باینری جدید در حافظه جایگزین شود.
فایل تنظیمات (dwm.rc)
فایل پیش فرض xsession که با g (/etc/X11/Sessions/dwm) Ebuild Gentoo به دست می آید یک جعبه وضعیت پیش فرض دارد که لود سیستم و تاریخ و زمان یا هر کد شل (shell script) که کاربر داخل ~/.dwm/dwmrc دارد را نمایش میدهد. مکانیسم حاضر (از dwm-6.0) برای ارسال متن به جعبه وضعیت در نوار مدیر پنجره از 'xsetroot' استفاده می کند که در xsession پیش فرض رسم شده، همانطور که در قسمت بالا اشاره شد. با چند خط کد شل، هر کسی می تواند از این مکانیسم برای ارسال متن دلخواه به نوار وضعیت ارسال کند (برای مثال، دمای CPU، آهنگ در حال پخش، تعداد ایمیل های خوانده نشده و غیره.)
ویژگیهای اضافه
dmenu یک منوی پویا برای X هست، در اصل برای dwm طراحی شده است.
نصب کردن
Emerge
نصب dmenu:
root #
emerge --ask x11-misc/dmenu
پیکربندی
گزینههای dmenu را می شود با فایل dwm.h شخصی سازی کرد، مثلا برای نشان دادن منو در پایین صفحه نمایش.
static const char *dmenucmd[] = { "dmenu_run", "-b", "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
کاربرد
Alt (aka META) + P کلیدهای متوالی منو را فعال می کند.
اطلاعات اضافی وضعیت
برای نشان دادن اطلاعات اضافی وضعیت در نوار منوی dwm، باید از x11-apps/xsetroot استفاده کنیم که اطلاعات متنی را در گوشه سمت راست - بالا قرار میدهد.
اول از همه، x11-apps/xsetroot را نصب کنید اگر هنوز نصب نشده است.
سپس از اسکریپت یا برنامه جانبی برای نشاندن اطلاعات در نوار وضعیت dwm استفاده کنید.
root #
emerge --ask x11-apps/xsetroot
Conky
For example, try Conky to display current information about the system. Prefer installing with -X
USE flag as only text information is piped through to the dwm instance. (USE flags for consideration are "-X hddtemp iostats wifi".)
root #
emerge --ask app-admin/conky
An example ~/.config/conky/conky.conf file. The configuration file is divided into two sections: conky.config
and conky.text
. The conky.config
section contains options related to Conky, while the conky.text
section defines what and how information is displayed. To use Conky on your system, you may need to adjust some settings in the conky.text
section, such as the path to network interfaces or hard drives, as those can vary depending on your system.
conky.config = {
background = no,
format_human_readable = yes,
out_to_console = yes,
temperature_unit = celsius,
total_run_times = 0,
update_interval = 1,
#use_spacer = left,
use_spacer = none,
};
conky.text = [[
M ${memperc}%/${swapperc}% | \
/sda ${diskio sda} /sdb ${diskio sdb} \
/sdc ${diskio sdc} | \
${if_existing /proc/net/route ppp0}P0 U ${upspeed ppp0} D ${downspeed ppp0} |${endif}\
${if_existing /proc/net/route eth0}E0 U ${upspeed eth0} D ${downspeed eth0} |${endif}\
${if_existing /proc/net/route wlan0}W0 U ${upspeed eth0} D ${downspeed eth0}\
${wireless_ap wlan0} ${wireless_link_qual_perc wlan0} ${endif}\
CPU ${hwmon 1 temp 1}F \
/sda ${hddtemp /dev/sda}F \
/sdb ${hddtemp /dev/sdb}F \
${time %a, %b %d %Y %H:%M (%z)}
]]
If Conky was used some time before, pay attention to new syntax with braces and equal signs.
Add a line in the ~/.xinitrc file before the dwm execution command, mentioned earlier.
conky | while read -r; do xsetroot -name "$REPLY"; done &
exec ck-launch-session dbus-launch --sh-syntax --exit-with-session dwm
Custom script
Instead of emerging side programs, create a simple loop to show date, time, weather and other system information.
For example, to show weather, date and time create a shell script file, in ~/.scripts/:
#!/bin/sh
let loop=0
while true; do
if [[ $loop%300 -eq 0 ]]; then
weather="$(curl 'https://wttr.in?format=1')"
let loop=0
fi
xsetroot -name " $weather | $(date '+%b %d %a') | $(date '+%H:%M') "
let loop=$loop+1
sleep 1
done
Since the script is already looped, we just need to set it within xroot in our ~/.xinitrc file.
. ~/.scripts/xsetloop.sh &
exec ck-launch-session dbus-launch --sh-syntax --exit-with-session dwm
Usage
Keys and key functions
All (default) dwm key bindings work with a certain MODKEY
, which is defined in dwm.h. The default MODKEY
value is Mod1Mask
, which means Alt key for PC keyboards. In the rest of this article, Mod is used to represent MODKEY
.
Moving a window manually
To move a window to another window tag manually, hold down the Mod key and left click anywhere on the window. Then, while still holding down Mod, click again on the window tag to move the window to.
Default shortcuts
Those shortcuts are used by default in x11-wm/dwm.
Window management
- Mod+2 - Display window tag number two
- Mod+Shift+1-9 - Hover mouse over window and press keys. Puts window on tag number specified.
- Mod+Shift+0 - Hover mouse over window and press keys. Puts window on all tags.
Utilities
- Mod+Shift+Enter - Launch a terminal
- Mod+Shift+C - Kills a window
- Mod+P - dmenu
- Mod+J or Mod+K - Move to another terminal.
- Mod+Enter - Toggles Windows between stack and master.
- Mod+Shift+Q - Quit dwm
Changing layout
- Mod+F - Change layout on floating.
- Mod+T - Change layout on tiled.
Volume keys
"..." means to be included in x11-wm/dwm not at the file end.
Add the following lines to the config file and re-emerge dwm:
#include <X11/XF86keysym.h>
...
/* commands */
static const char *upvol[] = { "amixer", "set", "Master", "2+", NULL };
static const char *downvol[] = { "amixer", "set", "Master", "2-", NULL };
// for muting/unmuting //
static const char *mute[] = { "amixer", "-q", "set", "Master", "toggle", NULL };
// for pulse compatible //
static const char *upvol[] = { "amixer", "-q", "sset", "Master", "1%+", NULL };
static const char *downvol[] = { "amixer", "-q", "sset", "Master", "1%-", NULL };
static const char *mute[] = { "amixer", "-q", "-D", "pulse", "sset", "Master", "toggle", NULL };
...
static Key keys[] = {
/* modifier key function argument */
{ 0, XF86XK_AudioRaiseVolume, spawn, {.v = upvol } },
{ 0, XF86XK_AudioLowerVolume, spawn, {.v = downvol } },
{ 0, XF86XK_AudioMute, spawn, {.v = mute } },
Customization
(Put user customization tricks & tips here.)
Patching
Gentoo has a specific way of patching dwm. If the patches are ready to be merged with dwm source, there is special function called eapply_user
that can be called during the emerge process. This function allows user patches to be applied to the source. Move the necessary patches one of the two locations:
- /etc/portage/patches/category/application
- An ebuild repository
Patches in /etc/portage/patches/category/application
First create the following directory:
root #
mkdir -p /etc/portage/patches/x11-wm/dwm
Copy the dwm patches to /etc/portage/patches/x11-wm/dwm/ and make sure each patch is prefixed with a number, like so: 01-name_of_patch.patch. Also the filename needs to end with .patch
or .diff
otherwise Portage will not apply it. For this example we will assume that the patch is located in the home directory (/home/larry) of the user called larry.
root #
cp /home/larry/01-dwm.6.0-xft.patch /etc/portage/patches/x11-wm/dwm/
Now just install dwm, emerge will take care of applying patches
root #
emerge --ask x11-wm/dwm
Put patches in an ebuild repository configured with Portage
Creating an ebuild repository for the dwm patches can help when wanting to share them, either on another machine, or publicly.
Copy x11-wm/dwm from /var/db/repos/gentoo/ to a new ebuild repository, or to whatever repository is appropriate.
Place patches in the files directory (for this example, the repository created to hold these files is named "dwm_patches"):
root #
cp /home/larry/01-dwm-6.0-xft.diff /var/db/repos/dwm_patches/x11-wm/dwm/files/
Open the ebuild file in a text editor, /var/db/repos/dwm_patches/x11-wm/dwm/dwm-6.1.ebuild, and list them in the PATCHES variable array for automatic patching:
PATCHES=( "${FILESDIR}/01-dwm-6.0-xft.diff"
"${FILESDIR}/02-dwm-6.1-x11.diff"
)
Fire up emerge and enjoy
root #
emerge --ask x11-wm/dwm
Assigning applications to window tags
A user can have their favorite applications start on a different window tag, such as starting MPlayer on window tag number five.
First, know the name of the application recorded by Xorg so dwm can be aware of this window on startup. To find this, start the target application (MPlayer in this example) and then further execute the xprop command (x11-apps/xprop). Click on the MPlayer window and xprop will report Xorg's data on the MPlayer window. Use the second window name identified on the WM_CLASS(STRING)
line. Now we have the name of the window dwm needs to be aware of.
Sometimes an application will have multiple windows of itself and will report one window with capital letters, while the second will have no capital letters. Wildcard characters are allowed within window names.
static const Rule rules[] ={
{ "MPlayer", NULL, NULL, 1 << 4, True, 0 },
};
Troubleshooting
Upgrading to dwm-6.0
Upgrading from dwm-5.9 to dwm-6.0 incorporated many changes making the previous config.h a likely problem for compiling dwm-6.0. Likely problems displayed might be compiler error messages "'nmaster' undeclared". To resolve, compile and install dwm-6.0 without using the custom config.h file and then find the default dwm-6.0 config.h file and diff against the old config.h file. (Or, decompress the dwm-6.0 tarball to acquire the default dwm-6.0 config.h file.)
Fix " Permission Denied"
A logind provider, like systemd or elogind, must be running in order to start a X session as non privileged user. If a logind provider is not running and the user issues startx dwm fails to start and message similar to this appears:
(EE) parse_vt_settings: Cannot open /dev/tty0 (Permission denied)
If this is the case and the system is OpenRC-based, add elogind to boot and start the service:
root #
rc-update add elogind boot
root #
/etc/init.d/elogind start
for more information, please visit Non root Xorg wiki page.
Remap mod key
If there are conflicts with the default dwm Alt conflicting with other console interface applications, use the Esc while within the console application. The Esc is an immediate usable fall back escape key. Another option, redefine the Mod key to use the keyboard Super (Windows) or other additional keys near the Space.
#define MODKEY Mod4Mask /* Use Super Key */
To assign a second Mod key allowing a user to have a Mod key on both sides of the keyboard, mimic or copy this keys activity to another key on the keyboard. The Microsoft Menu key (or context menu key) on Microsoft keyboards is directly opposite of the Super (Windows). The x11-apps/xmodmap package is required for this. (For reference, the two key's values are: showkey 125/127
and xev 133/135
respectively - on MS NEK4000 keyboard.)
# Top of $HOME/.xinitrc file is a good place for this.
# This reassigns MS NEK4000 right Menu key to simulate DWM Mod4Key as well.
xmodmap -e "keycode 135 = Super_L" # reassign MS Menu Keypress to Super_L
xmodmap -e "remove mod1 = Super_L" # make sure X keeps it out of the mod1 group
Now, a user should have a non-conflicting and easily accessible Mod key on both sides of the keyboard!
Fix Java application misbehaving
Java-based applications are known to misbehave as Java doesn't know the WM being used. This result in GUI of specific Java applications to not work properly. To solve this we need to set the window manager name property of the root window. This can be done using the wmname tool and set it to LG3D
.
Install the tool:
root #
emerge --ask x11-misc/wmname
and set the property name:
user $
wmname LG3D
To make this setting permanent add this command to ~/.xinitrc.
It is also useful to export AWT_TOOLKIT if some Java applications are using AWT, as noted below.
Blank (grey) windows of Java applications
Java-based applications, such as Apache NetBeans, does not render properly. To mitigate this problem set the AWT_TOOLKIT variable as:
user $
AWT_TOOLKIT=MToolkit; export AWT_TOOLKIT
To make the action permanent is is required to add the command to the startup script, for example ~/.xinitrc.
Background not redrawing
Sometimes the background may not properly redraw when the current view is switched. For example, some terminal emulators such as st don't draw the entirety of their allocated window space. In these cases, X root window must have a properly defined color. This can be done with the xsetroot command. For example:
user $
xsetroot -solid black