Compare commits

..

10 Commits

4 changed files with 310 additions and 18 deletions

111
DOC.md Normal file
View File

@ -0,0 +1,111 @@
## Install dependencies
```bash
sudo apt-get install -y git xorg libx11-dev libxft-dev libxinerama-dev build-essential
```
You can install another programs for your customization. This is for the example:
```bash
sudo apt install -y pulseaudio pavucontrol pulseaudio-utils # For volume script
sudo apt install -y nitrogen # For wallpaper
sudo apt install -y lxpolkit # For polkit
sudo apt install -y xcompmgr # For transparent supporting
sudo apt install -y rofi # For menu launcher
sudo apt install -y scrot # For screenshot
sudo apt install -y htop kitty thunar # For another Apps
```
## Clone from source
```bash
git clone https://git.suckless.org/dwm ~/.dwm
cd ~/.dwm
```
## Modification the `config.h`
See `config.def.h` for a default configuration.
## Compile and Install
```bash
sudo make clean install
```
## Usage
### Add DWM as a Window Manager
If you want to use it without Display Manager, you can use this method:
Add this line on `~/.xinitrc`
```bash
exec dwm
```
Then you can run it with `startx`
```bash
startx
```
### Add DWM on X Session
If you want to use a Display Manager with a semi-automatic via custom session, you can use this method:
Add this line on `~/.xsession`
```bash
exec dwm
```
### Add DWM to Display Manager
If you want to use a Display Manager with a GUI login, you can use this method:
As root, create file `/usr/share/xsessions/dwm.desktop` then type this:
```bash
[Desktop Entry]
Encoding=UTF-8
Name=DWM
Comment=Dynamic Window Manager
Exec=dwm
Icon=dwm
Type=XSession
```
## Add the autostart
### Use patch
You can use official autostart patch method. Check the complete instruction in [here](https://dwm.suckless.org/patches/autostart/). It will change your `dwm.c`.
### Add autostart in `.xprofile`
For a simple method without updating a `dwm.c`, you can use this method.
Make or edit the file `~/.xprofile` and add autostart script inside:
```bash
if [ -f ~/.dwm/autostart.sh ]; then
~/.dwm/autostart.sh &
fi
```
## Update DWM from origin
You can update your DWM version from the git repository with this command:
```bash
git checkout mybranch
git fetch origin master
git merge origin/master
git push myremote mybranch
```
## Removing DWM
Just delete the binary file if you want to removing DWM.
```bash
sudo rm /usr/local/bin/dwm
```

54
aji.c Normal file
View File

@ -0,0 +1,54 @@
void
cyclelayout(const Arg *arg) {
Layout *next;
for (next = (Layout *)layouts; next != selmon->lt[selmon->sellt]; next++);
if ((++next - layouts) >= LENGTH(layouts))
next = (Layout *)layouts;
setlayout(&(Arg) { .v = next });
}
/** Function to shift the current view to the left/right
*
* @param: "arg->i" stores the number of tags to shift right (positive value)
* or left (negative value)
*/
void
shifttag(const Arg *arg) {
if(selmon->sel){
Arg shifted;
if(arg->i > 0) // left circular shift
shifted.ui = (selmon->tagset[selmon->seltags] << arg->i)
| (selmon->tagset[selmon->seltags] >> (LENGTH(tags) - arg->i));
else // right circular shift
shifted.ui = selmon->tagset[selmon->seltags] >> (- arg->i)
| selmon->tagset[selmon->seltags] << (LENGTH(tags) + arg->i);
selmon->sel->tags = shifted.ui & TAGMASK;
arrange(selmon);
view(&shifted);
}
}
/** Function to shift the current view to the left/right
*
* @param: "arg->i" stores the number of tags to shift right (positive value)
* or left (negative value)
*/
void
shiftview(const Arg *arg) {
Arg shifted;
if(arg->i > 0) // left circular shift
shifted.ui = (selmon->tagset[selmon->seltags] << arg->i)
| (selmon->tagset[selmon->seltags] >> (LENGTH(tags) - arg->i));
else // right circular shift
shifted.ui = selmon->tagset[selmon->seltags] >> (- arg->i)
| selmon->tagset[selmon->seltags] << (LENGTH(tags) + arg->i);
view(&shifted);
}

View File

@ -45,16 +45,15 @@ static const Rule rules[] = {
};
/* layout(s) */
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
static const int nmaster = 1; /* number of clients in master area */
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
static const Layout layouts[] = {
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
static const int nmaster = 1; /* number of clients in master area */
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
static const Layout layouts[] = {
/* symbol arrange function */
{ "", tile }, /* first entry is default */
{ "", NULL }, /* no layout function means floating behavior */
{ "", monocle },
{ "[]=", tile }, /* first entry is default */
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
};
/* key definitions */
@ -87,7 +86,7 @@ static const char *roficmd[] = { "rofi",
"-columns", "2",
"-lines", "10",
"-window-thumbnail",
"-font", "\"Open Sans 18\"",
/*"-font", "'Open Sans 18'",*/
"-opacity",
"-width", "80",
"-sidebar-mode", NULL };
@ -102,22 +101,23 @@ static const char *nmtui[] = { "kitty" , "nmtui" , NULL };
static const char *nmcedit[] = { "nm-connection-editor" , NULL };
static const char *top[] = { "kitty" , "htop" , NULL };
#include "aji.c"
static const Key keys[] = {
/* modifier key function argument */
{ MODKEY, XK_Tab, view, {0} },
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
{ MODKEY, XK_BackSpace, view, {0} },
{ MODKEY, XK_a, view, {.ui = ~0} }, // Select all tags. Cancel it with `MODKEY + [tag key]`.
{ MODKEY|Mod1Mask, XK_p, tag, {.ui = ~0} }, // Pin current window to all tags. Cancel it with `MODKEY + Shift + [tag key]`.
{ MODKEY, XK_Left, focusmon, {.i = -1} },
{ MODKEY, XK_Right, focusmon, {.i = +1} },
{ MODKEY|ShiftMask, XK_Left, tagmon, {.i = -1} },
{ MODKEY|ShiftMask, XK_Right, tagmon, {.i = +1} },
{ MODKEY, XK_p, spawn, {.v = roficmd} },
{ MODKEY|ShiftMask, XK_p, spawn, {.v = dmenucmd} },
{ MODKEY, XK_k, spawn, {.v = termcmd} },
{ MODKEY, XK_e, spawn, {.v = filecmd} },
{ MODKEY, XK_n, spawn, {.v = nmtui} },
@ -131,9 +131,22 @@ static const Key keys[] = {
{ MODKEY, XK_Next, focusstack, {.i = +1} },
{ MODKEY, XK_Down, focusstack, {.i = -1} },
{ MODKEY, XK_Up, focusstack, {.i = +1} },
{ Mod1Mask, XK_Tab, focusstack, {.i = +1} },
{ Mod1Mask|ShiftMask, XK_Tab, focusstack, {.i = -1} },
{ MODKEY, XK_Return, zoom, {0} },
{ MODKEY|ControlMask, XK_Left, shiftview, {.i = -1} },
{ MODKEY|ControlMask, XK_Right, shiftview, {.i = +1} },
{ MODKEY|ShiftMask, XK_Tab, shiftview, {.i = -1} },
{ MODKEY, XK_Tab, shiftview, {.i = +1} },
{ MODKEY|ControlMask|ShiftMask, XK_Left, shifttag, {.i = -1} },
{ MODKEY|ControlMask|ShiftMask, XK_Right, shifttag, {.i = +1} },
{ MODKEY|Mod1Mask, XK_v, cyclelayout, {0} },
{ MODKEY, XK_w, killclient, {0} },
{ MODKEY|ShiftMask, XK_q, quit, {0} },

114
shift-tools.c Normal file
View File

@ -0,0 +1,114 @@
void
shift(unsigned int *tag, int i)
{
if (i > 0) /* left circular shift */
*tag = ((*tag << i) | (*tag >> (LENGTH(tags) - i)));
else /* right circular shift */
*tag = (*tag >> (- i) | *tag << (LENGTH(tags) + i));
}
/* send a window to the next/prev tag */
void
shifttag(const Arg *arg)
{
Arg shifted = { .ui = selmon->tagset[selmon->seltags] };
if (!selmon->clients)
return;
shift(&shifted.ui, arg->i);
tag(&shifted);
}
/* send a window to the next/prev tag that has a client, else it moves it to
* the next/prev one. */
void
shifttagclients(const Arg *arg)
{
Arg shifted = { .ui = selmon->tagset[selmon->seltags] };
Client *c;
unsigned int tagmask = 0;
for (c = selmon->clients; c; c = c->next)
tagmask = tagmask | c->tags;
do
shift(&shifted.ui, arg->i);
while (tagmask && !(shifted.ui & tagmask));
tag(&shifted);
}
/* view the next/prev tag */
void
shiftview(const Arg *arg)
{
Arg shifted = { .ui = selmon->tagset[selmon->seltags] };
shift(&shifted.ui, arg->i);
view(&shifted);
}
/* view the next/prev tag that has a client, else view the next/prev tag */
void
shiftviewclients(const Arg *arg)
{
Arg shifted = { .ui = selmon->tagset[selmon->seltags] };
Client *c;
unsigned int tagmask = 0;
for (c = selmon->clients; c; c = c->next)
tagmask = tagmask | c->tags;
do
shift(&shifted.ui, arg->i);
while (tagmask && !(shifted.ui & tagmask));
view(&shifted);
}
/* move the active window to the next/prev tag and view it's new tag */
void
shiftboth(const Arg *arg)
{
Arg shifted = { .ui = selmon->tagset[selmon->seltags] };
shift(&shifted.ui, arg->i);
tag(&shifted);
view(&shifted);
}
/* swaptags: https://dwm.suckless.org/patches/swaptags, used below */
void
swaptags(const Arg *arg)
{
Client *c;
unsigned int newtag = arg->ui & TAGMASK;
unsigned int curtag = selmon->tagset[selmon->seltags];
if (newtag == curtag || !curtag || (curtag & (curtag-1)))
return;
for (c = selmon->clients; c != NULL; c = c->next) {
if ((c->tags & newtag) || (c->tags & curtag))
c->tags ^= curtag ^ newtag;
if (!c->tags)
c->tags = newtag;
}
//uncomment to 'view' the new swaped tag
//selmon->tagset[selmon->seltags] = newtag;
focus(NULL);
arrange(selmon);
}
/* swaps "tags" (all the clients on it) with the next/prev tag */
void
shiftswaptags(const Arg *arg)
{
Arg shifted = { .ui = selmon->tagset[selmon->seltags] };
shift(&shifted.ui, arg->i);
swaptags(&shifted);
}