Initial Commit
This commit is contained in:
38
KleinDwm/LICENSE
Normal file
38
KleinDwm/LICENSE
Normal file
@@ -0,0 +1,38 @@
|
||||
MIT/X Consortium License
|
||||
|
||||
© 2006-2019 Anselm R Garbe <anselm@garbe.ca>
|
||||
© 2006-2009 Jukka Salmi <jukka at salmi dot ch>
|
||||
© 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
© 2007-2011 Peter Hartlich <sgkkr at hartlich dot com>
|
||||
© 2007-2009 Szabolcs Nagy <nszabolcs at gmail dot com>
|
||||
© 2007-2009 Christof Musik <christof at sendfax dot de>
|
||||
© 2007-2009 Premysl Hruby <dfenze at gmail dot com>
|
||||
© 2007-2008 Enno Gottox Boland <gottox at s01 dot de>
|
||||
© 2008 Martin Hurton <martin dot hurton at gmail dot com>
|
||||
© 2008 Neale Pickett <neale dot woozle dot org>
|
||||
© 2009 Mate Nagy <mnagy at port70 dot net>
|
||||
© 2010-2016 Hiltjo Posthuma <hiltjo@codemadness.org>
|
||||
© 2010-2012 Connor Lane Smith <cls@lubutu.com>
|
||||
© 2011 Christoph Lohmann <20h@r-36.net>
|
||||
© 2015-2016 Quentin Rameau <quinq@fifth.space>
|
||||
© 2015-2016 Eric Pruitt <eric.pruitt@gmail.com>
|
||||
© 2016-2017 Markus Teich <markus.teich@stusta.mhn.de>
|
||||
© 2020-2022 Chris Down <chris@chrisdown.name>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
48
KleinDwm/README
Normal file
48
KleinDwm/README
Normal file
@@ -0,0 +1,48 @@
|
||||
dwm - dynamic window manager
|
||||
============================
|
||||
dwm is an extremely fast, small, and dynamic window manager for X.
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
In order to build dwm you need the Xlib header files.
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
Edit config.mk to match your local setup (dwm is installed into
|
||||
the /usr/local namespace by default).
|
||||
|
||||
Afterwards enter the following command to build and install dwm (if
|
||||
necessary as root):
|
||||
|
||||
make clean install
|
||||
|
||||
|
||||
Running dwm
|
||||
-----------
|
||||
Add the following line to your .xinitrc to start dwm using startx:
|
||||
|
||||
exec dwm
|
||||
|
||||
In order to connect dwm to a specific display, make sure that
|
||||
the DISPLAY environment variable is set correctly, e.g.:
|
||||
|
||||
DISPLAY=foo.bar:1 exec dwm
|
||||
|
||||
(This will start dwm on display :1 of the host foo.bar.)
|
||||
|
||||
In order to display status info in the bar, you can do something
|
||||
like this in your .xinitrc:
|
||||
|
||||
while xsetroot -name "`date` `uptime | sed 's/.*,//'`"
|
||||
do
|
||||
sleep 1
|
||||
done &
|
||||
exec dwm
|
||||
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
The configuration of dwm is done by creating a custom config.h
|
||||
and (re)compiling the source code.
|
||||
44
KleinDwm/README.md
Normal file
44
KleinDwm/README.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# 0x73hahd's DWM
|
||||
|
||||
This repo is for DWM configuration and contains different themes to switch between them.
|
||||
|
||||
## Calm Room DWM Theme
|
||||
A DWM theme gives a feeling of calm ♡
|
||||
|
||||

|
||||
|
||||
## Color Space
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
## Tokyo DWM Theme
|
||||
A dark theme for DWM 🌃🌆
|
||||
|
||||

|
||||
|
||||
## Toy Story DWM Theme
|
||||
A dwm theme that I create reminds me of my childhood days 🙃❤
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
#### Themes Switching:
|
||||
|
||||
1. Change the current `color.h` file in `config.h`
|
||||
```c
|
||||
#include "colors/<NAME_OF_COLOR_DOT_H_FILE>"
|
||||
```
|
||||
|
||||
2. Replace `alacritty.yml` and `picom.conf` theme file with previous files
|
||||
|
||||
```
|
||||
$ mv <NAME_OF_THEME>/alacritty.yml ~/.config/alacritty/alacritty.yml
|
||||
```
|
||||
|
||||
```
|
||||
$ mv <NAME_OF_THEME>/picom.conf ~/.config/picom/picom.conf
|
||||
```
|
||||
|
||||
117
KleinDwm/misc/.bashrc
Normal file
117
KleinDwm/misc/.bashrc
Normal file
@@ -0,0 +1,117 @@
|
||||
# ~/.bashrc: executed by bash(1) for non-login shells.
|
||||
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
|
||||
# for examples
|
||||
|
||||
# If not running interactively, don't do anything
|
||||
case $- in
|
||||
*i*) ;;
|
||||
*) return;;
|
||||
esac
|
||||
|
||||
# don't put duplicate lines or lines starting with space in the history.
|
||||
# See bash(1) for more options
|
||||
HISTCONTROL=ignoreboth
|
||||
|
||||
# append to the history file, don't overwrite it
|
||||
shopt -s histappend
|
||||
|
||||
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
|
||||
HISTSIZE=1000
|
||||
HISTFILESIZE=2000
|
||||
|
||||
# check the window size after each command and, if necessary,
|
||||
# update the values of LINES and COLUMNS.
|
||||
shopt -s checkwinsize
|
||||
|
||||
# If set, the pattern "**" used in a pathname expansion context will
|
||||
# match all files and zero or more directories and subdirectories.
|
||||
#shopt -s globstar
|
||||
|
||||
# make less more friendly for non-text input files, see lesspipe(1)
|
||||
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
|
||||
|
||||
# set variable identifying the chroot you work in (used in the prompt below)
|
||||
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
|
||||
debian_chroot=$(cat /etc/debian_chroot)
|
||||
fi
|
||||
|
||||
# set a fancy prompt (non-color, unless we know we "want" color)
|
||||
case "$TERM" in
|
||||
xterm-color|*-256color) color_prompt=yes;;
|
||||
esac
|
||||
|
||||
# uncomment for a colored prompt, if the terminal has the capability; turned
|
||||
# off by default to not distract the user: the focus in a terminal window
|
||||
# should be on the output of commands, not on the prompt
|
||||
force_color_prompt=yes
|
||||
|
||||
if [ -n "$force_color_prompt" ]; then
|
||||
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
|
||||
# We have color support; assume it's compliant with Ecma-48
|
||||
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
|
||||
# a case would tend to support setf rather than setaf.)
|
||||
color_prompt=yes
|
||||
else
|
||||
color_prompt=
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$color_prompt" = yes ]; then
|
||||
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
|
||||
else
|
||||
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
|
||||
fi
|
||||
unset color_prompt force_color_prompt
|
||||
|
||||
# If this is an xterm set the title to user@host:dir
|
||||
case "$TERM" in
|
||||
xterm*|rxvt*)
|
||||
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
# enable color support of ls and also add handy aliases
|
||||
if [ -x /usr/bin/dircolors ]; then
|
||||
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
||||
alias ls='ls --color=auto'
|
||||
#alias dir='dir --color=auto'
|
||||
#alias vdir='vdir --color=auto'
|
||||
|
||||
#alias grep='grep --color=auto'
|
||||
#alias fgrep='fgrep --color=auto'
|
||||
#alias egrep='egrep --color=auto'
|
||||
fi
|
||||
|
||||
# colored GCC warnings and errors
|
||||
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
|
||||
|
||||
# some more ls aliases
|
||||
#alias ll='ls -l'
|
||||
#alias la='ls -A'
|
||||
#alias l='ls -CF'
|
||||
|
||||
# Alias definitions.
|
||||
# You may want to put all your additions into a separate file like
|
||||
# ~/.bash_aliases, instead of adding them here directly.
|
||||
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
|
||||
|
||||
if [ -f ~/.bash_aliases ]; then
|
||||
. ~/.bash_aliases
|
||||
fi
|
||||
|
||||
# enable programmable completion features (you don't need to enable
|
||||
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
|
||||
# sources /etc/bash.bashrc).
|
||||
if ! shopt -oq posix; then
|
||||
if [ -f /usr/share/bash-completion/bash_completion ]; then
|
||||
. /usr/share/bash-completion/bash_completion
|
||||
elif [ -f /etc/bash_completion ]; then
|
||||
. /etc/bash_completion
|
||||
fi
|
||||
fi
|
||||
|
||||
PATH=$PATH:$HOME/.local/bin/
|
||||
|
||||
export EDITOR=nvim
|
||||
32
KleinDwm/misc/.profile
Normal file
32
KleinDwm/misc/.profile
Normal file
@@ -0,0 +1,32 @@
|
||||
# ~/.profile: executed by the command interpreter for login shells.
|
||||
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
|
||||
# exists.
|
||||
# see /usr/share/doc/bash/examples/startup-files for examples.
|
||||
# the files are located in the bash-doc package.
|
||||
|
||||
# the default umask is set in /etc/profile; for setting the umask
|
||||
# for ssh logins, install and configure the libpam-umask package.
|
||||
#umask 022
|
||||
|
||||
# if running bash
|
||||
if [ -n "$BASH_VERSION" ]; then
|
||||
# include .bashrc if it exists
|
||||
if [ -f "$HOME/.bashrc" ]; then
|
||||
. "$HOME/.bashrc"
|
||||
fi
|
||||
fi
|
||||
|
||||
# set PATH so it includes user's private bin if it exists
|
||||
if [ -d "$HOME/bin" ] ; then
|
||||
PATH="$HOME/bin:$PATH"
|
||||
fi
|
||||
|
||||
# set PATH so it includes user's private bin if it exists
|
||||
if [ -d "$HOME/.local/bin" ] ; then
|
||||
PATH="$HOME/.local/bin:$PATH"
|
||||
fi
|
||||
|
||||
if [[ -z $DISPLAY && $(tty) == /dev/tty1 ]]
|
||||
then
|
||||
exec startx
|
||||
fi
|
||||
22
KleinDwm/misc/.xinitrc
Normal file
22
KleinDwm/misc/.xinitrc
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
# This is a shell script, read by xinit or startx during the start of the X windows system. File configures the behavior and setup of the X session.
|
||||
|
||||
# Start Picom
|
||||
picom --config ~/.config/picom/picom.conf &
|
||||
|
||||
# Start feh for bg
|
||||
feh --bg-scale ~/Pictures/backgrounds/jellyfishbg.jpg
|
||||
|
||||
# Start xrandr
|
||||
|
||||
# Start Statusbar
|
||||
|
||||
# Start First Terminal
|
||||
(sleep 1 && alacritty -e bash -c "neofetch; lsd; exec bash") &
|
||||
|
||||
# Start Custom SystemTrays
|
||||
# Start SystemTrays (Not-mine)
|
||||
pkill volumeicon; sleep 1; volumeicon &
|
||||
pkill copyq; sleep 2; copyq &
|
||||
# Start monitoring Scripts
|
||||
exec dwm
|
||||
66
KleinDwm/source/IPCClient.c
Normal file
66
KleinDwm/source/IPCClient.c
Normal file
@@ -0,0 +1,66 @@
|
||||
#include "IPCClient.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/epoll.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
IPCClient *
|
||||
ipc_client_new(int fd)
|
||||
{
|
||||
IPCClient *c = (IPCClient *)malloc(sizeof(IPCClient));
|
||||
|
||||
if (c == NULL) return NULL;
|
||||
|
||||
// Initialize struct
|
||||
memset(&c->event, 0, sizeof(struct epoll_event));
|
||||
|
||||
c->buffer_size = 0;
|
||||
c->buffer = NULL;
|
||||
c->fd = fd;
|
||||
c->event.data.fd = fd;
|
||||
c->next = NULL;
|
||||
c->prev = NULL;
|
||||
c->subscriptions = 0;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
void
|
||||
ipc_list_add_client(IPCClientList *list, IPCClient *nc)
|
||||
{
|
||||
DEBUG("Adding client with fd %d to list\n", nc->fd);
|
||||
|
||||
if (*list == NULL) {
|
||||
// List is empty, point list at first client
|
||||
*list = nc;
|
||||
} else {
|
||||
IPCClient *c;
|
||||
// Go to last client in list
|
||||
for (c = *list; c && c->next; c = c->next)
|
||||
;
|
||||
c->next = nc;
|
||||
nc->prev = c;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ipc_list_remove_client(IPCClientList *list, IPCClient *c)
|
||||
{
|
||||
IPCClient *cprev = c->prev;
|
||||
IPCClient *cnext = c->next;
|
||||
|
||||
if (cprev != NULL) cprev->next = c->next;
|
||||
if (cnext != NULL) cnext->prev = c->prev;
|
||||
if (c == *list) *list = c->next;
|
||||
}
|
||||
|
||||
IPCClient *
|
||||
ipc_list_get_client(IPCClientList list, int fd)
|
||||
{
|
||||
for (IPCClient *c = list; c; c = c->next) {
|
||||
if (c->fd == fd) return c;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
61
KleinDwm/source/IPCClient.h
Normal file
61
KleinDwm/source/IPCClient.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#ifndef IPC_CLIENT_H_
|
||||
#define IPC_CLIENT_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/epoll.h>
|
||||
|
||||
typedef struct IPCClient IPCClient;
|
||||
/**
|
||||
* This structure contains the details of an IPC Client and pointers for a
|
||||
* linked list
|
||||
*/
|
||||
struct IPCClient {
|
||||
int fd;
|
||||
int subscriptions;
|
||||
|
||||
char *buffer;
|
||||
uint32_t buffer_size;
|
||||
|
||||
struct epoll_event event;
|
||||
IPCClient *next;
|
||||
IPCClient *prev;
|
||||
};
|
||||
|
||||
typedef IPCClient *IPCClientList;
|
||||
|
||||
/**
|
||||
* Allocate memory for new IPCClient with the specified file descriptor and
|
||||
* initialize struct.
|
||||
*
|
||||
* @param fd File descriptor of IPC client
|
||||
*
|
||||
* @return Address to allocated IPCClient struct
|
||||
*/
|
||||
IPCClient *ipc_client_new(int fd);
|
||||
|
||||
/**
|
||||
* Add an IPC Client to the specified list
|
||||
*
|
||||
* @param list Address of the list to add the client to
|
||||
* @param nc Address of the IPCClient
|
||||
*/
|
||||
void ipc_list_add_client(IPCClientList *list, IPCClient *nc);
|
||||
|
||||
/**
|
||||
* Remove an IPCClient from the specified list
|
||||
*
|
||||
* @param list Address of the list to remove the client from
|
||||
* @param c Address of the IPCClient
|
||||
*/
|
||||
void ipc_list_remove_client(IPCClientList *list, IPCClient *c);
|
||||
|
||||
/**
|
||||
* Get an IPCClient from the specified IPCClient list
|
||||
*
|
||||
* @param list List to remove the client from
|
||||
* @param fd File descriptor of the IPCClient
|
||||
*/
|
||||
IPCClient *ipc_list_get_client(IPCClientList list, int fd);
|
||||
|
||||
#endif // IPC_CLIENT_H_
|
||||
55
KleinDwm/source/Makefile
Normal file
55
KleinDwm/source/Makefile
Normal file
@@ -0,0 +1,55 @@
|
||||
# dwm - dynamic window manager
|
||||
# See LICENSE file for copyright and license details.
|
||||
|
||||
include config.mk
|
||||
|
||||
SRC = drw.c dwm.c util.c
|
||||
OBJ = ${SRC:.c=.o}
|
||||
|
||||
all: options dwm dwm-msg
|
||||
|
||||
options:
|
||||
@echo dwm build options:
|
||||
@echo "CFLAGS = ${CFLAGS}"
|
||||
@echo "LDFLAGS = ${LDFLAGS}"
|
||||
@echo "CC = ${CC}"
|
||||
|
||||
.c.o:
|
||||
${CC} -c ${CFLAGS} $<
|
||||
|
||||
${OBJ}: config.h config.mk
|
||||
|
||||
config.h:
|
||||
cp config.def.h $@
|
||||
|
||||
dwm: ${OBJ}
|
||||
${CC} -o $@ ${OBJ} ${LDFLAGS}
|
||||
|
||||
dwm-msg: dwm-msg.o
|
||||
${CC} -o $@ $< ${LDFLAGS}
|
||||
|
||||
clean:
|
||||
rm -f dwm dwm-msg ${OBJ} dwm-${VERSION}.tar.gz
|
||||
|
||||
dist: clean
|
||||
mkdir -p dwm-${VERSION}
|
||||
cp -R LICENSE Makefile README config.def.h config.mk\
|
||||
dwm.1 drw.h util.h ${SRC} dwm.png transient.c dwm-${VERSION}
|
||||
tar -cf dwm-${VERSION}.tar dwm-${VERSION}
|
||||
gzip dwm-${VERSION}.tar
|
||||
rm -rf dwm-${VERSION}
|
||||
|
||||
install: all
|
||||
mkdir -p ${DESTDIR}${PREFIX}/bin
|
||||
cp -f dwm dwm-msg ${DESTDIR}${PREFIX}/bin
|
||||
chmod 755 ${DESTDIR}${PREFIX}/bin/dwm
|
||||
chmod 755 ${DESTDIR}${PREFIX}/bin/dwm-msg
|
||||
mkdir -p ${DESTDIR}${MANPREFIX}/man1
|
||||
sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
||||
chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
||||
|
||||
uninstall:
|
||||
rm -f ${DESTDIR}${PREFIX}/bin/dwm\
|
||||
${DESTDIR}${MANPREFIX}/man1/dwm.1
|
||||
|
||||
.PHONY: all options clean dist install uninstall
|
||||
34
KleinDwm/source/colors/default.h
Normal file
34
KleinDwm/source/colors/default.h
Normal file
@@ -0,0 +1,34 @@
|
||||
static const char col_gray1[] = "#ffffff";
|
||||
static const char col_gray3[] = "#ffffff";
|
||||
static const char col_gray4[] = "#ffffff";
|
||||
static const char col_gray2[] = "#ffffff";
|
||||
static const char col_cyan[] = "#ffffff";
|
||||
|
||||
static const char tag1[] = "#bf8427";
|
||||
static const char tag2[] = "#5865F2";
|
||||
static const char tag3[] = "#FF5500";
|
||||
static const char tag4[] = "#FF609A";
|
||||
static const char tag5[] = "#842291";
|
||||
static const char tag6[] = "#900C3F";
|
||||
static const char tag7[] = "#67AFA5";
|
||||
static const char tag8[] = "#1DB954";
|
||||
static const char tag9[] = "#FFFFFF";
|
||||
|
||||
static const char *colors[][3] = {
|
||||
/* fg bg border */
|
||||
[SchemeNorm] = { col_gray3, col_gray1, col_cyan },
|
||||
[SchemeSel] = { col_gray4, col_cyan, col_gray2 },
|
||||
[SchemeTitle] = { col_gray4, col_cyan, col_cyan },
|
||||
};
|
||||
|
||||
static const char *tagsel[][2] = {
|
||||
{ tag1, col_gray1 },
|
||||
{ tag2, col_gray1 },
|
||||
{ tag3, col_gray1 },
|
||||
{ tag4, col_gray1 },
|
||||
{ tag5, col_gray1 },
|
||||
{ tag6, col_gray1 },
|
||||
{ tag7, col_gray1 },
|
||||
{ tag8, col_gray1 },
|
||||
{ tag9, col_gray1 },
|
||||
};
|
||||
34
KleinDwm/source/colors/space.h
Normal file
34
KleinDwm/source/colors/space.h
Normal file
@@ -0,0 +1,34 @@
|
||||
static const char col_gray1[] = "#0f161e";
|
||||
static const char col_gray3[] = "#fff7d0";
|
||||
static const char col_gray4[] = "#FF609A";
|
||||
static const char col_gray2[] = "#282A2E";
|
||||
static const char col_cyan[] = "#0f161e";
|
||||
|
||||
static const char tag1[] = "#bf8427";
|
||||
static const char tag2[] = "#5865F2";
|
||||
static const char tag3[] = "#FF5500";
|
||||
static const char tag4[] = "#FF609A";
|
||||
static const char tag5[] = "#842291";
|
||||
static const char tag6[] = "#900C3F";
|
||||
static const char tag7[] = "#67AFA5";
|
||||
static const char tag8[] = "#1DB954";
|
||||
static const char tag9[] = "#FFFFFF";
|
||||
|
||||
static const char *colors[][3] = {
|
||||
/* fg bg border */
|
||||
[SchemeNorm] = { col_gray3, col_gray1, col_cyan },
|
||||
[SchemeSel] = { col_gray4, col_cyan, col_gray2 },
|
||||
[SchemeTitle] = { col_gray4, col_cyan, col_cyan },
|
||||
};
|
||||
|
||||
static const char *tagsel[][2] = {
|
||||
{ tag1, col_gray1 },
|
||||
{ tag2, col_gray1 },
|
||||
{ tag3, col_gray1 },
|
||||
{ tag4, col_gray1 },
|
||||
{ tag5, col_gray1 },
|
||||
{ tag6, col_gray1 },
|
||||
{ tag7, col_gray1 },
|
||||
{ tag8, col_gray1 },
|
||||
{ tag9, col_gray1 },
|
||||
};
|
||||
62
KleinDwm/source/config.def.h
Normal file
62
KleinDwm/source/config.def.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
#include "colors/space.h"
|
||||
#include "keys.h"
|
||||
|
||||
#define TERMINAL "alacritty" // default terminal appearance */
|
||||
#define ICONSIZE 20 /* icon size */
|
||||
#define ICONSPACING 5 /* space between icon and title */
|
||||
static const unsigned int borderpx = 2; /* border pixel of windows */
|
||||
static const unsigned int gappx = 10; /* gaps between windows */
|
||||
static const unsigned int snap = 32; /* snap pixel */
|
||||
static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */
|
||||
static const unsigned int systrayonleft = 0; /* 0: systray in the right corner, >0: systray on left of status text */
|
||||
static const unsigned int systrayspacing = 2; /* systray spacing */
|
||||
static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor*/
|
||||
static const int showsystray = 1; /* 0 means no systray */
|
||||
static const int showbar = 1; /* 0 means no bar */
|
||||
static const int topbar = 1; /* 0 means bottom bar */
|
||||
static const char *fonts[] = { "monospace:size=11", "DroidSansMono Nerd Font:size=11", "Noto Color Emoji:size=11", "Cairo:size=12" };
|
||||
static const int user_bh = 8; /* 2 is the default spacing around the bar's font */
|
||||
|
||||
/* tagging */
|
||||
//static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||
//static const char *tags[] = { " \u2680 ", " \u2681 ", " \u2682 ", " \u2683 ", " \u2684 ", " \u2685 ", " \u2661 ", " \u2665 ", "\u266c" }; // Dice Faces
|
||||
// tag1 tag2 tag3 tag4 tag5 tag6 tag7 tag8 tag9
|
||||
static const char *tags[] = { " \uf17c ", " \uf1d8 ", " \uf0ac ", " \uf109 ", " \uf09b ", " \uf02d ", " \uf044 ", " \uf1bc ", " \uf120 " };
|
||||
|
||||
static const Rule rules[] = {
|
||||
/* xprop(1):
|
||||
* WM_CLASS(STRING) = instance, class
|
||||
* WM_NAME(STRING) = title
|
||||
*/
|
||||
/* class instance title tags mask isfloating CenterThisWindow? monitor */
|
||||
{ "Gimp", NULL, NULL, 0, 1, 0, -1 },
|
||||
{ "Tk", NULL, NULL, 0, 1, 0, -1 },
|
||||
{ NULL, NULL, "Brightness Control", 0, 1, 0, -1 },
|
||||
{ NULL, NULL, "Screenshot Tool", 0, 1, 0, -1 },
|
||||
{ "Conky", NULL, NULL, 0, 1, 0, -1 },
|
||||
{ NULL, NULL, "Task Tray", 0, 1, 0, -1 },
|
||||
{ NULL, NULL, "YAD", 0, 1, 0, -1 },
|
||||
{ "Ssh_popup", NULL, NULL, 0, 1, 0, -1 },
|
||||
{ "Conky-Sysinfo", NULL, "Conky", 0, 1, 1, -1 },
|
||||
};
|
||||
|
||||
static const char *ipcsockpath = "/tmp/dwm.sock";
|
||||
static IPCCommand ipccommands[] = {
|
||||
IPCCOMMAND( view, 1, {ARG_TYPE_UINT} ),
|
||||
IPCCOMMAND( toggleview, 1, {ARG_TYPE_UINT} ),
|
||||
IPCCOMMAND( tag, 1, {ARG_TYPE_UINT} ),
|
||||
IPCCOMMAND( toggletag, 1, {ARG_TYPE_UINT} ),
|
||||
IPCCOMMAND( tagmon, 1, {ARG_TYPE_UINT} ),
|
||||
IPCCOMMAND( focusmon, 1, {ARG_TYPE_SINT} ),
|
||||
IPCCOMMAND( focusstack, 1, {ARG_TYPE_SINT} ),
|
||||
IPCCOMMAND( zoom, 1, {ARG_TYPE_NONE} ),
|
||||
IPCCOMMAND( incnmaster, 1, {ARG_TYPE_SINT} ),
|
||||
IPCCOMMAND( killclient, 1, {ARG_TYPE_SINT} ),
|
||||
IPCCOMMAND( togglefloating, 1, {ARG_TYPE_NONE} ),
|
||||
IPCCOMMAND( setmfact, 1, {ARG_TYPE_FLOAT} ),
|
||||
IPCCOMMAND( setlayoutsafe, 1, {ARG_TYPE_PTR} ),
|
||||
IPCCOMMAND( quit, 1, {ARG_TYPE_NONE} )
|
||||
};
|
||||
|
||||
44
KleinDwm/source/config.def.h.orig
Normal file
44
KleinDwm/source/config.def.h.orig
Normal file
@@ -0,0 +1,44 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
#include "colors/space.h"
|
||||
#include "keys.h"
|
||||
|
||||
#define TERMINAL "alacritty" // default terminal appearance */
|
||||
#define ICONSIZE 20 /* icon size */
|
||||
#define ICONSPACING 5 /* space between icon and title */
|
||||
static const unsigned int borderpx = 2; /* border pixel of windows */
|
||||
static const unsigned int gappx = 10; /* gaps between windows */
|
||||
static const unsigned int snap = 32; /* snap pixel */
|
||||
static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */
|
||||
static const unsigned int systrayonleft = 0; /* 0: systray in the right corner, >0: systray on left of status text */
|
||||
static const unsigned int systrayspacing = 2; /* systray spacing */
|
||||
static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor*/
|
||||
static const int showsystray = 1; /* 0 means no systray */
|
||||
static const int showbar = 1; /* 0 means no bar */
|
||||
static const int topbar = 1; /* 0 means bottom bar */
|
||||
static const char *fonts[] = { "monospace:size=11", "DroidSansMono Nerd Font:size=11", "Noto Color Emoji:size=11", "Cairo:size=12" };
|
||||
static const int user_bh = 8; /* 2 is the default spacing around the bar's font */
|
||||
|
||||
/* tagging */
|
||||
//static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||
//static const char *tags[] = { " \u2680 ", " \u2681 ", " \u2682 ", " \u2683 ", " \u2684 ", " \u2685 ", " \u2661 ", " \u2665 ", "\u266c" }; // Dice Faces
|
||||
// tag1 tag2 tag3 tag4 tag5 tag6 tag7 tag8 tag9
|
||||
static const char *tags[] = { " \uf17c ", " \uf1d8 ", " \uf0ac ", " \uf109 ", " \uf09b ", " \uf02d ", " \uf044 ", " \uf1bc ", " \uf120 " };
|
||||
|
||||
static const Rule rules[] = {
|
||||
/* xprop(1):
|
||||
* WM_CLASS(STRING) = instance, class
|
||||
* WM_NAME(STRING) = title
|
||||
*/
|
||||
/* class instance title tags mask isfloating CenterThisWindow? monitor */
|
||||
{ "Gimp", NULL, NULL, 0, 1, 0, -1 },
|
||||
{ "Tk", NULL, NULL, 0, 1, 0, -1 },
|
||||
{ NULL, NULL, "Brightness Control", 0, 1, 0, -1 },
|
||||
{ NULL, NULL, "Screenshot Tool", 0, 1, 0, -1 },
|
||||
{ "Conky", NULL, NULL, 0, 1, 0, -1 },
|
||||
{ NULL, NULL, "Task Tray", 0, 1, 0, -1 },
|
||||
{ NULL, NULL, "YAD", 0, 1, 0, -1 },
|
||||
{ "Ssh_popup", NULL, NULL, 0, 1, 0, -1 },
|
||||
{ "Conky-Sysinfo", NULL, "Conky", 0, 1, 1, -1 },
|
||||
};
|
||||
|
||||
11
KleinDwm/source/config.def.h.rej
Normal file
11
KleinDwm/source/config.def.h.rej
Normal file
@@ -0,0 +1,11 @@
|
||||
--- config.def.h
|
||||
+++ config.def.h
|
||||
@@ -5,6 +5,8 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||
static const unsigned int snap = 32; /* snap pixel */
|
||||
static const int showbar = 1; /* 0 means no bar */
|
||||
static const int topbar = 1; /* 0 means bottom bar */
|
||||
+static const int vertpad = 10; /* vertical padding of bar */
|
||||
+static const int sidepad = 10; /* horizontal padding of bar */
|
||||
static const char *fonts[] = { "monospace:size=10" };
|
||||
static const char dmenufont[] = "monospace:size=10";
|
||||
static const char col_gray1[] = "#222222";
|
||||
64
KleinDwm/source/config.h
Normal file
64
KleinDwm/source/config.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
#include "colors/space.h"
|
||||
#include "keys.h"
|
||||
|
||||
#define TERMINAL "alacritty" // default terminal appearance */
|
||||
#define ICONSIZE 20 /* icon size */
|
||||
#define ICONSPACING 5 /* space between icon and title */
|
||||
static const unsigned int borderpx = 2; /* border pixel of windows */
|
||||
static const unsigned int gappx = 10; /* gaps between windows */
|
||||
static const unsigned int snap = 32; /* snap pixel */
|
||||
static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */
|
||||
static const unsigned int systrayonleft = 0; /* 0: systray in the right corner, >0: systray on left of status text */
|
||||
static const unsigned int systrayspacing = 2; /* systray spacing */
|
||||
static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor*/
|
||||
static const int showsystray = 1; /* 0 means no systray */
|
||||
static const int showbar = 1; /* 0 means no bar */
|
||||
static const int topbar = 1; /* 0 means bottom bar */
|
||||
static const char *fonts[] = { "monospace:size=11", "DroidSansMono Nerd Font:size=11", "Noto Color Emoji:size=11", "Cairo:size=12" };
|
||||
static const int user_bh = 8; /* 2 is the default spacing around the bar's font */
|
||||
|
||||
/* tagging */
|
||||
//static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||
//static const char *tags[] = { " \u2680 ", " \u2681 ", " \u2682 ", " \u2683 ", " \u2684 ", " \u2685 ", " \u2661 ", " \u2665 ", "\u266c" }; // Dice Faces
|
||||
// tag1 tag2 tag3 tag4 tag5 tag6 tag7 tag8 tag9
|
||||
static const char *tags[] = { " \uf17c ", " \uf1d8 ", " \uf0ac ", " \uf109 ", " \uf09b ", " \uf02d ", " \uf044 ", " \uf1bc ", " \uf120 " };
|
||||
|
||||
static const Rule rules[] = {
|
||||
/* xprop(1):
|
||||
* WM_CLASS(STRING) = instance, class
|
||||
* WM_NAME(STRING) = title
|
||||
*/
|
||||
/* class instance title tags mask isfloating CenterThisWindow? monitor */
|
||||
{ "Gimp", NULL, NULL, 0, 1, 0, -1 },
|
||||
{ "Tk", NULL, NULL, 0, 1, 0, -1 },
|
||||
{ NULL, NULL, "Brightness Control", 0, 1, 0, -1 },
|
||||
{ NULL, NULL, "Screenshot Tool", 0, 1, 0, -1 },
|
||||
{ "Conky", NULL, NULL, 0, 1, 0, -1 },
|
||||
{ NULL, NULL, "Task Tray", 0, 1, 0, -1 },
|
||||
{ NULL, NULL, "YAD", 0, 1, 0, -1 },
|
||||
{ "Ssh_popup", NULL, NULL, 0, 1, 0, -1 },
|
||||
{ "Conky-Sysinfo", NULL, "Conky", 0, 1, 1, -1 },
|
||||
{ "BrightnessControl", NULL, NULL, 0, 1, 1 -1 },
|
||||
{ "Arduino", NULL, NULL, 0, 1, 1, -1 },
|
||||
};
|
||||
|
||||
static const char *ipcsockpath = "/tmp/dwm.sock";
|
||||
static IPCCommand ipccommands[] = {
|
||||
IPCCOMMAND( view, 1, {ARG_TYPE_UINT} ),
|
||||
IPCCOMMAND( toggleview, 1, {ARG_TYPE_UINT} ),
|
||||
IPCCOMMAND( tag, 1, {ARG_TYPE_UINT} ),
|
||||
IPCCOMMAND( toggletag, 1, {ARG_TYPE_UINT} ),
|
||||
IPCCOMMAND( tagmon, 1, {ARG_TYPE_UINT} ),
|
||||
IPCCOMMAND( focusmon, 1, {ARG_TYPE_SINT} ),
|
||||
IPCCOMMAND( focusstack, 1, {ARG_TYPE_SINT} ),
|
||||
IPCCOMMAND( zoom, 1, {ARG_TYPE_NONE} ),
|
||||
IPCCOMMAND( incnmaster, 1, {ARG_TYPE_SINT} ),
|
||||
IPCCOMMAND( killclient, 1, {ARG_TYPE_SINT} ),
|
||||
IPCCOMMAND( togglefloating, 1, {ARG_TYPE_NONE} ),
|
||||
IPCCOMMAND( setmfact, 1, {ARG_TYPE_FLOAT} ),
|
||||
IPCCOMMAND( setlayoutsafe, 1, {ARG_TYPE_PTR} ),
|
||||
IPCCOMMAND( quit, 1, {ARG_TYPE_NONE} )
|
||||
};
|
||||
|
||||
42
KleinDwm/source/config.mk
Normal file
42
KleinDwm/source/config.mk
Normal file
@@ -0,0 +1,42 @@
|
||||
# dwm version
|
||||
VERSION = 6.5
|
||||
|
||||
# Customize below to fit your system
|
||||
|
||||
# paths
|
||||
PREFIX = /usr/local
|
||||
MANPREFIX = ${PREFIX}/share/man
|
||||
|
||||
X11INC = /usr/X11R6/include
|
||||
X11LIB = /usr/X11R6/lib
|
||||
|
||||
# Xinerama, comment if you don't want it
|
||||
XINERAMALIBS = -lXinerama
|
||||
XINERAMAFLAGS = -DXINERAMA
|
||||
|
||||
# freetype
|
||||
FREETYPELIBS = -lfontconfig -lXft
|
||||
FREETYPEINC = /usr/include/freetype2
|
||||
# OpenBSD (uncomment)
|
||||
#FREETYPEINC = ${X11INC}/freetype2
|
||||
#MANPREFIX = ${PREFIX}/man
|
||||
# yajl
|
||||
YAJLLIBS = -lyajl
|
||||
YAJLINC = /usr/include/yajl
|
||||
|
||||
# includes and libs
|
||||
INCS = -I${X11INC} -I${FREETYPEINC} -I${YAJLINC}
|
||||
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} ${YAJLLIBS} -lXrender -lImlib2
|
||||
|
||||
# flags
|
||||
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
|
||||
CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
|
||||
LDFLAGS = ${LIBS}
|
||||
|
||||
# Solaris
|
||||
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
|
||||
#LDFLAGS = ${LIBS}
|
||||
|
||||
# compiler and linker
|
||||
CC = cc
|
||||
39
KleinDwm/source/config.mk.orig
Normal file
39
KleinDwm/source/config.mk.orig
Normal file
@@ -0,0 +1,39 @@
|
||||
# dwm version
|
||||
VERSION = 6.4
|
||||
|
||||
# Customize below to fit your system
|
||||
|
||||
# paths
|
||||
PREFIX = /usr/local
|
||||
MANPREFIX = ${PREFIX}/share/man
|
||||
|
||||
X11INC = /usr/X11R6/include
|
||||
X11LIB = /usr/X11R6/lib
|
||||
|
||||
# Xinerama, comment if you don't want it
|
||||
XINERAMALIBS = -lXinerama
|
||||
XINERAMAFLAGS = -DXINERAMA
|
||||
|
||||
# freetype
|
||||
FREETYPELIBS = -lfontconfig -lXft
|
||||
FREETYPEINC = /usr/include/freetype2
|
||||
# OpenBSD (uncomment)
|
||||
#FREETYPEINC = ${X11INC}/freetype2
|
||||
#MANPREFIX = ${PREFIX}/man
|
||||
|
||||
# includes and libs
|
||||
INCS = -I${X11INC} -I${FREETYPEINC}
|
||||
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
|
||||
|
||||
# flags
|
||||
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
|
||||
CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
|
||||
LDFLAGS = ${LIBS}
|
||||
|
||||
# Solaris
|
||||
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
|
||||
#LDFLAGS = ${LIBS}
|
||||
|
||||
# compiler and linker
|
||||
CC = cc
|
||||
10
KleinDwm/source/config.mk.rej
Normal file
10
KleinDwm/source/config.mk.rej
Normal file
@@ -0,0 +1,10 @@
|
||||
--- config.mk
|
||||
+++ config.mk
|
||||
@@ -20,9 +20,13 @@ FREETYPEINC = /usr/include/freetype2
|
||||
# OpenBSD (uncomment)
|
||||
#FREETYPEINC = ${X11INC}/freetype2
|
||||
|
||||
# includes and libs
|
||||
|
||||
# flags
|
||||
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||
525
KleinDwm/source/drw.c
Normal file
525
KleinDwm/source/drw.c
Normal file
@@ -0,0 +1,525 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xft/Xft.h>
|
||||
#include <Imlib2.h>
|
||||
|
||||
#include "drw.h"
|
||||
#include "util.h"
|
||||
|
||||
#define UTF_INVALID 0xFFFD
|
||||
#define UTF_SIZ 4
|
||||
|
||||
static const unsigned char utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
|
||||
static const unsigned char utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
|
||||
static const long utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
|
||||
static const long utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
|
||||
|
||||
static long
|
||||
utf8decodebyte(const char c, size_t *i)
|
||||
{
|
||||
for (*i = 0; *i < (UTF_SIZ + 1); ++(*i))
|
||||
if (((unsigned char)c & utfmask[*i]) == utfbyte[*i])
|
||||
return (unsigned char)c & ~utfmask[*i];
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t
|
||||
utf8validate(long *u, size_t i)
|
||||
{
|
||||
if (!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF))
|
||||
*u = UTF_INVALID;
|
||||
for (i = 1; *u > utfmax[i]; ++i)
|
||||
;
|
||||
return i;
|
||||
}
|
||||
|
||||
static size_t
|
||||
utf8decode(const char *c, long *u, size_t clen)
|
||||
{
|
||||
size_t i, j, len, type;
|
||||
long udecoded;
|
||||
|
||||
*u = UTF_INVALID;
|
||||
if (!clen)
|
||||
return 0;
|
||||
udecoded = utf8decodebyte(c[0], &len);
|
||||
if (!BETWEEN(len, 1, UTF_SIZ))
|
||||
return 1;
|
||||
for (i = 1, j = 1; i < clen && j < len; ++i, ++j) {
|
||||
udecoded = (udecoded << 6) | utf8decodebyte(c[i], &type);
|
||||
if (type)
|
||||
return j;
|
||||
}
|
||||
if (j < len)
|
||||
return 0;
|
||||
*u = udecoded;
|
||||
utf8validate(u, len);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
Drw *
|
||||
drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h)
|
||||
{
|
||||
Drw *drw = ecalloc(1, sizeof(Drw));
|
||||
|
||||
drw->dpy = dpy;
|
||||
drw->screen = screen;
|
||||
drw->root = root;
|
||||
drw->w = w;
|
||||
drw->h = h;
|
||||
drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen));
|
||||
drw->picture = XRenderCreatePicture(dpy, drw->drawable, XRenderFindVisualFormat(dpy, DefaultVisual(dpy, screen)), 0, NULL);
|
||||
drw->gc = XCreateGC(dpy, root, 0, NULL);
|
||||
XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter);
|
||||
|
||||
return drw;
|
||||
}
|
||||
|
||||
void
|
||||
drw_resize(Drw *drw, unsigned int w, unsigned int h)
|
||||
{
|
||||
if (!drw)
|
||||
return;
|
||||
|
||||
drw->w = w;
|
||||
drw->h = h;
|
||||
if (drw->picture)
|
||||
XRenderFreePicture(drw->dpy, drw->picture);
|
||||
if (drw->drawable)
|
||||
XFreePixmap(drw->dpy, drw->drawable);
|
||||
drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen));
|
||||
drw->picture = XRenderCreatePicture(drw->dpy, drw->drawable, XRenderFindVisualFormat(drw->dpy, DefaultVisual(drw->dpy, drw->screen)), 0, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
drw_free(Drw *drw)
|
||||
{
|
||||
XRenderFreePicture(drw->dpy, drw->picture);
|
||||
XFreePixmap(drw->dpy, drw->drawable);
|
||||
XFreeGC(drw->dpy, drw->gc);
|
||||
drw_fontset_free(drw->fonts);
|
||||
free(drw);
|
||||
}
|
||||
|
||||
/* This function is an implementation detail. Library users should use
|
||||
* drw_fontset_create instead.
|
||||
*/
|
||||
static Fnt *
|
||||
xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
|
||||
{
|
||||
Fnt *font;
|
||||
XftFont *xfont = NULL;
|
||||
FcPattern *pattern = NULL;
|
||||
|
||||
if (fontname) {
|
||||
/* Using the pattern found at font->xfont->pattern does not yield the
|
||||
* same substitution results as using the pattern returned by
|
||||
* FcNameParse; using the latter results in the desired fallback
|
||||
* behaviour whereas the former just results in missing-character
|
||||
* rectangles being drawn, at least with some fonts. */
|
||||
if (!(xfont = XftFontOpenName(drw->dpy, drw->screen, fontname))) {
|
||||
fprintf(stderr, "error, cannot load font from name: '%s'\n", fontname);
|
||||
return NULL;
|
||||
}
|
||||
if (!(pattern = FcNameParse((FcChar8 *) fontname))) {
|
||||
fprintf(stderr, "error, cannot parse font name to pattern: '%s'\n", fontname);
|
||||
XftFontClose(drw->dpy, xfont);
|
||||
return NULL;
|
||||
}
|
||||
} else if (fontpattern) {
|
||||
if (!(xfont = XftFontOpenPattern(drw->dpy, fontpattern))) {
|
||||
fprintf(stderr, "error, cannot load font from pattern.\n");
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
die("no font specified.");
|
||||
}
|
||||
|
||||
font = ecalloc(1, sizeof(Fnt));
|
||||
font->xfont = xfont;
|
||||
font->pattern = pattern;
|
||||
font->h = xfont->ascent + xfont->descent;
|
||||
font->dpy = drw->dpy;
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
static void
|
||||
xfont_free(Fnt *font)
|
||||
{
|
||||
if (!font)
|
||||
return;
|
||||
if (font->pattern)
|
||||
FcPatternDestroy(font->pattern);
|
||||
XftFontClose(font->dpy, font->xfont);
|
||||
free(font);
|
||||
}
|
||||
|
||||
Fnt*
|
||||
drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount)
|
||||
{
|
||||
Fnt *cur, *ret = NULL;
|
||||
size_t i;
|
||||
|
||||
if (!drw || !fonts)
|
||||
return NULL;
|
||||
|
||||
for (i = 1; i <= fontcount; i++) {
|
||||
if ((cur = xfont_create(drw, fonts[fontcount - i], NULL))) {
|
||||
cur->next = ret;
|
||||
ret = cur;
|
||||
}
|
||||
}
|
||||
return (drw->fonts = ret);
|
||||
}
|
||||
|
||||
void
|
||||
drw_fontset_free(Fnt *font)
|
||||
{
|
||||
if (font) {
|
||||
drw_fontset_free(font->next);
|
||||
xfont_free(font);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
|
||||
{
|
||||
if (!drw || !dest || !clrname)
|
||||
return;
|
||||
|
||||
if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
|
||||
DefaultColormap(drw->dpy, drw->screen),
|
||||
clrname, dest))
|
||||
die("error, cannot allocate color '%s'", clrname);
|
||||
}
|
||||
|
||||
/* Wrapper to create color schemes. The caller has to call free(3) on the
|
||||
* returned color scheme when done using it. */
|
||||
Clr *
|
||||
drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
||||
{
|
||||
size_t i;
|
||||
Clr *ret;
|
||||
|
||||
/* need at least two colors for a scheme */
|
||||
if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(XftColor))))
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < clrcount; i++)
|
||||
drw_clr_create(drw, &ret[i], clrnames[i]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
drw_setfontset(Drw *drw, Fnt *set)
|
||||
{
|
||||
if (drw)
|
||||
drw->fonts = set;
|
||||
}
|
||||
|
||||
void
|
||||
drw_setscheme(Drw *drw, Clr *scm)
|
||||
{
|
||||
if (drw)
|
||||
drw->scheme = scm;
|
||||
}
|
||||
|
||||
Picture
|
||||
drw_picture_create_resized(Drw *drw, char *src, unsigned int srcw, unsigned int srch, unsigned int dstw, unsigned int dsth) {
|
||||
Pixmap pm;
|
||||
Picture pic;
|
||||
GC gc;
|
||||
|
||||
if (srcw <= (dstw << 1u) && srch <= (dsth << 1u)) {
|
||||
XImage img = {
|
||||
srcw, srch, 0, ZPixmap, src,
|
||||
ImageByteOrder(drw->dpy), BitmapUnit(drw->dpy), BitmapBitOrder(drw->dpy), 32,
|
||||
32, 0, 32,
|
||||
0, 0, 0
|
||||
};
|
||||
XInitImage(&img);
|
||||
|
||||
pm = XCreatePixmap(drw->dpy, drw->root, srcw, srch, 32);
|
||||
gc = XCreateGC(drw->dpy, pm, 0, NULL);
|
||||
XPutImage(drw->dpy, pm, gc, &img, 0, 0, 0, 0, srcw, srch);
|
||||
XFreeGC(drw->dpy, gc);
|
||||
|
||||
pic = XRenderCreatePicture(drw->dpy, pm, XRenderFindStandardFormat(drw->dpy, PictStandardARGB32), 0, NULL);
|
||||
XFreePixmap(drw->dpy, pm);
|
||||
|
||||
XRenderSetPictureFilter(drw->dpy, pic, FilterBilinear, NULL, 0);
|
||||
XTransform xf;
|
||||
xf.matrix[0][0] = (srcw << 16u) / dstw; xf.matrix[0][1] = 0; xf.matrix[0][2] = 0;
|
||||
xf.matrix[1][0] = 0; xf.matrix[1][1] = (srch << 16u) / dsth; xf.matrix[1][2] = 0;
|
||||
xf.matrix[2][0] = 0; xf.matrix[2][1] = 0; xf.matrix[2][2] = 65536;
|
||||
XRenderSetPictureTransform(drw->dpy, pic, &xf);
|
||||
} else {
|
||||
Imlib_Image origin = imlib_create_image_using_data(srcw, srch, (DATA32 *)src);
|
||||
if (!origin) return None;
|
||||
imlib_context_set_image(origin);
|
||||
imlib_image_set_has_alpha(1);
|
||||
Imlib_Image scaled = imlib_create_cropped_scaled_image(0, 0, srcw, srch, dstw, dsth);
|
||||
imlib_free_image_and_decache();
|
||||
if (!scaled) return None;
|
||||
imlib_context_set_image(scaled);
|
||||
imlib_image_set_has_alpha(1);
|
||||
|
||||
XImage img = {
|
||||
dstw, dsth, 0, ZPixmap, (char *)imlib_image_get_data_for_reading_only(),
|
||||
ImageByteOrder(drw->dpy), BitmapUnit(drw->dpy), BitmapBitOrder(drw->dpy), 32,
|
||||
32, 0, 32,
|
||||
0, 0, 0
|
||||
};
|
||||
XInitImage(&img);
|
||||
|
||||
pm = XCreatePixmap(drw->dpy, drw->root, dstw, dsth, 32);
|
||||
gc = XCreateGC(drw->dpy, pm, 0, NULL);
|
||||
XPutImage(drw->dpy, pm, gc, &img, 0, 0, 0, 0, dstw, dsth);
|
||||
imlib_free_image_and_decache();
|
||||
XFreeGC(drw->dpy, gc);
|
||||
|
||||
pic = XRenderCreatePicture(drw->dpy, pm, XRenderFindStandardFormat(drw->dpy, PictStandardARGB32), 0, NULL);
|
||||
XFreePixmap(drw->dpy, pm);
|
||||
}
|
||||
|
||||
return pic;
|
||||
}
|
||||
|
||||
void
|
||||
drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert)
|
||||
{
|
||||
if (!drw || !drw->scheme)
|
||||
return;
|
||||
XSetForeground(drw->dpy, drw->gc, invert ? drw->scheme[ColBg].pixel : drw->scheme[ColFg].pixel);
|
||||
if (filled)
|
||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||
else
|
||||
XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w - 1, h - 1);
|
||||
}
|
||||
|
||||
int
|
||||
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert)
|
||||
{
|
||||
int i, ty, ellipsis_x = 0;
|
||||
unsigned int tmpw, ew, ellipsis_w = 0, ellipsis_len;
|
||||
XftDraw *d = NULL;
|
||||
Fnt *usedfont, *curfont, *nextfont;
|
||||
int utf8strlen, utf8charlen, render = x || y || w || h;
|
||||
long utf8codepoint = 0;
|
||||
const char *utf8str;
|
||||
FcCharSet *fccharset;
|
||||
FcPattern *fcpattern;
|
||||
FcPattern *match;
|
||||
XftResult result;
|
||||
int charexists = 0, overflow = 0;
|
||||
/* keep track of a couple codepoints for which we have no match. */
|
||||
enum { nomatches_len = 64 };
|
||||
static struct { long codepoint[nomatches_len]; unsigned int idx; } nomatches;
|
||||
static unsigned int ellipsis_width = 0;
|
||||
|
||||
if (!drw || (render && (!drw->scheme || !w)) || !text || !drw->fonts)
|
||||
return 0;
|
||||
|
||||
if (!render) {
|
||||
w = invert ? invert : ~invert;
|
||||
} else {
|
||||
XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
|
||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||
d = XftDrawCreate(drw->dpy, drw->drawable,
|
||||
DefaultVisual(drw->dpy, drw->screen),
|
||||
DefaultColormap(drw->dpy, drw->screen));
|
||||
x += lpad;
|
||||
w -= lpad;
|
||||
}
|
||||
|
||||
usedfont = drw->fonts;
|
||||
if (!ellipsis_width && render)
|
||||
ellipsis_width = drw_fontset_getwidth(drw, "...");
|
||||
while (1) {
|
||||
ew = ellipsis_len = utf8strlen = 0;
|
||||
utf8str = text;
|
||||
nextfont = NULL;
|
||||
while (*text) {
|
||||
utf8charlen = utf8decode(text, &utf8codepoint, UTF_SIZ);
|
||||
for (curfont = drw->fonts; curfont; curfont = curfont->next) {
|
||||
charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint);
|
||||
if (charexists) {
|
||||
drw_font_getexts(curfont, text, utf8charlen, &tmpw, NULL);
|
||||
if (ew + ellipsis_width <= w) {
|
||||
/* keep track where the ellipsis still fits */
|
||||
ellipsis_x = x + ew;
|
||||
ellipsis_w = w - ew;
|
||||
ellipsis_len = utf8strlen;
|
||||
}
|
||||
|
||||
if (ew + tmpw > w) {
|
||||
overflow = 1;
|
||||
/* called from drw_fontset_getwidth_clamp():
|
||||
* it wants the width AFTER the overflow
|
||||
*/
|
||||
if (!render)
|
||||
x += tmpw;
|
||||
else
|
||||
utf8strlen = ellipsis_len;
|
||||
} else if (curfont == usedfont) {
|
||||
utf8strlen += utf8charlen;
|
||||
text += utf8charlen;
|
||||
ew += tmpw;
|
||||
} else {
|
||||
nextfont = curfont;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (overflow || !charexists || nextfont)
|
||||
break;
|
||||
else
|
||||
charexists = 0;
|
||||
}
|
||||
|
||||
if (utf8strlen) {
|
||||
if (render) {
|
||||
ty = y + (h - usedfont->h) / 2 + usedfont->xfont->ascent;
|
||||
XftDrawStringUtf8(d, &drw->scheme[invert ? ColBg : ColFg],
|
||||
usedfont->xfont, x, ty, (XftChar8 *)utf8str, utf8strlen);
|
||||
}
|
||||
x += ew;
|
||||
w -= ew;
|
||||
}
|
||||
if (render && overflow)
|
||||
drw_text(drw, ellipsis_x, y, ellipsis_w, h, 0, "...", invert);
|
||||
|
||||
if (!*text || overflow) {
|
||||
break;
|
||||
} else if (nextfont) {
|
||||
charexists = 0;
|
||||
usedfont = nextfont;
|
||||
} else {
|
||||
/* Regardless of whether or not a fallback font is found, the
|
||||
* character must be drawn. */
|
||||
charexists = 1;
|
||||
|
||||
for (i = 0; i < nomatches_len; ++i) {
|
||||
/* avoid calling XftFontMatch if we know we won't find a match */
|
||||
if (utf8codepoint == nomatches.codepoint[i])
|
||||
goto no_match;
|
||||
}
|
||||
|
||||
fccharset = FcCharSetCreate();
|
||||
FcCharSetAddChar(fccharset, utf8codepoint);
|
||||
|
||||
if (!drw->fonts->pattern) {
|
||||
/* Refer to the comment in xfont_create for more information. */
|
||||
die("the first font in the cache must be loaded from a font string.");
|
||||
}
|
||||
|
||||
fcpattern = FcPatternDuplicate(drw->fonts->pattern);
|
||||
FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset);
|
||||
FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue);
|
||||
|
||||
FcConfigSubstitute(NULL, fcpattern, FcMatchPattern);
|
||||
FcDefaultSubstitute(fcpattern);
|
||||
match = XftFontMatch(drw->dpy, drw->screen, fcpattern, &result);
|
||||
|
||||
FcCharSetDestroy(fccharset);
|
||||
FcPatternDestroy(fcpattern);
|
||||
|
||||
if (match) {
|
||||
usedfont = xfont_create(drw, NULL, match);
|
||||
if (usedfont && XftCharExists(drw->dpy, usedfont->xfont, utf8codepoint)) {
|
||||
for (curfont = drw->fonts; curfont->next; curfont = curfont->next)
|
||||
; /* NOP */
|
||||
curfont->next = usedfont;
|
||||
} else {
|
||||
xfont_free(usedfont);
|
||||
nomatches.codepoint[++nomatches.idx % nomatches_len] = utf8codepoint;
|
||||
no_match:
|
||||
usedfont = drw->fonts;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (d)
|
||||
XftDrawDestroy(d);
|
||||
|
||||
return x + (render ? w : 0);
|
||||
}
|
||||
|
||||
void
|
||||
drw_pic(Drw *drw, int x, int y, unsigned int w, unsigned int h, Picture pic)
|
||||
{
|
||||
if (!drw)
|
||||
return;
|
||||
XRenderComposite(drw->dpy, PictOpOver, pic, None, drw->picture, 0, 0, 0, 0, x, y, w, h);
|
||||
}
|
||||
|
||||
void
|
||||
drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h)
|
||||
{
|
||||
if (!drw)
|
||||
return;
|
||||
|
||||
XCopyArea(drw->dpy, drw->drawable, win, drw->gc, x, y, w, h, x, y);
|
||||
XSync(drw->dpy, False);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
drw_fontset_getwidth(Drw *drw, const char *text)
|
||||
{
|
||||
if (!drw || !drw->fonts || !text)
|
||||
return 0;
|
||||
return drw_text(drw, 0, 0, 0, 0, 0, text, 0);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n)
|
||||
{
|
||||
unsigned int tmp = 0;
|
||||
if (drw && drw->fonts && text && n)
|
||||
tmp = drw_text(drw, 0, 0, 0, 0, 0, text, n);
|
||||
return MIN(n, tmp);
|
||||
}
|
||||
|
||||
void
|
||||
drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h)
|
||||
{
|
||||
XGlyphInfo ext;
|
||||
|
||||
if (!font || !text)
|
||||
return;
|
||||
|
||||
XftTextExtentsUtf8(font->dpy, font->xfont, (XftChar8 *)text, len, &ext);
|
||||
if (w)
|
||||
*w = ext.xOff;
|
||||
if (h)
|
||||
*h = font->h;
|
||||
}
|
||||
|
||||
Cur *
|
||||
drw_cur_create(Drw *drw, int shape)
|
||||
{
|
||||
Cur *cur;
|
||||
|
||||
if (!drw || !(cur = ecalloc(1, sizeof(Cur))))
|
||||
return NULL;
|
||||
|
||||
cur->cursor = XCreateFontCursor(drw->dpy, shape);
|
||||
|
||||
return cur;
|
||||
}
|
||||
|
||||
void
|
||||
drw_cur_free(Drw *drw, Cur *cursor)
|
||||
{
|
||||
if (!cursor)
|
||||
return;
|
||||
|
||||
XFreeCursor(drw->dpy, cursor->cursor);
|
||||
free(cursor);
|
||||
}
|
||||
450
KleinDwm/source/drw.c.orig
Normal file
450
KleinDwm/source/drw.c.orig
Normal file
@@ -0,0 +1,450 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xft/Xft.h>
|
||||
|
||||
#include "drw.h"
|
||||
#include "util.h"
|
||||
|
||||
#define UTF_INVALID 0xFFFD
|
||||
#define UTF_SIZ 4
|
||||
|
||||
static const unsigned char utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
|
||||
static const unsigned char utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
|
||||
static const long utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
|
||||
static const long utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
|
||||
|
||||
static long
|
||||
utf8decodebyte(const char c, size_t *i)
|
||||
{
|
||||
for (*i = 0; *i < (UTF_SIZ + 1); ++(*i))
|
||||
if (((unsigned char)c & utfmask[*i]) == utfbyte[*i])
|
||||
return (unsigned char)c & ~utfmask[*i];
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t
|
||||
utf8validate(long *u, size_t i)
|
||||
{
|
||||
if (!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF))
|
||||
*u = UTF_INVALID;
|
||||
for (i = 1; *u > utfmax[i]; ++i)
|
||||
;
|
||||
return i;
|
||||
}
|
||||
|
||||
static size_t
|
||||
utf8decode(const char *c, long *u, size_t clen)
|
||||
{
|
||||
size_t i, j, len, type;
|
||||
long udecoded;
|
||||
|
||||
*u = UTF_INVALID;
|
||||
if (!clen)
|
||||
return 0;
|
||||
udecoded = utf8decodebyte(c[0], &len);
|
||||
if (!BETWEEN(len, 1, UTF_SIZ))
|
||||
return 1;
|
||||
for (i = 1, j = 1; i < clen && j < len; ++i, ++j) {
|
||||
udecoded = (udecoded << 6) | utf8decodebyte(c[i], &type);
|
||||
if (type)
|
||||
return j;
|
||||
}
|
||||
if (j < len)
|
||||
return 0;
|
||||
*u = udecoded;
|
||||
utf8validate(u, len);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
Drw *
|
||||
drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h)
|
||||
{
|
||||
Drw *drw = ecalloc(1, sizeof(Drw));
|
||||
|
||||
drw->dpy = dpy;
|
||||
drw->screen = screen;
|
||||
drw->root = root;
|
||||
drw->w = w;
|
||||
drw->h = h;
|
||||
drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen));
|
||||
drw->gc = XCreateGC(dpy, root, 0, NULL);
|
||||
XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter);
|
||||
|
||||
return drw;
|
||||
}
|
||||
|
||||
void
|
||||
drw_resize(Drw *drw, unsigned int w, unsigned int h)
|
||||
{
|
||||
if (!drw)
|
||||
return;
|
||||
|
||||
drw->w = w;
|
||||
drw->h = h;
|
||||
if (drw->drawable)
|
||||
XFreePixmap(drw->dpy, drw->drawable);
|
||||
drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen));
|
||||
}
|
||||
|
||||
void
|
||||
drw_free(Drw *drw)
|
||||
{
|
||||
XFreePixmap(drw->dpy, drw->drawable);
|
||||
XFreeGC(drw->dpy, drw->gc);
|
||||
drw_fontset_free(drw->fonts);
|
||||
free(drw);
|
||||
}
|
||||
|
||||
/* This function is an implementation detail. Library users should use
|
||||
* drw_fontset_create instead.
|
||||
*/
|
||||
static Fnt *
|
||||
xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
|
||||
{
|
||||
Fnt *font;
|
||||
XftFont *xfont = NULL;
|
||||
FcPattern *pattern = NULL;
|
||||
|
||||
if (fontname) {
|
||||
/* Using the pattern found at font->xfont->pattern does not yield the
|
||||
* same substitution results as using the pattern returned by
|
||||
* FcNameParse; using the latter results in the desired fallback
|
||||
* behaviour whereas the former just results in missing-character
|
||||
* rectangles being drawn, at least with some fonts. */
|
||||
if (!(xfont = XftFontOpenName(drw->dpy, drw->screen, fontname))) {
|
||||
fprintf(stderr, "error, cannot load font from name: '%s'\n", fontname);
|
||||
return NULL;
|
||||
}
|
||||
if (!(pattern = FcNameParse((FcChar8 *) fontname))) {
|
||||
fprintf(stderr, "error, cannot parse font name to pattern: '%s'\n", fontname);
|
||||
XftFontClose(drw->dpy, xfont);
|
||||
return NULL;
|
||||
}
|
||||
} else if (fontpattern) {
|
||||
if (!(xfont = XftFontOpenPattern(drw->dpy, fontpattern))) {
|
||||
fprintf(stderr, "error, cannot load font from pattern.\n");
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
die("no font specified.");
|
||||
}
|
||||
|
||||
font = ecalloc(1, sizeof(Fnt));
|
||||
font->xfont = xfont;
|
||||
font->pattern = pattern;
|
||||
font->h = xfont->ascent + xfont->descent;
|
||||
font->dpy = drw->dpy;
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
static void
|
||||
xfont_free(Fnt *font)
|
||||
{
|
||||
if (!font)
|
||||
return;
|
||||
if (font->pattern)
|
||||
FcPatternDestroy(font->pattern);
|
||||
XftFontClose(font->dpy, font->xfont);
|
||||
free(font);
|
||||
}
|
||||
|
||||
Fnt*
|
||||
drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount)
|
||||
{
|
||||
Fnt *cur, *ret = NULL;
|
||||
size_t i;
|
||||
|
||||
if (!drw || !fonts)
|
||||
return NULL;
|
||||
|
||||
for (i = 1; i <= fontcount; i++) {
|
||||
if ((cur = xfont_create(drw, fonts[fontcount - i], NULL))) {
|
||||
cur->next = ret;
|
||||
ret = cur;
|
||||
}
|
||||
}
|
||||
return (drw->fonts = ret);
|
||||
}
|
||||
|
||||
void
|
||||
drw_fontset_free(Fnt *font)
|
||||
{
|
||||
if (font) {
|
||||
drw_fontset_free(font->next);
|
||||
xfont_free(font);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
|
||||
{
|
||||
if (!drw || !dest || !clrname)
|
||||
return;
|
||||
|
||||
if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
|
||||
DefaultColormap(drw->dpy, drw->screen),
|
||||
clrname, dest))
|
||||
die("error, cannot allocate color '%s'", clrname);
|
||||
}
|
||||
|
||||
/* Wrapper to create color schemes. The caller has to call free(3) on the
|
||||
* returned color scheme when done using it. */
|
||||
Clr *
|
||||
drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
||||
{
|
||||
size_t i;
|
||||
Clr *ret;
|
||||
|
||||
/* need at least two colors for a scheme */
|
||||
if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(XftColor))))
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < clrcount; i++)
|
||||
drw_clr_create(drw, &ret[i], clrnames[i]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
drw_setfontset(Drw *drw, Fnt *set)
|
||||
{
|
||||
if (drw)
|
||||
drw->fonts = set;
|
||||
}
|
||||
|
||||
void
|
||||
drw_setscheme(Drw *drw, Clr *scm)
|
||||
{
|
||||
if (drw)
|
||||
drw->scheme = scm;
|
||||
}
|
||||
|
||||
void
|
||||
drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert)
|
||||
{
|
||||
if (!drw || !drw->scheme)
|
||||
return;
|
||||
XSetForeground(drw->dpy, drw->gc, invert ? drw->scheme[ColBg].pixel : drw->scheme[ColFg].pixel);
|
||||
if (filled)
|
||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||
else
|
||||
XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w - 1, h - 1);
|
||||
}
|
||||
|
||||
int
|
||||
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert)
|
||||
{
|
||||
int i, ty, ellipsis_x = 0;
|
||||
unsigned int tmpw, ew, ellipsis_w = 0, ellipsis_len;
|
||||
XftDraw *d = NULL;
|
||||
Fnt *usedfont, *curfont, *nextfont;
|
||||
int utf8strlen, utf8charlen, render = x || y || w || h;
|
||||
long utf8codepoint = 0;
|
||||
const char *utf8str;
|
||||
FcCharSet *fccharset;
|
||||
FcPattern *fcpattern;
|
||||
FcPattern *match;
|
||||
XftResult result;
|
||||
int charexists = 0, overflow = 0;
|
||||
/* keep track of a couple codepoints for which we have no match. */
|
||||
enum { nomatches_len = 64 };
|
||||
static struct { long codepoint[nomatches_len]; unsigned int idx; } nomatches;
|
||||
static unsigned int ellipsis_width = 0;
|
||||
|
||||
if (!drw || (render && (!drw->scheme || !w)) || !text || !drw->fonts)
|
||||
return 0;
|
||||
|
||||
if (!render) {
|
||||
w = invert ? invert : ~invert;
|
||||
} else {
|
||||
XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
|
||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||
d = XftDrawCreate(drw->dpy, drw->drawable,
|
||||
DefaultVisual(drw->dpy, drw->screen),
|
||||
DefaultColormap(drw->dpy, drw->screen));
|
||||
x += lpad;
|
||||
w -= lpad;
|
||||
}
|
||||
|
||||
usedfont = drw->fonts;
|
||||
if (!ellipsis_width && render)
|
||||
ellipsis_width = drw_fontset_getwidth(drw, "...");
|
||||
while (1) {
|
||||
ew = ellipsis_len = utf8strlen = 0;
|
||||
utf8str = text;
|
||||
nextfont = NULL;
|
||||
while (*text) {
|
||||
utf8charlen = utf8decode(text, &utf8codepoint, UTF_SIZ);
|
||||
for (curfont = drw->fonts; curfont; curfont = curfont->next) {
|
||||
charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint);
|
||||
if (charexists) {
|
||||
drw_font_getexts(curfont, text, utf8charlen, &tmpw, NULL);
|
||||
if (ew + ellipsis_width <= w) {
|
||||
/* keep track where the ellipsis still fits */
|
||||
ellipsis_x = x + ew;
|
||||
ellipsis_w = w - ew;
|
||||
ellipsis_len = utf8strlen;
|
||||
}
|
||||
|
||||
if (ew + tmpw > w) {
|
||||
overflow = 1;
|
||||
/* called from drw_fontset_getwidth_clamp():
|
||||
* it wants the width AFTER the overflow
|
||||
*/
|
||||
if (!render)
|
||||
x += tmpw;
|
||||
else
|
||||
utf8strlen = ellipsis_len;
|
||||
} else if (curfont == usedfont) {
|
||||
utf8strlen += utf8charlen;
|
||||
text += utf8charlen;
|
||||
ew += tmpw;
|
||||
} else {
|
||||
nextfont = curfont;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (overflow || !charexists || nextfont)
|
||||
break;
|
||||
else
|
||||
charexists = 0;
|
||||
}
|
||||
|
||||
if (utf8strlen) {
|
||||
if (render) {
|
||||
ty = y + (h - usedfont->h) / 2 + usedfont->xfont->ascent;
|
||||
XftDrawStringUtf8(d, &drw->scheme[invert ? ColBg : ColFg],
|
||||
usedfont->xfont, x, ty, (XftChar8 *)utf8str, utf8strlen);
|
||||
}
|
||||
x += ew;
|
||||
w -= ew;
|
||||
}
|
||||
if (render && overflow)
|
||||
drw_text(drw, ellipsis_x, y, ellipsis_w, h, 0, "...", invert);
|
||||
|
||||
if (!*text || overflow) {
|
||||
break;
|
||||
} else if (nextfont) {
|
||||
charexists = 0;
|
||||
usedfont = nextfont;
|
||||
} else {
|
||||
/* Regardless of whether or not a fallback font is found, the
|
||||
* character must be drawn. */
|
||||
charexists = 1;
|
||||
|
||||
for (i = 0; i < nomatches_len; ++i) {
|
||||
/* avoid calling XftFontMatch if we know we won't find a match */
|
||||
if (utf8codepoint == nomatches.codepoint[i])
|
||||
goto no_match;
|
||||
}
|
||||
|
||||
fccharset = FcCharSetCreate();
|
||||
FcCharSetAddChar(fccharset, utf8codepoint);
|
||||
|
||||
if (!drw->fonts->pattern) {
|
||||
/* Refer to the comment in xfont_create for more information. */
|
||||
die("the first font in the cache must be loaded from a font string.");
|
||||
}
|
||||
|
||||
fcpattern = FcPatternDuplicate(drw->fonts->pattern);
|
||||
FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset);
|
||||
FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue);
|
||||
|
||||
FcConfigSubstitute(NULL, fcpattern, FcMatchPattern);
|
||||
FcDefaultSubstitute(fcpattern);
|
||||
match = XftFontMatch(drw->dpy, drw->screen, fcpattern, &result);
|
||||
|
||||
FcCharSetDestroy(fccharset);
|
||||
FcPatternDestroy(fcpattern);
|
||||
|
||||
if (match) {
|
||||
usedfont = xfont_create(drw, NULL, match);
|
||||
if (usedfont && XftCharExists(drw->dpy, usedfont->xfont, utf8codepoint)) {
|
||||
for (curfont = drw->fonts; curfont->next; curfont = curfont->next)
|
||||
; /* NOP */
|
||||
curfont->next = usedfont;
|
||||
} else {
|
||||
xfont_free(usedfont);
|
||||
nomatches.codepoint[++nomatches.idx % nomatches_len] = utf8codepoint;
|
||||
no_match:
|
||||
usedfont = drw->fonts;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (d)
|
||||
XftDrawDestroy(d);
|
||||
|
||||
return x + (render ? w : 0);
|
||||
}
|
||||
|
||||
void
|
||||
drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h)
|
||||
{
|
||||
if (!drw)
|
||||
return;
|
||||
|
||||
XCopyArea(drw->dpy, drw->drawable, win, drw->gc, x, y, w, h, x, y);
|
||||
XSync(drw->dpy, False);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
drw_fontset_getwidth(Drw *drw, const char *text)
|
||||
{
|
||||
if (!drw || !drw->fonts || !text)
|
||||
return 0;
|
||||
return drw_text(drw, 0, 0, 0, 0, 0, text, 0);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n)
|
||||
{
|
||||
unsigned int tmp = 0;
|
||||
if (drw && drw->fonts && text && n)
|
||||
tmp = drw_text(drw, 0, 0, 0, 0, 0, text, n);
|
||||
return MIN(n, tmp);
|
||||
}
|
||||
|
||||
void
|
||||
drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h)
|
||||
{
|
||||
XGlyphInfo ext;
|
||||
|
||||
if (!font || !text)
|
||||
return;
|
||||
|
||||
XftTextExtentsUtf8(font->dpy, font->xfont, (XftChar8 *)text, len, &ext);
|
||||
if (w)
|
||||
*w = ext.xOff;
|
||||
if (h)
|
||||
*h = font->h;
|
||||
}
|
||||
|
||||
Cur *
|
||||
drw_cur_create(Drw *drw, int shape)
|
||||
{
|
||||
Cur *cur;
|
||||
|
||||
if (!drw || !(cur = ecalloc(1, sizeof(Cur))))
|
||||
return NULL;
|
||||
|
||||
cur->cursor = XCreateFontCursor(drw->dpy, shape);
|
||||
|
||||
return cur;
|
||||
}
|
||||
|
||||
void
|
||||
drw_cur_free(Drw *drw, Cur *cursor)
|
||||
{
|
||||
if (!cursor)
|
||||
return;
|
||||
|
||||
XFreeCursor(drw->dpy, cursor->cursor);
|
||||
free(cursor);
|
||||
}
|
||||
62
KleinDwm/source/drw.h
Normal file
62
KleinDwm/source/drw.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
typedef struct {
|
||||
Cursor cursor;
|
||||
} Cur;
|
||||
|
||||
typedef struct Fnt {
|
||||
Display *dpy;
|
||||
unsigned int h;
|
||||
XftFont *xfont;
|
||||
FcPattern *pattern;
|
||||
struct Fnt *next;
|
||||
} Fnt;
|
||||
|
||||
enum { ColFg, ColBg, ColBorder }; /* Clr scheme index */
|
||||
typedef XftColor Clr;
|
||||
|
||||
typedef struct {
|
||||
unsigned int w, h;
|
||||
Display *dpy;
|
||||
int screen;
|
||||
Window root;
|
||||
Drawable drawable;
|
||||
Picture picture;
|
||||
GC gc;
|
||||
Clr *scheme;
|
||||
Fnt *fonts;
|
||||
} Drw;
|
||||
|
||||
/* Drawable abstraction */
|
||||
Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
|
||||
void drw_resize(Drw *drw, unsigned int w, unsigned int h);
|
||||
void drw_free(Drw *drw);
|
||||
|
||||
/* Fnt abstraction */
|
||||
Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount);
|
||||
void drw_fontset_free(Fnt* set);
|
||||
unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
|
||||
unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n);
|
||||
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
|
||||
|
||||
/* Colorscheme abstraction */
|
||||
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
|
||||
Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
|
||||
|
||||
/* Cursor abstraction */
|
||||
Cur *drw_cur_create(Drw *drw, int shape);
|
||||
void drw_cur_free(Drw *drw, Cur *cursor);
|
||||
|
||||
/* Drawing context manipulation */
|
||||
void drw_setfontset(Drw *drw, Fnt *set);
|
||||
void drw_setscheme(Drw *drw, Clr *scm);
|
||||
|
||||
Picture drw_picture_create_resized(Drw *drw, char *src, unsigned int src_w, unsigned int src_h, unsigned int dst_w, unsigned int dst_h);
|
||||
|
||||
/* Drawing functions */
|
||||
void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert);
|
||||
int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert);
|
||||
void drw_pic(Drw *drw, int x, int y, unsigned int w, unsigned int h, Picture pic);
|
||||
|
||||
/* Map functions */
|
||||
void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);
|
||||
58
KleinDwm/source/drw.h.orig
Normal file
58
KleinDwm/source/drw.h.orig
Normal file
@@ -0,0 +1,58 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
typedef struct {
|
||||
Cursor cursor;
|
||||
} Cur;
|
||||
|
||||
typedef struct Fnt {
|
||||
Display *dpy;
|
||||
unsigned int h;
|
||||
XftFont *xfont;
|
||||
FcPattern *pattern;
|
||||
struct Fnt *next;
|
||||
} Fnt;
|
||||
|
||||
enum { ColFg, ColBg, ColBorder }; /* Clr scheme index */
|
||||
typedef XftColor Clr;
|
||||
|
||||
typedef struct {
|
||||
unsigned int w, h;
|
||||
Display *dpy;
|
||||
int screen;
|
||||
Window root;
|
||||
Drawable drawable;
|
||||
GC gc;
|
||||
Clr *scheme;
|
||||
Fnt *fonts;
|
||||
} Drw;
|
||||
|
||||
/* Drawable abstraction */
|
||||
Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
|
||||
void drw_resize(Drw *drw, unsigned int w, unsigned int h);
|
||||
void drw_free(Drw *drw);
|
||||
|
||||
/* Fnt abstraction */
|
||||
Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount);
|
||||
void drw_fontset_free(Fnt* set);
|
||||
unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
|
||||
unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n);
|
||||
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
|
||||
|
||||
/* Colorscheme abstraction */
|
||||
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
|
||||
Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
|
||||
|
||||
/* Cursor abstraction */
|
||||
Cur *drw_cur_create(Drw *drw, int shape);
|
||||
void drw_cur_free(Drw *drw, Cur *cursor);
|
||||
|
||||
/* Drawing context manipulation */
|
||||
void drw_setfontset(Drw *drw, Fnt *set);
|
||||
void drw_setscheme(Drw *drw, Clr *scm);
|
||||
|
||||
/* Drawing functions */
|
||||
void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert);
|
||||
int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert);
|
||||
|
||||
/* Map functions */
|
||||
void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);
|
||||
BIN
KleinDwm/source/drw.o
Normal file
BIN
KleinDwm/source/drw.o
Normal file
Binary file not shown.
BIN
KleinDwm/source/dwm
Executable file
BIN
KleinDwm/source/dwm
Executable file
Binary file not shown.
BIN
KleinDwm/source/dwm-msg
Executable file
BIN
KleinDwm/source/dwm-msg
Executable file
Binary file not shown.
548
KleinDwm/source/dwm-msg.c
Normal file
548
KleinDwm/source/dwm-msg.c
Normal file
@@ -0,0 +1,548 @@
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <unistd.h>
|
||||
#include <yajl/yajl_gen.h>
|
||||
|
||||
#define IPC_MAGIC "DWM-IPC"
|
||||
// clang-format off
|
||||
#define IPC_MAGIC_ARR { 'D', 'W', 'M', '-', 'I', 'P', 'C' }
|
||||
// clang-format on
|
||||
#define IPC_MAGIC_LEN 7 // Not including null char
|
||||
|
||||
#define IPC_EVENT_TAG_CHANGE "tag_change_event"
|
||||
#define IPC_EVENT_CLIENT_FOCUS_CHANGE "client_focus_change_event"
|
||||
#define IPC_EVENT_LAYOUT_CHANGE "layout_change_event"
|
||||
#define IPC_EVENT_MONITOR_FOCUS_CHANGE "monitor_focus_change_event"
|
||||
#define IPC_EVENT_FOCUSED_TITLE_CHANGE "focused_title_change_event"
|
||||
#define IPC_EVENT_FOCUSED_STATE_CHANGE "focused_state_change_event"
|
||||
|
||||
#define YSTR(str) yajl_gen_string(gen, (unsigned char *)str, strlen(str))
|
||||
#define YINT(num) yajl_gen_integer(gen, num)
|
||||
#define YDOUBLE(num) yajl_gen_double(gen, num)
|
||||
#define YBOOL(v) yajl_gen_bool(gen, v)
|
||||
#define YNULL() yajl_gen_null(gen)
|
||||
#define YARR(body) \
|
||||
{ \
|
||||
yajl_gen_array_open(gen); \
|
||||
body; \
|
||||
yajl_gen_array_close(gen); \
|
||||
}
|
||||
#define YMAP(body) \
|
||||
{ \
|
||||
yajl_gen_map_open(gen); \
|
||||
body; \
|
||||
yajl_gen_map_close(gen); \
|
||||
}
|
||||
|
||||
typedef unsigned long Window;
|
||||
|
||||
const char *DEFAULT_SOCKET_PATH = "/tmp/dwm.sock";
|
||||
static int sock_fd = -1;
|
||||
static unsigned int ignore_reply = 0;
|
||||
|
||||
typedef enum IPCMessageType {
|
||||
IPC_TYPE_RUN_COMMAND = 0,
|
||||
IPC_TYPE_GET_MONITORS = 1,
|
||||
IPC_TYPE_GET_TAGS = 2,
|
||||
IPC_TYPE_GET_LAYOUTS = 3,
|
||||
IPC_TYPE_GET_DWM_CLIENT = 4,
|
||||
IPC_TYPE_SUBSCRIBE = 5,
|
||||
IPC_TYPE_EVENT = 6
|
||||
} IPCMessageType;
|
||||
|
||||
// Every IPC message must begin with this
|
||||
typedef struct dwm_ipc_header {
|
||||
uint8_t magic[IPC_MAGIC_LEN];
|
||||
uint32_t size;
|
||||
uint8_t type;
|
||||
} __attribute((packed)) dwm_ipc_header_t;
|
||||
|
||||
static int
|
||||
recv_message(uint8_t *msg_type, uint32_t *reply_size, uint8_t **reply)
|
||||
{
|
||||
uint32_t read_bytes = 0;
|
||||
const int32_t to_read = sizeof(dwm_ipc_header_t);
|
||||
char header[to_read];
|
||||
char *walk = header;
|
||||
|
||||
// Try to read header
|
||||
while (read_bytes < to_read) {
|
||||
ssize_t n = read(sock_fd, header + read_bytes, to_read - read_bytes);
|
||||
|
||||
if (n == 0) {
|
||||
if (read_bytes == 0) {
|
||||
fprintf(stderr, "Unexpectedly reached EOF while reading header.");
|
||||
fprintf(stderr,
|
||||
"Read %" PRIu32 " bytes, expected %" PRIu32 " total bytes.\n",
|
||||
read_bytes, to_read);
|
||||
return -2;
|
||||
} else {
|
||||
fprintf(stderr, "Unexpectedly reached EOF while reading header.");
|
||||
fprintf(stderr,
|
||||
"Read %" PRIu32 " bytes, expected %" PRIu32 " total bytes.\n",
|
||||
read_bytes, to_read);
|
||||
return -3;
|
||||
}
|
||||
} else if (n == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
read_bytes += n;
|
||||
}
|
||||
|
||||
// Check if magic string in header matches
|
||||
if (memcmp(walk, IPC_MAGIC, IPC_MAGIC_LEN) != 0) {
|
||||
fprintf(stderr, "Invalid magic string. Got '%.*s', expected '%s'\n",
|
||||
IPC_MAGIC_LEN, walk, IPC_MAGIC);
|
||||
return -3;
|
||||
}
|
||||
|
||||
walk += IPC_MAGIC_LEN;
|
||||
|
||||
// Extract reply size
|
||||
memcpy(reply_size, walk, sizeof(uint32_t));
|
||||
walk += sizeof(uint32_t);
|
||||
|
||||
// Extract message type
|
||||
memcpy(msg_type, walk, sizeof(uint8_t));
|
||||
walk += sizeof(uint8_t);
|
||||
|
||||
(*reply) = malloc(*reply_size);
|
||||
|
||||
// Extract payload
|
||||
read_bytes = 0;
|
||||
while (read_bytes < *reply_size) {
|
||||
ssize_t n = read(sock_fd, *reply + read_bytes, *reply_size - read_bytes);
|
||||
|
||||
if (n == 0) {
|
||||
fprintf(stderr, "Unexpectedly reached EOF while reading payload.");
|
||||
fprintf(stderr, "Read %" PRIu32 " bytes, expected %" PRIu32 " bytes.\n",
|
||||
read_bytes, *reply_size);
|
||||
free(*reply);
|
||||
return -2;
|
||||
} else if (n == -1) {
|
||||
if (errno == EINTR || errno == EAGAIN) continue;
|
||||
free(*reply);
|
||||
return -1;
|
||||
}
|
||||
|
||||
read_bytes += n;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
read_socket(IPCMessageType *msg_type, uint32_t *msg_size, char **msg)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
while (ret != 0) {
|
||||
ret = recv_message((uint8_t *)msg_type, msg_size, (uint8_t **)msg);
|
||||
|
||||
if (ret < 0) {
|
||||
// Try again (non-fatal error)
|
||||
if (ret == -1 && (errno == EINTR || errno == EAGAIN)) continue;
|
||||
|
||||
fprintf(stderr, "Error receiving response from socket. ");
|
||||
fprintf(stderr, "The connection might have been lost.\n");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
write_socket(const void *buf, size_t count)
|
||||
{
|
||||
size_t written = 0;
|
||||
|
||||
while (written < count) {
|
||||
const ssize_t n =
|
||||
write(sock_fd, ((uint8_t *)buf) + written, count - written);
|
||||
|
||||
if (n == -1) {
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR)
|
||||
continue;
|
||||
else
|
||||
return n;
|
||||
}
|
||||
written += n;
|
||||
}
|
||||
return written;
|
||||
}
|
||||
|
||||
static void
|
||||
connect_to_socket()
|
||||
{
|
||||
struct sockaddr_un addr;
|
||||
|
||||
int sock = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
|
||||
// Initialize struct to 0
|
||||
memset(&addr, 0, sizeof(struct sockaddr_un));
|
||||
|
||||
addr.sun_family = AF_UNIX;
|
||||
strcpy(addr.sun_path, DEFAULT_SOCKET_PATH);
|
||||
|
||||
connect(sock, (const struct sockaddr *)&addr, sizeof(struct sockaddr_un));
|
||||
|
||||
sock_fd = sock;
|
||||
}
|
||||
|
||||
static int
|
||||
send_message(IPCMessageType msg_type, uint32_t msg_size, uint8_t *msg)
|
||||
{
|
||||
dwm_ipc_header_t header = {
|
||||
.magic = IPC_MAGIC_ARR, .size = msg_size, .type = msg_type};
|
||||
|
||||
size_t header_size = sizeof(dwm_ipc_header_t);
|
||||
size_t total_size = header_size + msg_size;
|
||||
|
||||
uint8_t buffer[total_size];
|
||||
|
||||
// Copy header to buffer
|
||||
memcpy(buffer, &header, header_size);
|
||||
// Copy message to buffer
|
||||
memcpy(buffer + header_size, msg, header.size);
|
||||
|
||||
write_socket(buffer, total_size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
is_float(const char *s)
|
||||
{
|
||||
size_t len = strlen(s);
|
||||
int is_dot_used = 0;
|
||||
int is_minus_used = 0;
|
||||
|
||||
// Floats can only have one decimal point in between or digits
|
||||
// Optionally, floats can also be below zero (negative)
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (isdigit(s[i]))
|
||||
continue;
|
||||
else if (!is_dot_used && s[i] == '.' && i != 0 && i != len - 1) {
|
||||
is_dot_used = 1;
|
||||
continue;
|
||||
} else if (!is_minus_used && s[i] == '-' && i == 0) {
|
||||
is_minus_used = 1;
|
||||
continue;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
is_unsigned_int(const char *s)
|
||||
{
|
||||
size_t len = strlen(s);
|
||||
|
||||
// Unsigned int can only have digits
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (isdigit(s[i]))
|
||||
continue;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
is_signed_int(const char *s)
|
||||
{
|
||||
size_t len = strlen(s);
|
||||
|
||||
// Signed int can only have digits and a negative sign at the start
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (isdigit(s[i]))
|
||||
continue;
|
||||
else if (i == 0 && s[i] == '-') {
|
||||
continue;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
flush_socket_reply()
|
||||
{
|
||||
IPCMessageType reply_type;
|
||||
uint32_t reply_size;
|
||||
char *reply;
|
||||
|
||||
read_socket(&reply_type, &reply_size, &reply);
|
||||
|
||||
free(reply);
|
||||
}
|
||||
|
||||
static void
|
||||
print_socket_reply()
|
||||
{
|
||||
IPCMessageType reply_type;
|
||||
uint32_t reply_size;
|
||||
char *reply;
|
||||
|
||||
read_socket(&reply_type, &reply_size, &reply);
|
||||
|
||||
printf("%.*s\n", reply_size, reply);
|
||||
fflush(stdout);
|
||||
free(reply);
|
||||
}
|
||||
|
||||
static int
|
||||
run_command(const char *name, char *args[], int argc)
|
||||
{
|
||||
const unsigned char *msg;
|
||||
size_t msg_size;
|
||||
|
||||
yajl_gen gen = yajl_gen_alloc(NULL);
|
||||
|
||||
// Message format:
|
||||
// {
|
||||
// "command": "<name>",
|
||||
// "args": [ ... ]
|
||||
// }
|
||||
// clang-format off
|
||||
YMAP(
|
||||
YSTR("command"); YSTR(name);
|
||||
YSTR("args"); YARR(
|
||||
for (int i = 0; i < argc; i++) {
|
||||
if (is_signed_int(args[i])) {
|
||||
long long num = atoll(args[i]);
|
||||
YINT(num);
|
||||
} else if (is_float(args[i])) {
|
||||
float num = atof(args[i]);
|
||||
YDOUBLE(num);
|
||||
} else {
|
||||
YSTR(args[i]);
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
// clang-format on
|
||||
|
||||
yajl_gen_get_buf(gen, &msg, &msg_size);
|
||||
|
||||
send_message(IPC_TYPE_RUN_COMMAND, msg_size, (uint8_t *)msg);
|
||||
|
||||
if (!ignore_reply)
|
||||
print_socket_reply();
|
||||
else
|
||||
flush_socket_reply();
|
||||
|
||||
yajl_gen_free(gen);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
get_monitors()
|
||||
{
|
||||
send_message(IPC_TYPE_GET_MONITORS, 1, (uint8_t *)"");
|
||||
print_socket_reply();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
get_tags()
|
||||
{
|
||||
send_message(IPC_TYPE_GET_TAGS, 1, (uint8_t *)"");
|
||||
print_socket_reply();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
get_layouts()
|
||||
{
|
||||
send_message(IPC_TYPE_GET_LAYOUTS, 1, (uint8_t *)"");
|
||||
print_socket_reply();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
get_dwm_client(Window win)
|
||||
{
|
||||
const unsigned char *msg;
|
||||
size_t msg_size;
|
||||
|
||||
yajl_gen gen = yajl_gen_alloc(NULL);
|
||||
|
||||
// Message format:
|
||||
// {
|
||||
// "client_window_id": "<win>"
|
||||
// }
|
||||
// clang-format off
|
||||
YMAP(
|
||||
YSTR("client_window_id"); YINT(win);
|
||||
)
|
||||
// clang-format on
|
||||
|
||||
yajl_gen_get_buf(gen, &msg, &msg_size);
|
||||
|
||||
send_message(IPC_TYPE_GET_DWM_CLIENT, msg_size, (uint8_t *)msg);
|
||||
|
||||
print_socket_reply();
|
||||
|
||||
yajl_gen_free(gen);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
subscribe(const char *event)
|
||||
{
|
||||
const unsigned char *msg;
|
||||
size_t msg_size;
|
||||
|
||||
yajl_gen gen = yajl_gen_alloc(NULL);
|
||||
|
||||
// Message format:
|
||||
// {
|
||||
// "event": "<event>",
|
||||
// "action": "subscribe"
|
||||
// }
|
||||
// clang-format off
|
||||
YMAP(
|
||||
YSTR("event"); YSTR(event);
|
||||
YSTR("action"); YSTR("subscribe");
|
||||
)
|
||||
// clang-format on
|
||||
|
||||
yajl_gen_get_buf(gen, &msg, &msg_size);
|
||||
|
||||
send_message(IPC_TYPE_SUBSCRIBE, msg_size, (uint8_t *)msg);
|
||||
|
||||
if (!ignore_reply)
|
||||
print_socket_reply();
|
||||
else
|
||||
flush_socket_reply();
|
||||
|
||||
yajl_gen_free(gen);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
usage_error(const char *prog_name, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
||||
fprintf(stderr, "Error: ");
|
||||
vfprintf(stderr, format, args);
|
||||
fprintf(stderr, "\nusage: %s <command> [...]\n", prog_name);
|
||||
fprintf(stderr, "Try '%s help'\n", prog_name);
|
||||
|
||||
va_end(args);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void
|
||||
print_usage(const char *name)
|
||||
{
|
||||
printf("usage: %s [options] <command> [...]\n", name);
|
||||
puts("");
|
||||
puts("Commands:");
|
||||
puts(" run_command <name> [args...] Run an IPC command");
|
||||
puts("");
|
||||
puts(" get_monitors Get monitor properties");
|
||||
puts("");
|
||||
puts(" get_tags Get list of tags");
|
||||
puts("");
|
||||
puts(" get_layouts Get list of layouts");
|
||||
puts("");
|
||||
puts(" get_dwm_client <window_id> Get dwm client proprties");
|
||||
puts("");
|
||||
puts(" subscribe [events...] Subscribe to specified events");
|
||||
puts(" Options: " IPC_EVENT_TAG_CHANGE ",");
|
||||
puts(" " IPC_EVENT_LAYOUT_CHANGE ",");
|
||||
puts(" " IPC_EVENT_CLIENT_FOCUS_CHANGE ",");
|
||||
puts(" " IPC_EVENT_MONITOR_FOCUS_CHANGE ",");
|
||||
puts(" " IPC_EVENT_FOCUSED_TITLE_CHANGE ",");
|
||||
puts(" " IPC_EVENT_FOCUSED_STATE_CHANGE);
|
||||
puts("");
|
||||
puts(" help Display this message");
|
||||
puts("");
|
||||
puts("Options:");
|
||||
puts(" --ignore-reply Don't print reply messages from");
|
||||
puts(" run_command and subscribe.");
|
||||
puts("");
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
const char *prog_name = argv[0];
|
||||
|
||||
connect_to_socket();
|
||||
if (sock_fd == -1) {
|
||||
fprintf(stderr, "Failed to connect to socket\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int i = 1;
|
||||
if (i < argc && strcmp(argv[i], "--ignore-reply") == 0) {
|
||||
ignore_reply = 1;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i >= argc) usage_error(prog_name, "Expected an argument, got none");
|
||||
|
||||
if (strcmp(argv[i], "help") == 0)
|
||||
print_usage(prog_name);
|
||||
else if (strcmp(argv[i], "run_command") == 0) {
|
||||
if (++i >= argc) usage_error(prog_name, "No command specified");
|
||||
// Command name
|
||||
char *command = argv[i];
|
||||
// Command arguments are everything after command name
|
||||
char **command_args = argv + ++i;
|
||||
// Number of command arguments
|
||||
int command_argc = argc - i;
|
||||
run_command(command, command_args, command_argc);
|
||||
} else if (strcmp(argv[i], "get_monitors") == 0) {
|
||||
get_monitors();
|
||||
} else if (strcmp(argv[i], "get_tags") == 0) {
|
||||
get_tags();
|
||||
} else if (strcmp(argv[i], "get_layouts") == 0) {
|
||||
get_layouts();
|
||||
} else if (strcmp(argv[i], "get_dwm_client") == 0) {
|
||||
if (++i < argc) {
|
||||
if (is_unsigned_int(argv[i])) {
|
||||
Window win = atol(argv[i]);
|
||||
get_dwm_client(win);
|
||||
} else
|
||||
usage_error(prog_name, "Expected unsigned integer argument");
|
||||
} else
|
||||
usage_error(prog_name, "Expected the window id");
|
||||
} else if (strcmp(argv[i], "subscribe") == 0) {
|
||||
if (++i < argc) {
|
||||
for (int j = i; j < argc; j++) subscribe(argv[j]);
|
||||
} else
|
||||
usage_error(prog_name, "Expected event name");
|
||||
// Keep listening for events forever
|
||||
while (1) {
|
||||
print_socket_reply();
|
||||
}
|
||||
} else
|
||||
usage_error(prog_name, "Invalid argument '%s'", argv[i]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
BIN
KleinDwm/source/dwm-msg.o
Normal file
BIN
KleinDwm/source/dwm-msg.o
Normal file
Binary file not shown.
219
KleinDwm/source/dwm.1
Normal file
219
KleinDwm/source/dwm.1
Normal file
@@ -0,0 +1,219 @@
|
||||
.TH DWM 1 dwm\-VERSION
|
||||
.SH NAME
|
||||
dwm \- dynamic window manager
|
||||
.SH SYNOPSIS
|
||||
.B dwm
|
||||
.RB [ \-v ]
|
||||
.SH DESCRIPTION
|
||||
dwm is a dynamic window manager for X. It manages windows in tiled, monocle
|
||||
and floating layouts. Either layout can be applied dynamically, optimising the
|
||||
environment for the application in use and the task performed.
|
||||
.P
|
||||
In tiled layouts windows are managed in a master and stacking area. The master
|
||||
area on the left contains one window by default, and the stacking area on the
|
||||
right contains all other windows. The number of master area windows can be
|
||||
adjusted from zero to an arbitrary number. In monocle layout all windows are
|
||||
maximised to the screen size. In floating layout windows can be resized and
|
||||
moved freely. Dialog windows are always managed floating, regardless of the
|
||||
layout applied.
|
||||
.P
|
||||
Windows are grouped by tags. Each window can be tagged with one or multiple
|
||||
tags. Selecting certain tags displays all windows with these tags.
|
||||
.P
|
||||
Each screen contains a small status bar which displays all available tags, the
|
||||
layout, the title of the focused window, and the text read from the root window
|
||||
name property, if the screen is focused. A floating window is indicated with an
|
||||
empty square and a maximised floating window is indicated with a filled square
|
||||
before the windows title. The selected tags are indicated with a different
|
||||
color. The tags of the focused window are indicated with a filled square in the
|
||||
top left corner. The tags which are applied to one or more windows are
|
||||
indicated with an empty square in the top left corner.
|
||||
.P
|
||||
dwm draws a small border around windows to indicate the focus state.
|
||||
.P
|
||||
On start, dwm can start additional programs that may be specified in two special
|
||||
shell scripts (see the FILES section below), autostart_blocking.sh and
|
||||
autostart.sh. The former is executed first and dwm will wait for its
|
||||
termination before starting. The latter is executed in the background before
|
||||
dwm enters its handler loop.
|
||||
.P
|
||||
Either of these files may be omitted.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-v
|
||||
prints version information to stderr, then exits.
|
||||
.SH USAGE
|
||||
.SS Status bar
|
||||
.TP
|
||||
.B X root window name
|
||||
is read and displayed in the status text area. It can be set with the
|
||||
.BR xsetroot (1)
|
||||
command.
|
||||
.TP
|
||||
.B Button1
|
||||
click on a tag label to display all windows with that tag, click on the layout
|
||||
label toggles between tiled and floating layout.
|
||||
.TP
|
||||
.B Button3
|
||||
click on a tag label adds/removes all windows with that tag to/from the view.
|
||||
.TP
|
||||
.B Mod1\-Button1
|
||||
click on a tag label applies that tag to the focused window.
|
||||
.TP
|
||||
.B Mod1\-Button3
|
||||
click on a tag label adds/removes that tag to/from the focused window.
|
||||
.SS Keyboard commands
|
||||
.TP
|
||||
.B Mod1\-Shift\-Return
|
||||
Start
|
||||
.BR st(1).
|
||||
.TP
|
||||
.B Mod1\-p
|
||||
Spawn
|
||||
.BR dmenu(1)
|
||||
for launching other programs.
|
||||
.TP
|
||||
.B Mod1\-,
|
||||
Focus previous screen, if any.
|
||||
.TP
|
||||
.B Mod1\-.
|
||||
Focus next screen, if any.
|
||||
.TP
|
||||
.B Mod1\-Shift\-,
|
||||
Send focused window to previous screen, if any.
|
||||
.TP
|
||||
.B Mod1\-Shift\-.
|
||||
Send focused window to next screen, if any.
|
||||
.TP
|
||||
.B Mod1\-b
|
||||
Toggles bar on and off.
|
||||
.TP
|
||||
.B Mod1\-t
|
||||
Sets tiled layout.
|
||||
.TP
|
||||
.B Mod1\-f
|
||||
Sets floating layout.
|
||||
.TP
|
||||
.B Mod1\-m
|
||||
Sets monocle layout.
|
||||
.TP
|
||||
.B Mod1\-space
|
||||
Toggles between current and previous layout.
|
||||
.TP
|
||||
.B Mod1\-j
|
||||
Focus next window.
|
||||
.TP
|
||||
.B Mod1\-k
|
||||
Focus previous window.
|
||||
.TP
|
||||
.B Mod1\-i
|
||||
Increase number of windows in master area.
|
||||
.TP
|
||||
.B Mod1\-d
|
||||
Decrease number of windows in master area.
|
||||
.TP
|
||||
.B Mod1\-l
|
||||
Increase master area size.
|
||||
.TP
|
||||
.B Mod1\-h
|
||||
Decrease master area size.
|
||||
.TP
|
||||
.B Mod1\-Return
|
||||
Zooms/cycles focused window to/from master area (tiled layouts only).
|
||||
.TP
|
||||
.B Mod1\-Shift\-c
|
||||
Close focused window.
|
||||
.TP
|
||||
.B Mod1\-Shift\-space
|
||||
Toggle focused window between tiled and floating state.
|
||||
.TP
|
||||
.B Mod1\-Tab
|
||||
Toggles to the previously selected tags.
|
||||
.TP
|
||||
.B Mod1\-Shift\-[1..n]
|
||||
Apply nth tag to focused window.
|
||||
.TP
|
||||
.B Mod1\-Shift\-0
|
||||
Apply all tags to focused window.
|
||||
.TP
|
||||
.B Mod1\-Control\-Shift\-[1..n]
|
||||
Add/remove nth tag to/from focused window.
|
||||
.TP
|
||||
.B Mod1\-[1..n]
|
||||
View all windows with nth tag.
|
||||
.TP
|
||||
.B Mod1\-0
|
||||
View all windows with any tag.
|
||||
.TP
|
||||
.B Mod1\-Control\-[1..n]
|
||||
Add/remove all windows with nth tag to/from the view.
|
||||
.TP
|
||||
.B Mod1\--
|
||||
Decrease the gaps around windows.
|
||||
.TP
|
||||
.B Mod1\-=
|
||||
Increase the gaps around windows.
|
||||
.TP
|
||||
.B Mod1\-Shift-=
|
||||
Reset the gaps around windows to
|
||||
.BR 0 .
|
||||
.TP
|
||||
.B Mod1\-Shift\-q
|
||||
Quit dwm.
|
||||
.TP
|
||||
.B Mod1\-Control\-Shift\-q
|
||||
Restart dwm.
|
||||
.SS Mouse commands
|
||||
.TP
|
||||
.B Mod1\-Button1
|
||||
Move focused window while dragging. Tiled windows will be toggled to the floating state.
|
||||
.TP
|
||||
.B Mod1\-Button2
|
||||
Toggles focused window between floating and tiled state.
|
||||
.TP
|
||||
.B Mod1\-Button3
|
||||
Resize focused window while dragging. Tiled windows will be toggled to the floating state.
|
||||
.SH FILES
|
||||
The files containing programs to be started along with dwm are searched for in
|
||||
the following directories:
|
||||
.IP "1. $XDG_DATA_HOME/dwm"
|
||||
.IP "2. $HOME/.local/share/dwm"
|
||||
.IP "3. $HOME/.dwm"
|
||||
.P
|
||||
The first existing directory is scanned for any of the autostart files below.
|
||||
.TP 15
|
||||
autostart.sh
|
||||
This file is started as a shell background process before dwm enters its handler
|
||||
loop.
|
||||
.TP 15
|
||||
autostart_blocking.sh
|
||||
This file is started before any autostart.sh; dwm waits for its termination.
|
||||
.SH CUSTOMIZATION
|
||||
dwm is customized by creating a custom config.h and (re)compiling the source
|
||||
code. This keeps it fast, secure and simple.
|
||||
.SH SIGNALS
|
||||
.TP
|
||||
.B SIGHUP - 1
|
||||
Restart the dwm process.
|
||||
.TP
|
||||
.B SIGTERM - 15
|
||||
Cleanly terminate the dwm process.
|
||||
.SH SEE ALSO
|
||||
.BR dmenu (1),
|
||||
.BR st (1)
|
||||
.SH ISSUES
|
||||
Java applications which use the XToolkit/XAWT backend may draw grey windows
|
||||
only. The XToolkit/XAWT backend breaks ICCCM-compliance in recent JDK 1.5 and early
|
||||
JDK 1.6 versions, because it assumes a reparenting window manager. Possible workarounds
|
||||
are using JDK 1.4 (which doesn't contain the XToolkit/XAWT backend) or setting the
|
||||
environment variable
|
||||
.BR AWT_TOOLKIT=MToolkit
|
||||
(to use the older Motif backend instead) or running
|
||||
.B xprop -root -f _NET_WM_NAME 32a -set _NET_WM_NAME LG3D
|
||||
or
|
||||
.B wmname LG3D
|
||||
(to pretend that a non-reparenting window manager is running that the
|
||||
XToolkit/XAWT backend can recognize) or when using OpenJDK setting the environment variable
|
||||
.BR _JAVA_AWT_WM_NONREPARENTING=1 .
|
||||
.SH BUGS
|
||||
Send all bug reports with a patch to hackers@suckless.org.
|
||||
209
KleinDwm/source/dwm.1.orig
Normal file
209
KleinDwm/source/dwm.1.orig
Normal file
@@ -0,0 +1,209 @@
|
||||
.TH DWM 1 dwm\-VERSION
|
||||
.SH NAME
|
||||
dwm \- dynamic window manager
|
||||
.SH SYNOPSIS
|
||||
.B dwm
|
||||
.RB [ \-v ]
|
||||
.SH DESCRIPTION
|
||||
dwm is a dynamic window manager for X. It manages windows in tiled, monocle
|
||||
and floating layouts. Either layout can be applied dynamically, optimising the
|
||||
environment for the application in use and the task performed.
|
||||
.P
|
||||
In tiled layouts windows are managed in a master and stacking area. The master
|
||||
area on the left contains one window by default, and the stacking area on the
|
||||
right contains all other windows. The number of master area windows can be
|
||||
adjusted from zero to an arbitrary number. In monocle layout all windows are
|
||||
maximised to the screen size. In floating layout windows can be resized and
|
||||
moved freely. Dialog windows are always managed floating, regardless of the
|
||||
layout applied.
|
||||
.P
|
||||
Windows are grouped by tags. Each window can be tagged with one or multiple
|
||||
tags. Selecting certain tags displays all windows with these tags.
|
||||
.P
|
||||
Each screen contains a small status bar which displays all available tags, the
|
||||
layout, the title of the focused window, and the text read from the root window
|
||||
name property, if the screen is focused. A floating window is indicated with an
|
||||
empty square and a maximised floating window is indicated with a filled square
|
||||
before the windows title. The selected tags are indicated with a different
|
||||
color. The tags of the focused window are indicated with a filled square in the
|
||||
top left corner. The tags which are applied to one or more windows are
|
||||
indicated with an empty square in the top left corner.
|
||||
.P
|
||||
dwm draws a small border around windows to indicate the focus state.
|
||||
.P
|
||||
On start, dwm can start additional programs that may be specified in two special
|
||||
shell scripts (see the FILES section below), autostart_blocking.sh and
|
||||
autostart.sh. The former is executed first and dwm will wait for its
|
||||
termination before starting. The latter is executed in the background before
|
||||
dwm enters its handler loop.
|
||||
.P
|
||||
Either of these files may be omitted.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-v
|
||||
prints version information to stderr, then exits.
|
||||
.SH USAGE
|
||||
.SS Status bar
|
||||
.TP
|
||||
.B X root window name
|
||||
is read and displayed in the status text area. It can be set with the
|
||||
.BR xsetroot (1)
|
||||
command.
|
||||
.TP
|
||||
.B Button1
|
||||
click on a tag label to display all windows with that tag, click on the layout
|
||||
label toggles between tiled and floating layout.
|
||||
.TP
|
||||
.B Button3
|
||||
click on a tag label adds/removes all windows with that tag to/from the view.
|
||||
.TP
|
||||
.B Mod1\-Button1
|
||||
click on a tag label applies that tag to the focused window.
|
||||
.TP
|
||||
.B Mod1\-Button3
|
||||
click on a tag label adds/removes that tag to/from the focused window.
|
||||
.SS Keyboard commands
|
||||
.TP
|
||||
.B Mod1\-Shift\-Return
|
||||
Start
|
||||
.BR st(1).
|
||||
.TP
|
||||
.B Mod1\-p
|
||||
Spawn
|
||||
.BR dmenu(1)
|
||||
for launching other programs.
|
||||
.TP
|
||||
.B Mod1\-,
|
||||
Focus previous screen, if any.
|
||||
.TP
|
||||
.B Mod1\-.
|
||||
Focus next screen, if any.
|
||||
.TP
|
||||
.B Mod1\-Shift\-,
|
||||
Send focused window to previous screen, if any.
|
||||
.TP
|
||||
.B Mod1\-Shift\-.
|
||||
Send focused window to next screen, if any.
|
||||
.TP
|
||||
.B Mod1\-b
|
||||
Toggles bar on and off.
|
||||
.TP
|
||||
.B Mod1\-t
|
||||
Sets tiled layout.
|
||||
.TP
|
||||
.B Mod1\-f
|
||||
Sets floating layout.
|
||||
.TP
|
||||
.B Mod1\-m
|
||||
Sets monocle layout.
|
||||
.TP
|
||||
.B Mod1\-space
|
||||
Toggles between current and previous layout.
|
||||
.TP
|
||||
.B Mod1\-j
|
||||
Focus next window.
|
||||
.TP
|
||||
.B Mod1\-k
|
||||
Focus previous window.
|
||||
.TP
|
||||
.B Mod1\-i
|
||||
Increase number of windows in master area.
|
||||
.TP
|
||||
.B Mod1\-d
|
||||
Decrease number of windows in master area.
|
||||
.TP
|
||||
.B Mod1\-l
|
||||
Increase master area size.
|
||||
.TP
|
||||
.B Mod1\-h
|
||||
Decrease master area size.
|
||||
.TP
|
||||
.B Mod1\-Return
|
||||
Zooms/cycles focused window to/from master area (tiled layouts only).
|
||||
.TP
|
||||
.B Mod1\-Shift\-c
|
||||
Close focused window.
|
||||
.TP
|
||||
.B Mod1\-Shift\-space
|
||||
Toggle focused window between tiled and floating state.
|
||||
.TP
|
||||
.B Mod1\-Tab
|
||||
Toggles to the previously selected tags.
|
||||
.TP
|
||||
.B Mod1\-Shift\-[1..n]
|
||||
Apply nth tag to focused window.
|
||||
.TP
|
||||
.B Mod1\-Shift\-0
|
||||
Apply all tags to focused window.
|
||||
.TP
|
||||
.B Mod1\-Control\-Shift\-[1..n]
|
||||
Add/remove nth tag to/from focused window.
|
||||
.TP
|
||||
.B Mod1\-[1..n]
|
||||
View all windows with nth tag.
|
||||
.TP
|
||||
.B Mod1\-0
|
||||
View all windows with any tag.
|
||||
.TP
|
||||
.B Mod1\-Control\-[1..n]
|
||||
Add/remove all windows with nth tag to/from the view.
|
||||
.TP
|
||||
.B Mod1\-Shift\-q
|
||||
Quit dwm.
|
||||
.TP
|
||||
.B Mod1\-Control\-Shift\-q
|
||||
Restart dwm.
|
||||
.SS Mouse commands
|
||||
.TP
|
||||
.B Mod1\-Button1
|
||||
Move focused window while dragging. Tiled windows will be toggled to the floating state.
|
||||
.TP
|
||||
.B Mod1\-Button2
|
||||
Toggles focused window between floating and tiled state.
|
||||
.TP
|
||||
.B Mod1\-Button3
|
||||
Resize focused window while dragging. Tiled windows will be toggled to the floating state.
|
||||
.SH FILES
|
||||
The files containing programs to be started along with dwm are searched for in
|
||||
the following directories:
|
||||
.IP "1. $XDG_DATA_HOME/dwm"
|
||||
.IP "2. $HOME/.local/share/dwm"
|
||||
.IP "3. $HOME/.dwm"
|
||||
.P
|
||||
The first existing directory is scanned for any of the autostart files below.
|
||||
.TP 15
|
||||
autostart.sh
|
||||
This file is started as a shell background process before dwm enters its handler
|
||||
loop.
|
||||
.TP 15
|
||||
autostart_blocking.sh
|
||||
This file is started before any autostart.sh; dwm waits for its termination.
|
||||
.SH CUSTOMIZATION
|
||||
dwm is customized by creating a custom config.h and (re)compiling the source
|
||||
code. This keeps it fast, secure and simple.
|
||||
.SH SIGNALS
|
||||
.TP
|
||||
.B SIGHUP - 1
|
||||
Restart the dwm process.
|
||||
.TP
|
||||
.B SIGTERM - 15
|
||||
Cleanly terminate the dwm process.
|
||||
.SH SEE ALSO
|
||||
.BR dmenu (1),
|
||||
.BR st (1)
|
||||
.SH ISSUES
|
||||
Java applications which use the XToolkit/XAWT backend may draw grey windows
|
||||
only. The XToolkit/XAWT backend breaks ICCCM-compliance in recent JDK 1.5 and early
|
||||
JDK 1.6 versions, because it assumes a reparenting window manager. Possible workarounds
|
||||
are using JDK 1.4 (which doesn't contain the XToolkit/XAWT backend) or setting the
|
||||
environment variable
|
||||
.BR AWT_TOOLKIT=MToolkit
|
||||
(to use the older Motif backend instead) or running
|
||||
.B xprop -root -f _NET_WM_NAME 32a -set _NET_WM_NAME LG3D
|
||||
or
|
||||
.B wmname LG3D
|
||||
(to pretend that a non-reparenting window manager is running that the
|
||||
XToolkit/XAWT backend can recognize) or when using OpenJDK setting the environment variable
|
||||
.BR _JAVA_AWT_WM_NONREPARENTING=1 .
|
||||
.SH BUGS
|
||||
Send all bug reports with a patch to hackers@suckless.org.
|
||||
3098
KleinDwm/source/dwm.c
Normal file
3098
KleinDwm/source/dwm.c
Normal file
File diff suppressed because it is too large
Load Diff
2965
KleinDwm/source/dwm.c.orig
Normal file
2965
KleinDwm/source/dwm.c.orig
Normal file
File diff suppressed because it is too large
Load Diff
53
KleinDwm/source/dwm.c.rej
Normal file
53
KleinDwm/source/dwm.c.rej
Normal file
@@ -0,0 +1,53 @@
|
||||
--- dwm.c
|
||||
+++ dwm.c
|
||||
@@ -125,8 +139,10 @@ typedef struct {
|
||||
void (*arrange)(Monitor *);
|
||||
} Layout;
|
||||
|
||||
+
|
||||
struct Monitor {
|
||||
char ltsymbol[16];
|
||||
float mfact;
|
||||
int nmaster;
|
||||
int num;
|
||||
@@ -136,14 +152,17 @@ struct Monitor {
|
||||
unsigned int seltags;
|
||||
unsigned int sellt;
|
||||
unsigned int tagset[2];
|
||||
int showbar;
|
||||
int topbar;
|
||||
Client *clients;
|
||||
Client *sel;
|
||||
Client *stack;
|
||||
Monitor *next;
|
||||
Window barwin;
|
||||
const Layout *lt[2];
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
@@ -278,17 +300,27 @@ static void (*handler[LASTEvent]) (XEvent *) = {
|
||||
[UnmapNotify] = unmapnotify
|
||||
};
|
||||
static Atom wmatom[WMLast], netatom[NetLast];
|
||||
static int running = 1;
|
||||
static Cur *cursor[CurLast];
|
||||
static Clr **scheme;
|
||||
static Display *dpy;
|
||||
static Drw *drw;
|
||||
static Window root, wmcheckwin;
|
||||
|
||||
/* configuration, allows nested code to access above variables */
|
||||
#include "config.h"
|
||||
|
||||
/* compile-time check if all tags fit into an unsigned int bit array. */
|
||||
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
||||
|
||||
@@ -1677,8 +1774,37 @@ setup(void)
|
||||
XSelectInput(dpy, root, wa.event_mask);
|
||||
grabkeys();
|
||||
focus(NULL);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
seturgent(Client *c, int urg)
|
||||
BIN
KleinDwm/source/dwm.o
Normal file
BIN
KleinDwm/source/dwm.o
Normal file
Binary file not shown.
66
KleinDwm/source/fibonacci.c
Normal file
66
KleinDwm/source/fibonacci.c
Normal file
@@ -0,0 +1,66 @@
|
||||
void
|
||||
fibonacci(Monitor *mon, int s) {
|
||||
unsigned int i, n, nx, ny, nw, nh;
|
||||
Client *c;
|
||||
|
||||
for(n = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next), n++);
|
||||
if(n == 0)
|
||||
return;
|
||||
|
||||
nx = mon->wx;
|
||||
ny = 0;
|
||||
nw = mon->ww;
|
||||
nh = mon->wh;
|
||||
|
||||
for(i = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next)) {
|
||||
if((i % 2 && nh / 2 > 2 * c->bw)
|
||||
|| (!(i % 2) && nw / 2 > 2 * c->bw)) {
|
||||
if(i < n - 1) {
|
||||
if(i % 2)
|
||||
nh /= 2;
|
||||
else
|
||||
nw /= 2;
|
||||
if((i % 4) == 2 && !s)
|
||||
nx += nw;
|
||||
else if((i % 4) == 3 && !s)
|
||||
ny += nh;
|
||||
}
|
||||
if((i % 4) == 0) {
|
||||
if(s)
|
||||
ny += nh;
|
||||
else
|
||||
ny -= nh;
|
||||
}
|
||||
else if((i % 4) == 1)
|
||||
nx += nw;
|
||||
else if((i % 4) == 2)
|
||||
ny += nh;
|
||||
else if((i % 4) == 3) {
|
||||
if(s)
|
||||
nx += nw;
|
||||
else
|
||||
nx -= nw;
|
||||
}
|
||||
if(i == 0)
|
||||
{
|
||||
if(n != 1)
|
||||
nw = mon->ww * mon->mfact;
|
||||
ny = mon->wy;
|
||||
}
|
||||
else if(i == 1)
|
||||
nw = mon->ww - nw;
|
||||
i++;
|
||||
}
|
||||
resize(c, nx, ny, nw - 2 * c->bw, nh - 2 * c->bw, False);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
dwindle(Monitor *mon) {
|
||||
fibonacci(mon, 1);
|
||||
}
|
||||
|
||||
void
|
||||
spiral(Monitor *mon) {
|
||||
fibonacci(mon, 0);
|
||||
}
|
||||
1202
KleinDwm/source/ipc.c
Normal file
1202
KleinDwm/source/ipc.c
Normal file
File diff suppressed because it is too large
Load Diff
320
KleinDwm/source/ipc.h
Normal file
320
KleinDwm/source/ipc.h
Normal file
@@ -0,0 +1,320 @@
|
||||
#ifndef IPC_H_
|
||||
#define IPC_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/epoll.h>
|
||||
#include <yajl/yajl_gen.h>
|
||||
|
||||
#include "IPCClient.h"
|
||||
|
||||
// clang-format off
|
||||
#define IPC_MAGIC "DWM-IPC"
|
||||
#define IPC_MAGIC_ARR { 'D', 'W', 'M', '-', 'I', 'P', 'C'}
|
||||
#define IPC_MAGIC_LEN 7 // Not including null char
|
||||
|
||||
#define IPCCOMMAND(FUNC, ARGC, TYPES) \
|
||||
{ #FUNC, {FUNC }, ARGC, (ArgType[ARGC])TYPES }
|
||||
// clang-format on
|
||||
|
||||
typedef enum IPCMessageType {
|
||||
IPC_TYPE_RUN_COMMAND = 0,
|
||||
IPC_TYPE_GET_MONITORS = 1,
|
||||
IPC_TYPE_GET_TAGS = 2,
|
||||
IPC_TYPE_GET_LAYOUTS = 3,
|
||||
IPC_TYPE_GET_DWM_CLIENT = 4,
|
||||
IPC_TYPE_SUBSCRIBE = 5,
|
||||
IPC_TYPE_EVENT = 6
|
||||
} IPCMessageType;
|
||||
|
||||
typedef enum IPCEvent {
|
||||
IPC_EVENT_TAG_CHANGE = 1 << 0,
|
||||
IPC_EVENT_CLIENT_FOCUS_CHANGE = 1 << 1,
|
||||
IPC_EVENT_LAYOUT_CHANGE = 1 << 2,
|
||||
IPC_EVENT_MONITOR_FOCUS_CHANGE = 1 << 3,
|
||||
IPC_EVENT_FOCUSED_TITLE_CHANGE = 1 << 4,
|
||||
IPC_EVENT_FOCUSED_STATE_CHANGE = 1 << 5
|
||||
} IPCEvent;
|
||||
|
||||
typedef enum IPCSubscriptionAction {
|
||||
IPC_ACTION_UNSUBSCRIBE = 0,
|
||||
IPC_ACTION_SUBSCRIBE = 1
|
||||
} IPCSubscriptionAction;
|
||||
|
||||
/**
|
||||
* Every IPC packet starts with this structure
|
||||
*/
|
||||
typedef struct dwm_ipc_header {
|
||||
uint8_t magic[IPC_MAGIC_LEN];
|
||||
uint32_t size;
|
||||
uint8_t type;
|
||||
} __attribute((packed)) dwm_ipc_header_t;
|
||||
|
||||
typedef enum ArgType {
|
||||
ARG_TYPE_NONE = 0,
|
||||
ARG_TYPE_UINT = 1,
|
||||
ARG_TYPE_SINT = 2,
|
||||
ARG_TYPE_FLOAT = 3,
|
||||
ARG_TYPE_PTR = 4,
|
||||
ARG_TYPE_STR = 5
|
||||
} ArgType;
|
||||
|
||||
/**
|
||||
* An IPCCommand function can have either of these function signatures
|
||||
*/
|
||||
typedef union ArgFunction {
|
||||
void (*single_param)(const Arg *);
|
||||
void (*array_param)(const Arg *, int);
|
||||
} ArgFunction;
|
||||
|
||||
typedef struct IPCCommand {
|
||||
char *name;
|
||||
ArgFunction func;
|
||||
unsigned int argc;
|
||||
ArgType *arg_types;
|
||||
} IPCCommand;
|
||||
|
||||
typedef struct IPCParsedCommand {
|
||||
char *name;
|
||||
Arg *args;
|
||||
ArgType *arg_types;
|
||||
unsigned int argc;
|
||||
} IPCParsedCommand;
|
||||
|
||||
/**
|
||||
* Initialize the IPC socket and the IPC module
|
||||
*
|
||||
* @param socket_path Path to create the socket at
|
||||
* @param epoll_fd File descriptor for epoll
|
||||
* @param commands Address of IPCCommands array defined in config.h
|
||||
* @param commands_len Length of commands[] array
|
||||
*
|
||||
* @return int The file descriptor of the socket if it was successfully created,
|
||||
* -1 otherwise
|
||||
*/
|
||||
int ipc_init(const char *socket_path, const int p_epoll_fd,
|
||||
IPCCommand commands[], const int commands_len);
|
||||
|
||||
/**
|
||||
* Uninitialize the socket and module. Free allocated memory and restore static
|
||||
* variables to their state before ipc_init
|
||||
*/
|
||||
void ipc_cleanup();
|
||||
|
||||
/**
|
||||
* Get the file descriptor of the IPC socket
|
||||
*
|
||||
* @return int File descriptor of IPC socket, -1 if socket not created.
|
||||
*/
|
||||
int ipc_get_sock_fd();
|
||||
|
||||
/**
|
||||
* Get address to IPCClient with specified file descriptor
|
||||
*
|
||||
* @param fd File descriptor of IPC Client
|
||||
*
|
||||
* @return Address to IPCClient with specified file descriptor, -1 otherwise
|
||||
*/
|
||||
IPCClient *ipc_get_client(int fd);
|
||||
|
||||
/**
|
||||
* Check if an IPC client exists with the specified file descriptor
|
||||
*
|
||||
* @param fd File descriptor
|
||||
*
|
||||
* @return int 1 if client exists, 0 otherwise
|
||||
*/
|
||||
int ipc_is_client_registered(int fd);
|
||||
|
||||
/**
|
||||
* Disconnect an IPCClient from the socket and remove the client from the list
|
||||
* of known connected clients
|
||||
*
|
||||
* @param c Address of IPCClient
|
||||
*
|
||||
* @return 0 if the client's file descriptor was closed successfully, the
|
||||
* result of executing close() on the file descriptor otherwise.
|
||||
*/
|
||||
int ipc_drop_client(IPCClient *c);
|
||||
|
||||
/**
|
||||
* Accept an IPC Client requesting to connect to the socket and add it to the
|
||||
* list of clients
|
||||
*
|
||||
* @return File descriptor of new client, -1 on error
|
||||
*/
|
||||
int ipc_accept_client();
|
||||
|
||||
/**
|
||||
* Read an incoming message from an accepted IPC client
|
||||
*
|
||||
* @param c Address of IPCClient
|
||||
* @param msg_type Address to IPCMessageType variable which will be assigned
|
||||
* the message type of the received message
|
||||
* @param msg_size Address to uint32_t variable which will be assigned the size
|
||||
* of the received message
|
||||
* @param msg Address to char* variable which will be assigned the address of
|
||||
* the received message. This must be freed using free().
|
||||
*
|
||||
* @return 0 on success, -1 on error reading message, -2 if reading the message
|
||||
* resulted in EAGAIN, EINTR, or EWOULDBLOCK.
|
||||
*/
|
||||
int ipc_read_client(IPCClient *c, IPCMessageType *msg_type, uint32_t *msg_size,
|
||||
char **msg);
|
||||
|
||||
/**
|
||||
* Write any pending buffer of the client to the client's socket
|
||||
*
|
||||
* @param c Client whose buffer to write
|
||||
*
|
||||
* @return Number of bytes written >= 0, -1 otherwise. errno will still be set
|
||||
* from the write operation.
|
||||
*/
|
||||
ssize_t ipc_write_client(IPCClient *c);
|
||||
|
||||
/**
|
||||
* Prepare a message in the specified client's buffer.
|
||||
*
|
||||
* @param c Client to prepare message for
|
||||
* @param msg_type Type of message to prepare
|
||||
* @param msg_size Size of the message in bytes. Should not exceed
|
||||
* MAX_MESSAGE_SIZE
|
||||
* @param msg Message to prepare (not including header). This pointer can be
|
||||
* freed after the function invocation.
|
||||
*/
|
||||
void ipc_prepare_send_message(IPCClient *c, const IPCMessageType msg_type,
|
||||
const uint32_t msg_size, const char *msg);
|
||||
|
||||
/**
|
||||
* Prepare an error message in the specified client's buffer
|
||||
*
|
||||
* @param c Client to prepare message for
|
||||
* @param msg_type Type of message
|
||||
* @param format Format string following vsprintf
|
||||
* @param ... Arguments for format string
|
||||
*/
|
||||
void ipc_prepare_reply_failure(IPCClient *c, IPCMessageType msg_type,
|
||||
const char *format, ...);
|
||||
|
||||
/**
|
||||
* Prepare a success message in the specified client's buffer
|
||||
*
|
||||
* @param c Client to prepare message for
|
||||
* @param msg_type Type of message
|
||||
*/
|
||||
void ipc_prepare_reply_success(IPCClient *c, IPCMessageType msg_type);
|
||||
|
||||
/**
|
||||
* Send a tag_change_event to all subscribers. Should be called only when there
|
||||
* has been a tag state change.
|
||||
*
|
||||
* @param mon_num The index of the monitor (Monitor.num property)
|
||||
* @param old_state The old tag state
|
||||
* @param new_state The new (now current) tag state
|
||||
*/
|
||||
void ipc_tag_change_event(const int mon_num, TagState old_state,
|
||||
TagState new_state);
|
||||
|
||||
/**
|
||||
* Send a client_focus_change_event to all subscribers. Should be called only
|
||||
* when the client focus changes.
|
||||
*
|
||||
* @param mon_num The index of the monitor (Monitor.num property)
|
||||
* @param old_client The old DWM client selection (Monitor.oldsel)
|
||||
* @param new_client The new (now current) DWM client selection
|
||||
*/
|
||||
void ipc_client_focus_change_event(const int mon_num, Client *old_client,
|
||||
Client *new_client);
|
||||
|
||||
/**
|
||||
* Send a layout_change_event to all subscribers. Should be called only
|
||||
* when there has been a layout change.
|
||||
*
|
||||
* @param mon_num The index of the monitor (Monitor.num property)
|
||||
* @param old_symbol The old layout symbol
|
||||
* @param old_layout Address to the old Layout
|
||||
* @param new_symbol The new (now current) layout symbol
|
||||
* @param new_layout Address to the new Layout
|
||||
*/
|
||||
void ipc_layout_change_event(const int mon_num, const char *old_symbol,
|
||||
const Layout *old_layout, const char *new_symbol,
|
||||
const Layout *new_layout);
|
||||
|
||||
/**
|
||||
* Send a monitor_focus_change_event to all subscribers. Should be called only
|
||||
* when the monitor focus changes.
|
||||
*
|
||||
* @param last_mon_num The index of the previously selected monitor
|
||||
* @param new_mon_num The index of the newly selected monitor
|
||||
*/
|
||||
void ipc_monitor_focus_change_event(const int last_mon_num,
|
||||
const int new_mon_num);
|
||||
|
||||
/**
|
||||
* Send a focused_title_change_event to all subscribers. Should only be called
|
||||
* if a selected client has a title change.
|
||||
*
|
||||
* @param mon_num Index of the client's monitor
|
||||
* @param client_id Window XID of client
|
||||
* @param old_name Old name of the client window
|
||||
* @param new_name New name of the client window
|
||||
*/
|
||||
void ipc_focused_title_change_event(const int mon_num, const Window client_id,
|
||||
const char *old_name, const char *new_name);
|
||||
|
||||
/**
|
||||
* Send a focused_state_change_event to all subscribers. Should only be called
|
||||
* if a selected client has a state change.
|
||||
*
|
||||
* @param mon_num Index of the client's monitor
|
||||
* @param client_id Window XID of client
|
||||
* @param old_state Old state of the client
|
||||
* @param new_state New state of the client
|
||||
*/
|
||||
void ipc_focused_state_change_event(const int mon_num, const Window client_id,
|
||||
const ClientState *old_state,
|
||||
const ClientState *new_state);
|
||||
/**
|
||||
* Check to see if an event has occured and call the *_change_event functions
|
||||
* accordingly
|
||||
*
|
||||
* @param mons Address of Monitor pointing to start of linked list
|
||||
* @param lastselmon Address of pointer to previously selected monitor
|
||||
* @param selmon Address of selected Monitor
|
||||
*/
|
||||
void ipc_send_events(Monitor *mons, Monitor **lastselmon, Monitor *selmon);
|
||||
|
||||
/**
|
||||
* Handle an epoll event caused by a registered IPC client. Read, process, and
|
||||
* handle any received messages from clients. Write pending buffer to client if
|
||||
* the client is ready to receive messages. Drop clients that have sent an
|
||||
* EPOLLHUP.
|
||||
*
|
||||
* @param ev Associated epoll event returned by epoll_wait
|
||||
* @param mons Address of Monitor pointing to start of linked list
|
||||
* @param selmon Address of selected Monitor
|
||||
* @param lastselmon Address of pointer to previously selected monitor
|
||||
* @param tags Array of tag names
|
||||
* @param tags_len Length of tags array
|
||||
* @param layouts Array of available layouts
|
||||
* @param layouts_len Length of layouts array
|
||||
*
|
||||
* @return 0 if event was successfully handled, -1 on any error receiving
|
||||
* or handling incoming messages or unhandled epoll event.
|
||||
*/
|
||||
int ipc_handle_client_epoll_event(struct epoll_event *ev, Monitor *mons,
|
||||
Monitor **lastselmon, Monitor *selmon,
|
||||
const char *tags[], const int tags_len,
|
||||
const Layout *layouts, const int layouts_len);
|
||||
|
||||
/**
|
||||
* Handle an epoll event caused by the IPC socket. This function only handles an
|
||||
* EPOLLIN event indicating a new client requesting to connect to the socket.
|
||||
*
|
||||
* @param ev Associated epoll event returned by epoll_wait
|
||||
*
|
||||
* @return 0, if the event was successfully handled, -1 if not an EPOLLIN event
|
||||
* or if a new IPC client connection request could not be accepted.
|
||||
*/
|
||||
int ipc_handle_socket_epoll_event(struct epoll_event *ev);
|
||||
|
||||
#endif /* IPC_H_ */
|
||||
121
KleinDwm/source/keys.h
Normal file
121
KleinDwm/source/keys.h
Normal file
@@ -0,0 +1,121 @@
|
||||
#include "layouts.h"
|
||||
#include "movestack.c"
|
||||
#include <X11/XF86keysym.h>
|
||||
|
||||
#define TERMINAL "alacritty" // default terminal
|
||||
|
||||
/* key definitions */
|
||||
#define MODKEY Mod4Mask
|
||||
#define ALTMOD Mod1Mask
|
||||
#define TAGKEYS(CHAIN,KEY,TAG) \
|
||||
{ MODKEY, CHAIN, KEY, view, {.ui = 1 << TAG} }, \
|
||||
{ MODKEY|ControlMask, CHAIN, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||
{ MODKEY|ShiftMask, CHAIN, KEY, tag, {.ui = 1 << TAG} }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, CHAIN, KEY, toggletag, {.ui = 1 << TAG} }, \
|
||||
{ ALTMOD, CHAIN, KEY, focusnthmon, {.i = TAG } }, \
|
||||
{ ALTMOD|ShiftMask, CHAIN, KEY, tagnthmon, {.i = TAG } },
|
||||
|
||||
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||
|
||||
/* commands */
|
||||
static const char dmenufont[] = "monospace:size=10";
|
||||
static const char *dmenucmd[] = { "dmenu_run", "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
||||
static const char *termcmd[] = { TERMINAL, NULL };
|
||||
|
||||
|
||||
/* brightness control */
|
||||
static const char *inc_light[] = { "brightness", "-a", "up", NULL};
|
||||
static const char *dec_light[] = { "brightness", "-a", "down", NULL };
|
||||
|
||||
/*xrandr control gui wrapper*/
|
||||
static const char *xrandrwrap[] = { "xrandrwrap", NULL };
|
||||
/* screenshot command */
|
||||
static const char *scrotselcmd[] = { "scrot", "-s", "/home/klein/Pictures/screenshots/Screenshot_%Y-%m-%d_%H-%M-%S.png", NULL };
|
||||
|
||||
/* volume controls */
|
||||
// Set up volume controls with amixer, and volumeicon. Without preset keys volumeicon will take over (provided constantly running)
|
||||
// Do not add keys for XF86XK_AudioRaiseVolume, XF86XKK_AudioLowerVolume, or XF86KX_AudiotMute.
|
||||
/* nvim */
|
||||
static const char *nvimcmd[] = { TERMINAL, "-e", "nvim", "vimwiki/index.md", NULL };
|
||||
|
||||
|
||||
static const Key keys[] = {
|
||||
/* modifier chain key key function argument */
|
||||
{ MODKEY, -1, XK_p, spawn, {.v = dmenucmd } },
|
||||
{ MODKEY|ShiftMask, -1, XK_Return, spawn, {.v = termcmd } },
|
||||
{ MODKEY|ShiftMask, -1, XK_b, togglebar, {0} },
|
||||
{ MODKEY, -1, XK_j, focusstack, {.i = +1 } },
|
||||
{ MODKEY, -1, XK_k, focusstack, {.i = -1 } },
|
||||
{ MODKEY, -1, XK_i, incnmaster, {.i = +1 } },
|
||||
{ MODKEY, -1, XK_d, incnmaster, {.i = -1 } },
|
||||
{ MODKEY|ShiftMask, -1, XK_x, movestack, {.i = +1 } },
|
||||
{ MODKEY|ShiftMask, -1, XK_z, movestack, {.i = -1 } },
|
||||
{ MODKEY, -1, XK_h, setmfact, {.f = -0.05} },
|
||||
{ MODKEY, -1, XK_l, setmfact, {.f = +0.05} },
|
||||
{ MODKEY, -1, XK_Return, zoom, {0} },
|
||||
{ MODKEY, -1, XK_Tab, view, {0} },
|
||||
|
||||
{ MODKEY|ShiftMask, -1, XK_c, killclient, {0} },
|
||||
|
||||
{ MODKEY, -1, XK_t, setlayout, { .v = &layouts[0] } },
|
||||
{ MODKEY, -1, XK_f, setlayout, {.v = &layouts[1]} },
|
||||
{ MODKEY, -1, XK_m, setlayout, {.v = &layouts[2]} },
|
||||
{ MODKEY, -1, XK_r, setlayout, {.v = &layouts[3]} },
|
||||
{ MODKEY|ShiftMask, -1, XK_r, setlayout, {.v = &layouts[4]} },
|
||||
{ MODKEY, -1, XK_space, setlayout, {0} },
|
||||
|
||||
{ MODKEY|ShiftMask, -1, XK_space, togglefloating, {0} },
|
||||
{ MODKEY, -1, XK_0, view, {.ui = ~0 } },
|
||||
{ MODKEY|ShiftMask, -1, XK_0, tag, {.ui = ~0 } },
|
||||
{ MODKEY, -1, XK_comma, focusmon, {.i = -1 } },
|
||||
{ MODKEY, -1, XK_period, focusmon, {.i = +1 } },
|
||||
{ MODKEY|ShiftMask, -1, XK_comma, tagmon, {.i = -1 } },
|
||||
{ MODKEY|ShiftMask, -1, XK_period, tagmon, {.i = +1 } },
|
||||
//--//
|
||||
|
||||
{ MODKEY, XK_c, XK_o, spawn, SHCMD("xdotool key Super_L+2 && dissent") },
|
||||
{ MODKEY, XK_c, XK_q, spawn, SHCMD("xdotool key Super_L+2 && qtox") },
|
||||
{ MODKEY, XK_c, XK_b, spawn, SHCMD("xdotool key Super_L+3 && qutebrowser") },
|
||||
{ MODKEY, XK_c, XK_f, spawn, SHCMD("xdotool key Super_L+4 && freetube") },
|
||||
{ MODKEY, XK_c, XK_g, spawn, SHCMD("xdotool key Super_L+5 && qutebrowser github.com") },
|
||||
{ MODKEY, XK_c, XK_n, spawn, SHCMD("xdotool key Super_L+7 && nvim") },
|
||||
{ MODKEY, XK_c, XK_s, spawn, SHCMD("xdotool key Super_L+8 && spotube") },
|
||||
{ MODKEY, XK_c, XK_z, spawn, SHCMD("xdotool key Super_L+9 && alacritty") },
|
||||
{ MODKEY, XK_n, XK_v, spawn, {.v = nvimcmd } },
|
||||
|
||||
TAGKEYS( -1, XK_1, 0)
|
||||
TAGKEYS( -1, XK_2, 1)
|
||||
TAGKEYS( -1, XK_3, 2)
|
||||
TAGKEYS( -1, XK_4, 3)
|
||||
TAGKEYS( -1, XK_5, 4)
|
||||
TAGKEYS( -1, XK_6, 5)
|
||||
TAGKEYS( -1, XK_7, 6)
|
||||
TAGKEYS( -1, XK_8, 7)
|
||||
TAGKEYS( -1, XK_9, 8)
|
||||
|
||||
{ MODKEY|ShiftMask, -1, XK_q, quit, {0} },
|
||||
{ MODKEY|ControlMask|ShiftMask, -1, XK_r, quit, {1} }, // restart
|
||||
|
||||
{ 0, -1, XK_F10, spawn, { .v = scrotselcmd } },
|
||||
{ 0, -1, XF86XK_MonBrightnessUp, spawn, { .v = inc_light } },
|
||||
{ 0, -1, XF86XK_MonBrightnessDown, spawn, { .v = dec_light } },
|
||||
{ 0, -1, XK_F8, spawn, { .v = xrandrwrap } },
|
||||
};
|
||||
|
||||
/* button definitions */
|
||||
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
|
||||
static const Button buttons[] = {
|
||||
/* click event mask button function argument */
|
||||
{ ClkTagBar, MODKEY, Button1, tag, {0} },
|
||||
{ ClkTagBar, MODKEY, Button3, toggletag, {0} },
|
||||
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
||||
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
|
||||
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
||||
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
||||
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
||||
{ ClkTagBar, 0, Button1, view, {0} },
|
||||
{ ClkTagBar, 0, Button3, toggleview, {0} },
|
||||
{ ClkTagBar, MODKEY, Button1, tag, {0} },
|
||||
{ ClkTagBar, MODKEY, Button3, toggletag, {0} },
|
||||
};
|
||||
20
KleinDwm/source/layouts.h
Normal file
20
KleinDwm/source/layouts.h
Normal file
@@ -0,0 +1,20 @@
|
||||
/* 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 = 0; /* 1 will force focus on the fullscreen window */
|
||||
|
||||
#include "fibonacci.c"
|
||||
static const Layout layouts[] = {
|
||||
/* symbol arrange function */
|
||||
{ "[]=", tile }, /* first entry is default */
|
||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||
{ "[M]", monocle },
|
||||
{ "[@]", spiral },
|
||||
{ "[\\]", dwindle },
|
||||
};
|
||||
/* custom symbols for nr. of clients in monocle layout */
|
||||
/* when clients >= LENGTH(monocles), uses the last element */
|
||||
static const char *monocles[] = { "[1]", "[2]", "[3]", "[4]", "[5]", "[6]", "[7]", "[8]", "[9]", "[9+]" };
|
||||
|
||||
|
||||
48
KleinDwm/source/movestack.c
Normal file
48
KleinDwm/source/movestack.c
Normal file
@@ -0,0 +1,48 @@
|
||||
void
|
||||
movestack(const Arg *arg) {
|
||||
Client *c = NULL, *p = NULL, *pc = NULL, *i;
|
||||
|
||||
if(arg->i > 0) {
|
||||
/* find the client after selmon->sel */
|
||||
for(c = selmon->sel->next; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
|
||||
if(!c)
|
||||
for(c = selmon->clients; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
|
||||
|
||||
}
|
||||
else {
|
||||
/* find the client before selmon->sel */
|
||||
for(i = selmon->clients; i != selmon->sel; i = i->next)
|
||||
if(ISVISIBLE(i) && !i->isfloating)
|
||||
c = i;
|
||||
if(!c)
|
||||
for(; i; i = i->next)
|
||||
if(ISVISIBLE(i) && !i->isfloating)
|
||||
c = i;
|
||||
}
|
||||
/* find the client before selmon->sel and c */
|
||||
for(i = selmon->clients; i && (!p || !pc); i = i->next) {
|
||||
if(i->next == selmon->sel)
|
||||
p = i;
|
||||
if(i->next == c)
|
||||
pc = i;
|
||||
}
|
||||
|
||||
/* swap c and selmon->sel selmon->clients in the selmon->clients list */
|
||||
if(c && c != selmon->sel) {
|
||||
Client *temp = selmon->sel->next==c?selmon->sel:selmon->sel->next;
|
||||
selmon->sel->next = c->next==selmon->sel?c:c->next;
|
||||
c->next = temp;
|
||||
|
||||
if(p && p != c)
|
||||
p->next = c;
|
||||
if(pc && pc != selmon->sel)
|
||||
pc->next = selmon->sel;
|
||||
|
||||
if(selmon->sel == selmon->clients)
|
||||
selmon->clients = c;
|
||||
else if(c == selmon->clients)
|
||||
selmon->clients = selmon->sel;
|
||||
|
||||
arrange(selmon);
|
||||
}
|
||||
}
|
||||
103
KleinDwm/source/patches/README.md
Normal file
103
KleinDwm/source/patches/README.md
Normal file
@@ -0,0 +1,103 @@
|
||||
## patches that I used on dwm
|
||||
|
||||
### [autosart](https://dwm.suckless.org/patches/autostart/)
|
||||
This patch allows programs to autostart when you login to dwm.
|
||||
you can create autostart.sh file on the following directories:
|
||||
1. $HOME/.dwm
|
||||
2. $HOME/.local/share/dwm
|
||||
3. $XDG_DATA_HOME/dwm
|
||||
|
||||
### [alwayscenter](https://dwm.suckless.org/patches/alwayscenter/)
|
||||
This patch make all floating windows are centered.
|
||||
|
||||
### [bar-height-spacing](https://dwm.suckless.org/patches/bar_height/)
|
||||
This patch allows you to change dwm's default bar height.
|
||||
```c
|
||||
static const int user_bh = 0;
|
||||
```
|
||||
### [fakefullscreen](https://dwm.suckless.org/patches/fakefullscreen/)
|
||||
This patch enables fullscreen on a small secondary screen while having other windows.
|
||||
|
||||

|
||||
|
||||
### [fullgabs](https://dwm.suckless.org/patches/fullgaps/)
|
||||
This patch adds gaps between client windows.
|
||||
```c
|
||||
static const unsigned int gappx = 5; /* gaps between windows */
|
||||
```
|
||||
|
||||
### [keychain](https://dwm.suckless.org/patches/keychain/)
|
||||
This patch allows you to chain multiple key bindings together. for example Mod+a+t to open alacritty terminal.
|
||||
```c
|
||||
static const Key keys[] = {
|
||||
/* modifier chain key key function argument */
|
||||
{ MODKEY, XK_a, XK_t, spawn, SHCMD("alacritty") },
|
||||
}
|
||||
```
|
||||
### [movestack](https://dwm.suckless.org/patches/movestack/)
|
||||
This patch allows you to move clients around in the stack and swap them with the main window by include movestack.c source file and add keys for swapping.
|
||||
```c
|
||||
#include "movestack.c"
|
||||
static const Key keys[] = {
|
||||
{ ShiftMask, -1, XK_x, movestack, {.i = +1 } },
|
||||
{ ShiftMask, -1, XK_z, movestack, {.i = -1 } },
|
||||
}
|
||||
```
|
||||
|
||||
### [pertag](https://dwm.suckless.org/patches/pertag/)
|
||||
This patch keeps layout, mwfact, barpos and nmaster per tag.
|
||||
|
||||
### [raimbowtags](https://dwm.suckless.org/patches/rainbowtags/)
|
||||
Allows each tag to be an independent colour when selected.
|
||||
```c
|
||||
static const char tag1[] = "#939393";
|
||||
static const char tag2[] = "#5865F2";
|
||||
static const char tag3[] = "#FF5500";
|
||||
static const char tag4[] = "#FF609A";
|
||||
static const char tag5[] = "#842291";
|
||||
static const char tag6[] = "#900C3F";
|
||||
static const char tag7[] = "#67AFA5";
|
||||
static const char tag8[] = "#1DB954";
|
||||
static const char tag9[] = "#FFFFFF";
|
||||
|
||||
static const char *tagsel[][2] = {
|
||||
{ tag1, col_gray1 },
|
||||
{ tag2, col_gray1 },
|
||||
{ tag3, col_gray1 },
|
||||
{ tag4, col_gray1 },
|
||||
{ tag5, col_gray1 },
|
||||
{ tag6, col_gray1 },
|
||||
{ tag7, col_gray1 },
|
||||
{ tag8, col_gray1 },
|
||||
{ tag9, col_gray1 },
|
||||
};
|
||||
```
|
||||
|
||||
### [resarting](https://dwm.suckless.org/patches/restartsig/)
|
||||
This patch allows you to restart dwm.
|
||||
|
||||
### [status2d-systray](https://dwm.suckless.org/patches/status2d/)
|
||||
This patch allows colors in your dwm status bar with system tray implementation.
|
||||
|
||||
### [titlecolor](https://dwm.suckless.org/patches/titlecolor/)
|
||||
This patch adds a new color scheme used by the window title in the bar.
|
||||
```c
|
||||
static const char *colors[][3] = {
|
||||
[SchemeTitle] = { col_gray4, col_cyan, col_cyan },
|
||||
}
|
||||
```
|
||||
|
||||
### [urg-border](https://dwm.suckless.org/patches/urgentborder/)
|
||||
This patch makes borders of urgent windows a different color.
|
||||
|
||||
```c
|
||||
static const char col_urgborder[] = "#ff0000";
|
||||
static const char *colors[][3] = {
|
||||
[SchemeUrg] = { col_gray4, col_cyan, col_urgborder },
|
||||
}
|
||||
```
|
||||
|
||||
### [winicon](https://dwm.suckless.org/patches/winicon/)
|
||||
This patch enables dwm to show window icons.
|
||||
|
||||

|
||||
100
KleinDwm/source/patches/accessnthmon.diff
Normal file
100
KleinDwm/source/patches/accessnthmon.diff
Normal file
@@ -0,0 +1,100 @@
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 1c0b587..8595a71 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -49,7 +49,10 @@ static const Layout layouts[] = {
|
||||
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||
{ MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
|
||||
- { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
|
||||
+ { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, \
|
||||
+ { ALTMOD, KEY, focusnthmon, {.i = TAG } }, \
|
||||
+ { ALTMOD|ShiftMask, KEY, tagnthmon, {.i = TAG } },
|
||||
+
|
||||
|
||||
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index b0b3466..96fa0bd 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -161,6 +161,7 @@ static void destroynotify(XEvent *e);
|
||||
static void detach(Client *c);
|
||||
static void detachstack(Client *c);
|
||||
static Monitor *dirtomon(int dir);
|
||||
+static Monitor *numtomon(int num);
|
||||
static void drawbar(Monitor *m);
|
||||
static void drawbars(void);
|
||||
static void enternotify(XEvent *e);
|
||||
@@ -168,6 +169,7 @@ static void expose(XEvent *e);
|
||||
static void focus(Client *c);
|
||||
static void focusin(XEvent *e);
|
||||
static void focusmon(const Arg *arg);
|
||||
+static void focusnthmon(const Arg *arg);
|
||||
static void focusstack(const Arg *arg);
|
||||
static Atom getatomprop(Client *c, Atom prop);
|
||||
static int getrootptr(int *x, int *y);
|
||||
@@ -209,6 +211,7 @@ static void sigchld(int unused);
|
||||
static void spawn(const Arg *arg);
|
||||
static void tag(const Arg *arg);
|
||||
static void tagmon(const Arg *arg);
|
||||
+static void tagnthmon(const Arg *arg);
|
||||
static void tile(Monitor *);
|
||||
static void togglebar(const Arg *arg);
|
||||
static void togglefloating(const Arg *arg);
|
||||
@@ -693,6 +696,18 @@ dirtomon(int dir)
|
||||
return m;
|
||||
}
|
||||
|
||||
+Monitor *
|
||||
+numtomon(int num)
|
||||
+{
|
||||
+ Monitor *m = NULL;
|
||||
+ int i = 0;
|
||||
+
|
||||
+ for(m = mons, i=0; m->next && i < num; m = m->next){
|
||||
+ i++;
|
||||
+ }
|
||||
+ return m;
|
||||
+}
|
||||
+
|
||||
void
|
||||
drawbar(Monitor *m)
|
||||
{
|
||||
@@ -830,6 +845,21 @@ focusmon(const Arg *arg)
|
||||
focus(NULL);
|
||||
}
|
||||
|
||||
+void
|
||||
+focusnthmon(const Arg *arg)
|
||||
+{
|
||||
+ Monitor *m;
|
||||
+
|
||||
+ if (!mons->next)
|
||||
+ return;
|
||||
+
|
||||
+ if ((m = numtomon(arg->i)) == selmon)
|
||||
+ return;
|
||||
+ unfocus(selmon->sel, 0);
|
||||
+ selmon = m;
|
||||
+ focus(NULL);
|
||||
+}
|
||||
+
|
||||
void
|
||||
focusstack(const Arg *arg)
|
||||
{
|
||||
@@ -1671,6 +1701,14 @@ tagmon(const Arg *arg)
|
||||
sendmon(selmon->sel, dirtomon(arg->i));
|
||||
}
|
||||
|
||||
+void
|
||||
+tagnthmon(const Arg *arg)
|
||||
+{
|
||||
+ if (!selmon->sel || !mons->next)
|
||||
+ return;
|
||||
+ sendmon(selmon->sel, numtomon(arg->i));
|
||||
+}
|
||||
+
|
||||
void
|
||||
tile(Monitor *m)
|
||||
{
|
||||
56
KleinDwm/source/patches/dwm-6.2-urg-border.diff
Normal file
56
KleinDwm/source/patches/dwm-6.2-urg-border.diff
Normal file
@@ -0,0 +1,56 @@
|
||||
From f20e5593e154e7e46c3f7100bd1378c7844b5ec8 Mon Sep 17 00:00:00 2001
|
||||
From: Dirk Leichsenring <dlei@reddott.de>
|
||||
Date: Sun, 21 Jun 2020 14:00:40 +0200
|
||||
Subject: [PATCH] Make the borders of urgent windows a different color - for dwm 6.2
|
||||
|
||||
---
|
||||
config.def.h | 2 ++
|
||||
dwm.c | 7 +++++--
|
||||
2 files changed, 7 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 1c0b587..1cb4492 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -12,10 +12,12 @@ static const char col_gray2[] = "#444444";
|
||||
static const char col_gray3[] = "#bbbbbb";
|
||||
static const char col_gray4[] = "#eeeeee";
|
||||
static const char col_cyan[] = "#005577";
|
||||
+static const char col_urgborder[] = "#ff0000";
|
||||
static const char *colors[][3] = {
|
||||
/* fg bg border */
|
||||
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
||||
+ [SchemeUrg] = { col_gray4, col_cyan, col_urgborder },
|
||||
};
|
||||
|
||||
/* tagging */
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 4465af1..fda4013 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -59,7 +59,7 @@
|
||||
|
||||
/* enums */
|
||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||
-enum { SchemeNorm, SchemeSel }; /* color schemes */
|
||||
+enum { SchemeNorm, SchemeSel, SchemeUrg }; /* color schemes */
|
||||
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
||||
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
||||
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
|
||||
@@ -2022,8 +2022,11 @@ updatewmhints(Client *c)
|
||||
if (c == selmon->sel && wmh->flags & XUrgencyHint) {
|
||||
wmh->flags &= ~XUrgencyHint;
|
||||
XSetWMHints(dpy, c->win, wmh);
|
||||
- } else
|
||||
+ } else {
|
||||
c->isurgent = (wmh->flags & XUrgencyHint) ? 1 : 0;
|
||||
+ if (c->isurgent)
|
||||
+ XSetWindowBorder(dpy, c->win, scheme[SchemeUrg][ColBorder].pixel);
|
||||
+ }
|
||||
if (wmh->flags & InputHint)
|
||||
c->neverfocus = !wmh->input;
|
||||
else
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
diff -up dwm/dwm.c dwmmod/dwm.c
|
||||
--- dwm/dwm.c 2020-06-25 00:21:30.383692180 -0300
|
||||
+++ dwmmod/dwm.c 2020-06-25 00:20:35.643692330 -0300
|
||||
@@ -1057,6 +1057,8 @@ manage(Window w, XWindowAttributes *wa)
|
||||
updatewindowtype(c);
|
||||
updatesizehints(c);
|
||||
updatewmhints(c);
|
||||
+ c->x = c->mon->mx + (c->mon->mw - WIDTH(c)) / 2;
|
||||
+ c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2;
|
||||
XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
|
||||
grabbuttons(c, 0);
|
||||
if (!c->isfloating)
|
||||
179
KleinDwm/source/patches/dwm-autostart-20210120-cb3f58a.diff
Normal file
179
KleinDwm/source/patches/dwm-autostart-20210120-cb3f58a.diff
Normal file
@@ -0,0 +1,179 @@
|
||||
From 37e970479dc5d40e57fc0cbfeaa5e39941483237 Mon Sep 17 00:00:00 2001
|
||||
From: Gan Ainm <gan.ainm.riomhphost@gmail.com>
|
||||
Date: Wed, 10 Jun 2020 10:59:02 +0000
|
||||
Subject: [PATCH] dwm-xdgautostart-6.2.diff
|
||||
|
||||
===================================================================
|
||||
---
|
||||
dwm.1 | 23 +++++++++++++++++
|
||||
dwm.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 105 insertions(+)
|
||||
|
||||
diff --git a/dwm.1 b/dwm.1
|
||||
index 13b3729..9533aa6 100644
|
||||
--- a/dwm.1
|
||||
+++ b/dwm.1
|
||||
@@ -30,6 +30,14 @@ top left corner. The tags which are applied to one or more windows are
|
||||
indicated with an empty square in the top left corner.
|
||||
.P
|
||||
dwm draws a small border around windows to indicate the focus state.
|
||||
+.P
|
||||
+On start, dwm can start additional programs that may be specified in two special
|
||||
+shell scripts (see the FILES section below), autostart_blocking.sh and
|
||||
+autostart.sh. The former is executed first and dwm will wait for its
|
||||
+termination before starting. The latter is executed in the background before
|
||||
+dwm enters its handler loop.
|
||||
+.P
|
||||
+Either of these files may be omitted.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-v
|
||||
@@ -152,6 +160,21 @@ Toggles focused window between floating and tiled state.
|
||||
.TP
|
||||
.B Mod1\-Button3
|
||||
Resize focused window while dragging. Tiled windows will be toggled to the floating state.
|
||||
+.SH FILES
|
||||
+The files containing programs to be started along with dwm are searched for in
|
||||
+the following directories:
|
||||
+.IP "1. $XDG_DATA_HOME/dwm"
|
||||
+.IP "2. $HOME/.local/share/dwm"
|
||||
+.IP "3. $HOME/.dwm"
|
||||
+.P
|
||||
+The first existing directory is scanned for any of the autostart files below.
|
||||
+.TP 15
|
||||
+autostart.sh
|
||||
+This file is started as a shell background process before dwm enters its handler
|
||||
+loop.
|
||||
+.TP 15
|
||||
+autostart_blocking.sh
|
||||
+This file is started before any autostart.sh; dwm waits for its termination.
|
||||
.SH CUSTOMIZATION
|
||||
dwm is customized by creating a custom config.h and (re)compiling the source
|
||||
code. This keeps it fast, secure and simple.
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 4465af1..2156b49 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
+#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <X11/cursorfont.h>
|
||||
#include <X11/keysym.h>
|
||||
@@ -193,6 +194,7 @@ static void resizeclient(Client *c, int x, int y, int w, int h);
|
||||
static void resizemouse(const Arg *arg);
|
||||
static void restack(Monitor *m);
|
||||
static void run(void);
|
||||
+static void runautostart(void);
|
||||
static void scan(void);
|
||||
static int sendevent(Client *c, Atom proto);
|
||||
static void sendmon(Client *c, Monitor *m);
|
||||
@@ -235,7 +237,11 @@ static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||
static void zoom(const Arg *arg);
|
||||
|
||||
/* variables */
|
||||
+static const char autostartblocksh[] = "autostart_blocking.sh";
|
||||
+static const char autostartsh[] = "autostart.sh";
|
||||
static const char broken[] = "broken";
|
||||
+static const char dwmdir[] = "dwm";
|
||||
+static const char localshare[] = ".local/share";
|
||||
static char stext[256];
|
||||
static int screen;
|
||||
static int sw, sh; /* X display screen geometry width, height */
|
||||
@@ -1380,6 +1386,83 @@ run(void)
|
||||
handler[ev.type](&ev); /* call handler */
|
||||
}
|
||||
|
||||
+void
|
||||
+runautostart(void)
|
||||
+{
|
||||
+ char *pathpfx;
|
||||
+ char *path;
|
||||
+ char *xdgdatahome;
|
||||
+ char *home;
|
||||
+ struct stat sb;
|
||||
+
|
||||
+ if ((home = getenv("HOME")) == NULL)
|
||||
+ /* this is almost impossible */
|
||||
+ return;
|
||||
+
|
||||
+ /* if $XDG_DATA_HOME is set and not empty, use $XDG_DATA_HOME/dwm,
|
||||
+ * otherwise use ~/.local/share/dwm as autostart script directory
|
||||
+ */
|
||||
+ xdgdatahome = getenv("XDG_DATA_HOME");
|
||||
+ if (xdgdatahome != NULL && *xdgdatahome != '\0') {
|
||||
+ /* space for path segments, separators and nul */
|
||||
+ pathpfx = ecalloc(1, strlen(xdgdatahome) + strlen(dwmdir) + 2);
|
||||
+
|
||||
+ if (sprintf(pathpfx, "%s/%s", xdgdatahome, dwmdir) <= 0) {
|
||||
+ free(pathpfx);
|
||||
+ return;
|
||||
+ }
|
||||
+ } else {
|
||||
+ /* space for path segments, separators and nul */
|
||||
+ pathpfx = ecalloc(1, strlen(home) + strlen(localshare)
|
||||
+ + strlen(dwmdir) + 3);
|
||||
+
|
||||
+ if (sprintf(pathpfx, "%s/%s/%s", home, localshare, dwmdir) < 0) {
|
||||
+ free(pathpfx);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* check if the autostart script directory exists */
|
||||
+ if (! (stat(pathpfx, &sb) == 0 && S_ISDIR(sb.st_mode))) {
|
||||
+ /* the XDG conformant path does not exist or is no directory
|
||||
+ * so we try ~/.dwm instead
|
||||
+ */
|
||||
+ char *pathpfx_new = realloc(pathpfx, strlen(home) + strlen(dwmdir) + 3);
|
||||
+ if(pathpfx_new == NULL) {
|
||||
+ free(pathpfx);
|
||||
+ return;
|
||||
+ }
|
||||
+ pathpfx = pathpfx_new;
|
||||
+
|
||||
+ if (sprintf(pathpfx, "%s/.%s", home, dwmdir) <= 0) {
|
||||
+ free(pathpfx);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* try the blocking script first */
|
||||
+ path = ecalloc(1, strlen(pathpfx) + strlen(autostartblocksh) + 2);
|
||||
+ if (sprintf(path, "%s/%s", pathpfx, autostartblocksh) <= 0) {
|
||||
+ free(path);
|
||||
+ free(pathpfx);
|
||||
+ }
|
||||
+
|
||||
+ if (access(path, X_OK) == 0)
|
||||
+ system(path);
|
||||
+
|
||||
+ /* now the non-blocking script */
|
||||
+ if (sprintf(path, "%s/%s", pathpfx, autostartsh) <= 0) {
|
||||
+ free(path);
|
||||
+ free(pathpfx);
|
||||
+ }
|
||||
+
|
||||
+ if (access(path, X_OK) == 0)
|
||||
+ system(strcat(path, " &"));
|
||||
+
|
||||
+ free(pathpfx);
|
||||
+ free(path);
|
||||
+}
|
||||
+
|
||||
void
|
||||
scan(void)
|
||||
{
|
||||
@@ -2142,6 +2223,7 @@ main(int argc, char *argv[])
|
||||
die("pledge");
|
||||
#endif /* __OpenBSD__ */
|
||||
scan();
|
||||
+ runautostart();
|
||||
run();
|
||||
cleanup();
|
||||
XCloseDisplay(dpy);
|
||||
--
|
||||
2.27.0
|
||||
|
||||
25
KleinDwm/source/patches/dwm-bar-height-spacing-6.3.diff
Normal file
25
KleinDwm/source/patches/dwm-bar-height-spacing-6.3.diff
Normal file
@@ -0,0 +1,25 @@
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 1c0b587..9814500 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -5,6 +5,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||
static const unsigned int snap = 32; /* snap pixel */
|
||||
static const int showbar = 1; /* 0 means no bar */
|
||||
static const int topbar = 1; /* 0 means bottom bar */
|
||||
+static const int user_bh = 2; /* 2 is the default spacing around the bar's font */
|
||||
static const char *fonts[] = { "monospace:size=10" };
|
||||
static const char dmenufont[] = "monospace:size=10";
|
||||
static const char col_gray1[] = "#222222";
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 4465af1..2c27cb3 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -1545,7 +1545,7 @@ setup(void)
|
||||
if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
|
||||
die("no fonts could be loaded.");
|
||||
lrpad = drw->fonts->h;
|
||||
- bh = drw->fonts->h + 2;
|
||||
+ bh = drw->fonts->h + user_bh;
|
||||
updategeom();
|
||||
/* init atoms */
|
||||
utf8string = XInternAtom(dpy, "UTF8_STRING", False);
|
||||
67
KleinDwm/source/patches/dwm-centerfirstwindow-6.2.diff
Normal file
67
KleinDwm/source/patches/dwm-centerfirstwindow-6.2.diff
Normal file
@@ -0,0 +1,67 @@
|
||||
diff -up dwm-6.2-orig/config.def.h dwm-6.2-modd/config.def.h
|
||||
--- dwm-6.2-orig/config.def.h 2019-02-02 16:55:28.000000000 +0400
|
||||
+++ dwm-6.2-modd/config.def.h 2021-04-25 16:05:22.569759243 +0400
|
||||
@@ -26,9 +26,10 @@ static const Rule rules[] = {
|
||||
* WM_CLASS(STRING) = instance, class
|
||||
* WM_NAME(STRING) = title
|
||||
*/
|
||||
- /* class instance title tags mask isfloating monitor */
|
||||
- { "Gimp", NULL, NULL, 0, 1, -1 },
|
||||
- { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
|
||||
+ /* class instance title tags mask isfloating CenterThisWindow? monitor */
|
||||
+ { "st", NULL, NULL, 0, 0, 1, -1 },
|
||||
+ { "Gimp", NULL, NULL, 0, 1, 0, -1 },
|
||||
+ { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1 },
|
||||
};
|
||||
|
||||
/* layout(s) */
|
||||
diff -up dwm-6.2-orig/dwm.c dwm-6.2-modd/dwm.c
|
||||
--- dwm-6.2-orig/dwm.c 2019-02-02 16:55:28.000000000 +0400
|
||||
+++ dwm-6.2-modd/dwm.c 2021-04-25 16:06:15.368310756 +0400
|
||||
@@ -92,7 +92,7 @@ struct Client {
|
||||
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
||||
int bw, oldbw;
|
||||
unsigned int tags;
|
||||
- int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
|
||||
+ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, CenterThisWindow;
|
||||
Client *next;
|
||||
Client *snext;
|
||||
Monitor *mon;
|
||||
@@ -138,6 +138,7 @@ typedef struct {
|
||||
const char *title;
|
||||
unsigned int tags;
|
||||
int isfloating;
|
||||
+ int CenterThisWindow;
|
||||
int monitor;
|
||||
} Rule;
|
||||
|
||||
@@ -286,6 +287,7 @@ applyrules(Client *c)
|
||||
|
||||
/* rule matching */
|
||||
c->isfloating = 0;
|
||||
+ c->CenterThisWindow = 0;
|
||||
c->tags = 0;
|
||||
XGetClassHint(dpy, c->win, &ch);
|
||||
class = ch.res_class ? ch.res_class : broken;
|
||||
@@ -298,6 +300,7 @@ applyrules(Client *c)
|
||||
&& (!r->instance || strstr(instance, r->instance)))
|
||||
{
|
||||
c->isfloating = r->isfloating;
|
||||
+ c->CenterThisWindow = r->CenterThisWindow;
|
||||
c->tags |= r->tags;
|
||||
for (m = mons; m && m->num != r->monitor; m = m->next);
|
||||
if (m)
|
||||
@@ -1694,6 +1697,13 @@ tile(Monitor *m)
|
||||
resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
|
||||
ty += HEIGHT(c);
|
||||
}
|
||||
+
|
||||
+ if (n == 1 && selmon->sel->CenterThisWindow)
|
||||
+ resizeclient(selmon->sel,
|
||||
+ (selmon->mw - selmon->mw * 0.5) / 2,
|
||||
+ (selmon->mh - selmon->mh * 0.5) / 2,
|
||||
+ selmon->mw * 0.5,
|
||||
+ selmon->mh * 0.5);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -0,0 +1,41 @@
|
||||
From 630859138bb960e2aea41d47e68c48ec020daf5c Mon Sep 17 00:00:00 2001
|
||||
From: ben evolver <>
|
||||
Date: Sun, 17 Apr 2022 08:07:24 -0500
|
||||
Subject: [PATCH] add alternative symbols for nr. of active clients in monocle layout
|
||||
|
||||
---
|
||||
config.def.h | 4 ++++
|
||||
dwm.c | 2 +-
|
||||
2 files changed, 5 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index a2ac963..f49dfdf 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -44,6 +44,10 @@ static const Layout layouts[] = {
|
||||
{ "[M]", monocle },
|
||||
};
|
||||
|
||||
+/* custom symbols for nr. of clients in monocle layout */
|
||||
+/* when clients >= LENGTH(monocles), uses the last element */
|
||||
+static const char *monocles[] = { "[1]", "[2]", "[3]", "[4]", "[5]", "[6]", "[7]", "[8]", "[9]", "[9+]" };
|
||||
+
|
||||
/* key definitions */
|
||||
#define MODKEY Mod1Mask
|
||||
#define TAGKEYS(KEY,TAG) \
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 0fc328a..e47ba70 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -1116,7 +1116,7 @@ monocle(Monitor *m)
|
||||
if (ISVISIBLE(c))
|
||||
n++;
|
||||
if (n > 0) /* override layout symbol */
|
||||
- snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
|
||||
+ snprintf(m->ltsymbol, sizeof m->ltsymbol, "%s", monocles[MIN(n, LENGTH(monocles)) - 1]);
|
||||
for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
|
||||
resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
|
||||
}
|
||||
--
|
||||
2.35.1
|
||||
|
||||
120
KleinDwm/source/patches/dwm-fakefullscreen-20210714-138b405.diff
Normal file
120
KleinDwm/source/patches/dwm-fakefullscreen-20210714-138b405.diff
Normal file
@@ -0,0 +1,120 @@
|
||||
From 33c7811ca7280be7890851f5a83fa8d1a3313374 Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian LaVine <mail@smlavine.com>
|
||||
Date: Wed, 14 Jul 2021 11:22:34 -0400
|
||||
Subject: [PATCH] Set new lockfullscreen variable to 0
|
||||
|
||||
This more properly fixes the problem introduced by 67d76bd than the
|
||||
previous patch revision does.
|
||||
---
|
||||
config.def.h | 2 +-
|
||||
dwm.c | 28 ++--------------------------
|
||||
2 files changed, 3 insertions(+), 27 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index a2ac963..1b46cb4 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -35,7 +35,7 @@ static const Rule rules[] = {
|
||||
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 int lockfullscreen = 0; /* 1 will force focus on the fullscreen window */
|
||||
|
||||
static const Layout layouts[] = {
|
||||
/* symbol arrange function */
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 5e4d494..968e256 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -522,7 +522,7 @@ clientmessage(XEvent *e)
|
||||
if (cme->data.l[1] == netatom[NetWMFullscreen]
|
||||
|| cme->data.l[2] == netatom[NetWMFullscreen])
|
||||
setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */
|
||||
- || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen)));
|
||||
+ || cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */));
|
||||
} else if (cme->message_type == netatom[NetActiveWindow]) {
|
||||
if (c != selmon->sel && !c->isurgent)
|
||||
seturgent(c, 1);
|
||||
@@ -552,7 +552,6 @@ void
|
||||
configurenotify(XEvent *e)
|
||||
{
|
||||
Monitor *m;
|
||||
- Client *c;
|
||||
XConfigureEvent *ev = &e->xconfigure;
|
||||
int dirty;
|
||||
|
||||
@@ -565,9 +564,6 @@ configurenotify(XEvent *e)
|
||||
drw_resize(drw, sw, bh);
|
||||
updatebars();
|
||||
for (m = mons; m; m = m->next) {
|
||||
- for (c = m->clients; c; c = c->next)
|
||||
- if (c->isfullscreen)
|
||||
- resizeclient(c, m->mx, m->my, m->mw, m->mh);
|
||||
XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
|
||||
}
|
||||
focus(NULL);
|
||||
@@ -1144,8 +1140,6 @@ movemouse(const Arg *arg)
|
||||
|
||||
if (!(c = selmon->sel))
|
||||
return;
|
||||
- if (c->isfullscreen) /* no support moving fullscreen windows by mouse */
|
||||
- return;
|
||||
restack(selmon);
|
||||
ocx = c->x;
|
||||
ocy = c->y;
|
||||
@@ -1299,8 +1293,6 @@ resizemouse(const Arg *arg)
|
||||
|
||||
if (!(c = selmon->sel))
|
||||
return;
|
||||
- if (c->isfullscreen) /* no support resizing fullscreen windows by mouse */
|
||||
- return;
|
||||
restack(selmon);
|
||||
ocx = c->x;
|
||||
ocy = c->y;
|
||||
@@ -1477,24 +1469,10 @@ setfullscreen(Client *c, int fullscreen)
|
||||
XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
|
||||
PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
|
||||
c->isfullscreen = 1;
|
||||
- c->oldstate = c->isfloating;
|
||||
- c->oldbw = c->bw;
|
||||
- c->bw = 0;
|
||||
- c->isfloating = 1;
|
||||
- resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
|
||||
- XRaiseWindow(dpy, c->win);
|
||||
} else if (!fullscreen && c->isfullscreen){
|
||||
XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
|
||||
PropModeReplace, (unsigned char*)0, 0);
|
||||
c->isfullscreen = 0;
|
||||
- c->isfloating = c->oldstate;
|
||||
- c->bw = c->oldbw;
|
||||
- c->x = c->oldx;
|
||||
- c->y = c->oldy;
|
||||
- c->w = c->oldw;
|
||||
- c->h = c->oldh;
|
||||
- resizeclient(c, c->x, c->y, c->w, c->h);
|
||||
- arrange(c->mon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1619,7 +1597,7 @@ showhide(Client *c)
|
||||
if (ISVISIBLE(c)) {
|
||||
/* show clients top down */
|
||||
XMoveWindow(dpy, c->win, c->x, c->y);
|
||||
- if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
|
||||
+ if (!c->mon->lt[c->mon->sellt]->arrange || c->isfloating)
|
||||
resize(c, c->x, c->y, c->w, c->h, 0);
|
||||
showhide(c->snext);
|
||||
} else {
|
||||
@@ -1713,8 +1691,6 @@ togglefloating(const Arg *arg)
|
||||
{
|
||||
if (!selmon->sel)
|
||||
return;
|
||||
- if (selmon->sel->isfullscreen) /* no support for fullscreen windows */
|
||||
- return;
|
||||
selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed;
|
||||
if (selmon->sel->isfloating)
|
||||
resize(selmon->sel, selmon->sel->x, selmon->sel->y,
|
||||
--
|
||||
2.32.0
|
||||
|
||||
114
KleinDwm/source/patches/dwm-fibonacci-6.2.diff
Normal file
114
KleinDwm/source/patches/dwm-fibonacci-6.2.diff
Normal file
@@ -0,0 +1,114 @@
|
||||
From ec9f55b6005cfa3b025b3d700c61af3ce539d057 Mon Sep 17 00:00:00 2001
|
||||
From: Niki Yoshiuchi <nyoshiuchi@gmail.com>
|
||||
Date: Sat, 18 Apr 2020 09:55:26 -0700
|
||||
Subject: [PATCH] Adding the fibonacci layout patch
|
||||
|
||||
---
|
||||
config.def.h | 5 ++++
|
||||
fibonacci.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 71 insertions(+)
|
||||
create mode 100644 fibonacci.c
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 1c0b587..5708487 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -36,11 +36,14 @@ 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 */
|
||||
|
||||
+#include "fibonacci.c"
|
||||
static const Layout layouts[] = {
|
||||
/* symbol arrange function */
|
||||
{ "[]=", tile }, /* first entry is default */
|
||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||
{ "[M]", monocle },
|
||||
+ { "[@]", spiral },
|
||||
+ { "[\\]", dwindle },
|
||||
};
|
||||
|
||||
/* key definitions */
|
||||
@@ -76,6 +79,8 @@ static Key keys[] = {
|
||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||
+ { MODKEY, XK_r, setlayout, {.v = &layouts[3]} },
|
||||
+ { MODKEY|ShiftMask, XK_r, setlayout, {.v = &layouts[4]} },
|
||||
{ MODKEY, XK_space, setlayout, {0} },
|
||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
||||
diff --git a/fibonacci.c b/fibonacci.c
|
||||
new file mode 100644
|
||||
index 0000000..fce0a57
|
||||
--- /dev/null
|
||||
+++ b/fibonacci.c
|
||||
@@ -0,0 +1,66 @@
|
||||
+void
|
||||
+fibonacci(Monitor *mon, int s) {
|
||||
+ unsigned int i, n, nx, ny, nw, nh;
|
||||
+ Client *c;
|
||||
+
|
||||
+ for(n = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next), n++);
|
||||
+ if(n == 0)
|
||||
+ return;
|
||||
+
|
||||
+ nx = mon->wx;
|
||||
+ ny = 0;
|
||||
+ nw = mon->ww;
|
||||
+ nh = mon->wh;
|
||||
+
|
||||
+ for(i = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next)) {
|
||||
+ if((i % 2 && nh / 2 > 2 * c->bw)
|
||||
+ || (!(i % 2) && nw / 2 > 2 * c->bw)) {
|
||||
+ if(i < n - 1) {
|
||||
+ if(i % 2)
|
||||
+ nh /= 2;
|
||||
+ else
|
||||
+ nw /= 2;
|
||||
+ if((i % 4) == 2 && !s)
|
||||
+ nx += nw;
|
||||
+ else if((i % 4) == 3 && !s)
|
||||
+ ny += nh;
|
||||
+ }
|
||||
+ if((i % 4) == 0) {
|
||||
+ if(s)
|
||||
+ ny += nh;
|
||||
+ else
|
||||
+ ny -= nh;
|
||||
+ }
|
||||
+ else if((i % 4) == 1)
|
||||
+ nx += nw;
|
||||
+ else if((i % 4) == 2)
|
||||
+ ny += nh;
|
||||
+ else if((i % 4) == 3) {
|
||||
+ if(s)
|
||||
+ nx += nw;
|
||||
+ else
|
||||
+ nx -= nw;
|
||||
+ }
|
||||
+ if(i == 0)
|
||||
+ {
|
||||
+ if(n != 1)
|
||||
+ nw = mon->ww * mon->mfact;
|
||||
+ ny = mon->wy;
|
||||
+ }
|
||||
+ else if(i == 1)
|
||||
+ nw = mon->ww - nw;
|
||||
+ i++;
|
||||
+ }
|
||||
+ resize(c, nx, ny, nw - 2 * c->bw, nh - 2 * c->bw, False);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+dwindle(Monitor *mon) {
|
||||
+ fibonacci(mon, 1);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+spiral(Monitor *mon) {
|
||||
+ fibonacci(mon, 0);
|
||||
+}
|
||||
--
|
||||
2.20.1
|
||||
|
||||
138
KleinDwm/source/patches/dwm-fullgaps-20200508-7b77734.diff
Normal file
138
KleinDwm/source/patches/dwm-fullgaps-20200508-7b77734.diff
Normal file
@@ -0,0 +1,138 @@
|
||||
From 7b7773458c072e4b24d6ea32d0364a8e402e4a43 Mon Sep 17 00:00:00 2001
|
||||
From: swy7ch <swy7ch@protonmail.com>
|
||||
Date: Fri, 8 May 2020 19:07:24 +0200
|
||||
Subject: [PATCH] [PATCH] update dwm-fullgaps patch to be used with tile layout
|
||||
update
|
||||
|
||||
the recent tile layout changes in commit HEAD~1 (f09418b) broke the
|
||||
patch
|
||||
|
||||
this patch adapt the new `if` statements to take gaps into account
|
||||
|
||||
this patch also provides manpage entries for the keybindings
|
||||
---
|
||||
config.def.h | 4 ++++
|
||||
dwm.1 | 10 ++++++++++
|
||||
dwm.c | 33 +++++++++++++++++++++++----------
|
||||
3 files changed, 37 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 1c0b587..38d2f6c 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
/* appearance */
|
||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||
+static const unsigned int gappx = 5; /* gaps between windows */
|
||||
static const unsigned int snap = 32; /* snap pixel */
|
||||
static const int showbar = 1; /* 0 means no bar */
|
||||
static const int topbar = 1; /* 0 means bottom bar */
|
||||
@@ -84,6 +85,9 @@ static Key keys[] = {
|
||||
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
||||
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
||||
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
||||
+ { MODKEY, XK_minus, setgaps, {.i = -1 } },
|
||||
+ { MODKEY, XK_equal, setgaps, {.i = +1 } },
|
||||
+ { MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } },
|
||||
TAGKEYS( XK_1, 0)
|
||||
TAGKEYS( XK_2, 1)
|
||||
TAGKEYS( XK_3, 2)
|
||||
diff --git a/dwm.1 b/dwm.1
|
||||
index 13b3729..0202d96 100644
|
||||
--- a/dwm.1
|
||||
+++ b/dwm.1
|
||||
@@ -140,6 +140,16 @@ View all windows with any tag.
|
||||
.B Mod1\-Control\-[1..n]
|
||||
Add/remove all windows with nth tag to/from the view.
|
||||
.TP
|
||||
+.B Mod1\--
|
||||
+Decrease the gaps around windows.
|
||||
+.TP
|
||||
+.B Mod1\-=
|
||||
+Increase the gaps around windows.
|
||||
+.TP
|
||||
+.B Mod1\-Shift-=
|
||||
+Reset the gaps around windows to
|
||||
+.BR 0 .
|
||||
+.TP
|
||||
.B Mod1\-Shift\-q
|
||||
Quit dwm.
|
||||
.SS Mouse commands
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 9fd0286..45a58f3 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -119,6 +119,7 @@ struct Monitor {
|
||||
int by; /* bar geometry */
|
||||
int mx, my, mw, mh; /* screen size */
|
||||
int wx, wy, ww, wh; /* window area */
|
||||
+ int gappx; /* gaps between windows */
|
||||
unsigned int seltags;
|
||||
unsigned int sellt;
|
||||
unsigned int tagset[2];
|
||||
@@ -200,6 +201,7 @@ static void sendmon(Client *c, Monitor *m);
|
||||
static void setclientstate(Client *c, long state);
|
||||
static void setfocus(Client *c);
|
||||
static void setfullscreen(Client *c, int fullscreen);
|
||||
+static void setgaps(const Arg *arg);
|
||||
static void setlayout(const Arg *arg);
|
||||
static void setmfact(const Arg *arg);
|
||||
static void setup(void);
|
||||
@@ -639,6 +641,7 @@ createmon(void)
|
||||
m->nmaster = nmaster;
|
||||
m->showbar = showbar;
|
||||
m->topbar = topbar;
|
||||
+ m->gappx = gappx;
|
||||
m->lt[0] = &layouts[0];
|
||||
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
||||
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
||||
@@ -1498,6 +1501,16 @@ setfullscreen(Client *c, int fullscreen)
|
||||
}
|
||||
}
|
||||
|
||||
+void
|
||||
+setgaps(const Arg *arg)
|
||||
+{
|
||||
+ if ((arg->i == 0) || (selmon->gappx + arg->i < 0))
|
||||
+ selmon->gappx = 0;
|
||||
+ else
|
||||
+ selmon->gappx += arg->i;
|
||||
+ arrange(selmon);
|
||||
+}
|
||||
+
|
||||
void
|
||||
setlayout(const Arg *arg)
|
||||
{
|
||||
@@ -1684,18 +1697,18 @@ tile(Monitor *m)
|
||||
if (n > m->nmaster)
|
||||
mw = m->nmaster ? m->ww * m->mfact : 0;
|
||||
else
|
||||
- mw = m->ww;
|
||||
- for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
||||
+ mw = m->ww - m->gappx;
|
||||
+ for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
||||
if (i < m->nmaster) {
|
||||
- h = (m->wh - my) / (MIN(n, m->nmaster) - i);
|
||||
- resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
|
||||
- if (my + HEIGHT(c) < m->wh)
|
||||
- my += HEIGHT(c);
|
||||
+ h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
|
||||
+ resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0);
|
||||
+ if (my + HEIGHT(c) + m->gappx < m->wh)
|
||||
+ my += HEIGHT(c) + m->gappx;
|
||||
} else {
|
||||
- h = (m->wh - ty) / (n - i);
|
||||
- resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
|
||||
- if (ty + HEIGHT(c) < m->wh)
|
||||
- ty += HEIGHT(c);
|
||||
+ h = (m->wh - ty) / (n - i) - m->gappx;
|
||||
+ resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), 0);
|
||||
+ if (ty + HEIGHT(c) + m->gappx < m->wh)
|
||||
+ ty += HEIGHT(c) + m->gappx;
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
2.26.2
|
||||
|
||||
3246
KleinDwm/source/patches/dwm-ipc-20201106-f04cac6.diff
Normal file
3246
KleinDwm/source/patches/dwm-ipc-20201106-f04cac6.diff
Normal file
File diff suppressed because it is too large
Load Diff
266
KleinDwm/source/patches/dwm-keychain-20200729-053e3a2.diff
Normal file
266
KleinDwm/source/patches/dwm-keychain-20200729-053e3a2.diff
Normal file
@@ -0,0 +1,266 @@
|
||||
From e6c2d5fdc6010a22d6cd74485cb0b3e74467d0da Mon Sep 17 00:00:00 2001
|
||||
From: braunbearded <braunbearded1@gmail.com>
|
||||
Date: Wed, 29 Jul 2020 18:37:47 +0200
|
||||
Subject: [PATCH 1/4] chain key bindings
|
||||
|
||||
---
|
||||
dwm.c | 34 +++++++++++++++++++++++++++++-----
|
||||
1 file changed, 29 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 9fd0286..7298c5e 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -101,6 +101,7 @@ struct Client {
|
||||
|
||||
typedef struct {
|
||||
unsigned int mod;
|
||||
+ KeySym chain;
|
||||
KeySym keysym;
|
||||
void (*func)(const Arg *);
|
||||
const Arg arg;
|
||||
@@ -268,6 +269,7 @@ static Display *dpy;
|
||||
static Drw *drw;
|
||||
static Monitor *mons, *selmon;
|
||||
static Window root, wmcheckwin;
|
||||
+static KeySym keychain = -1;
|
||||
|
||||
/* configuration, allows nested code to access above variables */
|
||||
#include "config.h"
|
||||
@@ -954,13 +956,18 @@ grabkeys(void)
|
||||
unsigned int i, j;
|
||||
unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
|
||||
KeyCode code;
|
||||
+ KeyCode chain;
|
||||
|
||||
XUngrabKey(dpy, AnyKey, AnyModifier, root);
|
||||
for (i = 0; i < LENGTH(keys); i++)
|
||||
- if ((code = XKeysymToKeycode(dpy, keys[i].keysym)))
|
||||
+ if ((code = XKeysymToKeycode(dpy, keys[i].keysym))) {
|
||||
+ if (keys[i].chain != -1 &&
|
||||
+ ((chain = XKeysymToKeycode(dpy, keys[i].chain))))
|
||||
+ code = chain;
|
||||
for (j = 0; j < LENGTH(modifiers); j++)
|
||||
XGrabKey(dpy, code, keys[i].mod | modifiers[j], root,
|
||||
True, GrabModeAsync, GrabModeAsync);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -989,14 +996,31 @@ keypress(XEvent *e)
|
||||
unsigned int i;
|
||||
KeySym keysym;
|
||||
XKeyEvent *ev;
|
||||
+ int current = 0;
|
||||
|
||||
ev = &e->xkey;
|
||||
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
|
||||
- for (i = 0; i < LENGTH(keys); i++)
|
||||
- if (keysym == keys[i].keysym
|
||||
- && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
|
||||
- && keys[i].func)
|
||||
+ for (i = 0; i < LENGTH(keys); i++) {
|
||||
+ if (keysym == keys[i].keysym && keys[i].chain == -1
|
||||
+ && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
|
||||
+ && keys[i].func)
|
||||
+ keys[i].func(&(keys[i].arg));
|
||||
+ else if (keysym == keys[i].chain && keychain == -1
|
||||
+ && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
|
||||
+ && keys[i].func) {
|
||||
+ current = 1;
|
||||
+ keychain = keysym;
|
||||
+ XGrabKey(dpy, AnyKey, AnyModifier, root, True, GrabModeAsync,
|
||||
+ GrabModeAsync);
|
||||
+ } else if (!current && keysym == keys[i].keysym
|
||||
+ && keys[i].chain == keychain
|
||||
+ && keys[i].func)
|
||||
keys[i].func(&(keys[i].arg));
|
||||
+ }
|
||||
+ if (!current) {
|
||||
+ keychain = -1;
|
||||
+ grabkeys();
|
||||
+ }
|
||||
}
|
||||
|
||||
void
|
||||
--
|
||||
2.28.0
|
||||
|
||||
|
||||
From ad3d15cf7df3286d35728afef823c3163898e2db Mon Sep 17 00:00:00 2001
|
||||
From: braunbearded <braunbearded1@gmail.com>
|
||||
Date: Wed, 29 Jul 2020 18:38:15 +0200
|
||||
Subject: [PATCH 2/4] update default bindings
|
||||
|
||||
---
|
||||
config.def.h | 80 +++++++++++++++++++++++++++-------------------------
|
||||
1 file changed, 41 insertions(+), 39 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 1c0b587..c7cab16 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -45,11 +45,11 @@ static const Layout layouts[] = {
|
||||
|
||||
/* key definitions */
|
||||
#define MODKEY Mod1Mask
|
||||
-#define TAGKEYS(KEY,TAG) \
|
||||
- { MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||
- { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||
- { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
|
||||
- { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
|
||||
+#define TAGKEYS(CHAIN,KEY,TAG) \
|
||||
+ { MODKEY, CHAIN, KEY, view, {.ui = 1 << TAG} }, \
|
||||
+ { MODKEY|ControlMask, CHAIN, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||
+ { MODKEY|ShiftMask, CHAIN, KEY, tag, {.ui = 1 << TAG} }, \
|
||||
+ { MODKEY|ControlMask|ShiftMask, CHAIN, KEY, toggletag, {.ui = 1 << TAG} },
|
||||
|
||||
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||
@@ -60,40 +60,42 @@ static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont,
|
||||
static const char *termcmd[] = { "st", NULL };
|
||||
|
||||
static Key keys[] = {
|
||||
- /* modifier key function argument */
|
||||
- { MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||
- { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
||||
- { MODKEY, XK_b, togglebar, {0} },
|
||||
- { MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||
- { MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||
- { MODKEY, XK_i, incnmaster, {.i = +1 } },
|
||||
- { MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||
- { MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||
- { MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||
- { MODKEY, XK_Return, zoom, {0} },
|
||||
- { MODKEY, XK_Tab, view, {0} },
|
||||
- { MODKEY|ShiftMask, XK_c, killclient, {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_comma, focusmon, {.i = -1 } },
|
||||
- { MODKEY, XK_period, focusmon, {.i = +1 } },
|
||||
- { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
||||
- { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
||||
- TAGKEYS( XK_1, 0)
|
||||
- TAGKEYS( XK_2, 1)
|
||||
- TAGKEYS( XK_3, 2)
|
||||
- TAGKEYS( XK_4, 3)
|
||||
- TAGKEYS( XK_5, 4)
|
||||
- TAGKEYS( XK_6, 5)
|
||||
- TAGKEYS( XK_7, 6)
|
||||
- TAGKEYS( XK_8, 7)
|
||||
- TAGKEYS( XK_9, 8)
|
||||
- { MODKEY|ShiftMask, XK_q, quit, {0} },
|
||||
+ /* modifier chain key key function argument */
|
||||
+ { MODKEY, -1, XK_p, spawn, {.v = dmenucmd } },
|
||||
+ { MODKEY|ShiftMask, -1, XK_Return, spawn, {.v = termcmd } },
|
||||
+ { MODKEY, -1, XK_b, togglebar, {0} },
|
||||
+ { MODKEY, -1, XK_j, focusstack, {.i = +1 } },
|
||||
+ { MODKEY, -1, XK_k, focusstack, {.i = -1 } },
|
||||
+ { MODKEY, -1, XK_i, incnmaster, {.i = +1 } },
|
||||
+ { MODKEY, -1, XK_d, incnmaster, {.i = -1 } },
|
||||
+ { MODKEY, -1, XK_h, setmfact, {.f = -0.05} },
|
||||
+ { MODKEY, -1, XK_l, setmfact, {.f = +0.05} },
|
||||
+ { MODKEY, -1, XK_Return, zoom, {0} },
|
||||
+ { MODKEY, -1, XK_Tab, view, {0} },
|
||||
+ { MODKEY|ShiftMask, -1, XK_c, killclient, {0} },
|
||||
+ { MODKEY, -1, XK_t, setlayout, {.v = &layouts[0]} },
|
||||
+ { MODKEY, -1, XK_f, setlayout, {.v = &layouts[1]} },
|
||||
+ { MODKEY, -1, XK_m, setlayout, {.v = &layouts[2]} },
|
||||
+ { MODKEY, -1, XK_space, setlayout, {0} },
|
||||
+ { MODKEY|ShiftMask, -1, XK_space, togglefloating, {0} },
|
||||
+ { MODKEY, -1, XK_0, view, {.ui = ~0 } },
|
||||
+ { MODKEY|ShiftMask, -1, XK_0, tag, {.ui = ~0 } },
|
||||
+ { MODKEY, -1, XK_comma, focusmon, {.i = -1 } },
|
||||
+ { MODKEY, -1, XK_period, focusmon, {.i = +1 } },
|
||||
+ { MODKEY|ShiftMask, -1, XK_comma, tagmon, {.i = -1 } },
|
||||
+ { MODKEY|ShiftMask, -1, XK_period, tagmon, {.i = +1 } },
|
||||
+ TAGKEYS( -1, XK_1, 0)
|
||||
+ TAGKEYS( -1, XK_2, 1)
|
||||
+ TAGKEYS( -1, XK_3, 2)
|
||||
+ TAGKEYS( -1, XK_4, 3)
|
||||
+ TAGKEYS( -1, XK_5, 4)
|
||||
+ TAGKEYS( -1, XK_6, 5)
|
||||
+ TAGKEYS( -1, XK_7, 6)
|
||||
+ TAGKEYS( -1, XK_8, 7)
|
||||
+ TAGKEYS( -1, XK_9, 8)
|
||||
+ { MODKEY|ShiftMask, -1, XK_q, quit, {0} },
|
||||
+ { MODKEY, XK_a, XK_d, spawn, {.v = dmenucmd } },
|
||||
+ { MODKEY, XK_a, XK_t, spawn, {.v = termcmd } },
|
||||
};
|
||||
|
||||
/* button definitions */
|
||||
--
|
||||
2.28.0
|
||||
|
||||
|
||||
From e9f3eec82010fd6083dc57f058902a1aab2d14ea Mon Sep 17 00:00:00 2001
|
||||
From: braunbearded <braunbearded1@gmail.com>
|
||||
Date: Wed, 29 Jul 2020 19:07:07 +0200
|
||||
Subject: [PATCH 3/4] fix bug for mod key ignore
|
||||
|
||||
---
|
||||
dwm.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 7298c5e..aee56d4 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -1013,6 +1013,7 @@ keypress(XEvent *e)
|
||||
XGrabKey(dpy, AnyKey, AnyModifier, root, True, GrabModeAsync,
|
||||
GrabModeAsync);
|
||||
} else if (!current && keysym == keys[i].keysym
|
||||
+ && keychain != -1
|
||||
&& keys[i].chain == keychain
|
||||
&& keys[i].func)
|
||||
keys[i].func(&(keys[i].arg));
|
||||
--
|
||||
2.28.0
|
||||
|
||||
|
||||
From 053e3a2b2ff87805a15f3fe2f82a7d8bf0ab9b7a Mon Sep 17 00:00:00 2001
|
||||
From: braunbearded <braunbearded1@gmail.com>
|
||||
Date: Wed, 29 Jul 2020 21:25:23 +0200
|
||||
Subject: [PATCH 4/4] listen for all keys inkl modifier after prefix
|
||||
|
||||
---
|
||||
dwm.c | 8 +++++---
|
||||
1 file changed, 5 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index aee56d4..dea8f6a 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -993,10 +993,11 @@ isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info)
|
||||
void
|
||||
keypress(XEvent *e)
|
||||
{
|
||||
- unsigned int i;
|
||||
+ unsigned int i, j;
|
||||
KeySym keysym;
|
||||
XKeyEvent *ev;
|
||||
int current = 0;
|
||||
+ unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
|
||||
|
||||
ev = &e->xkey;
|
||||
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
|
||||
@@ -1010,8 +1011,9 @@ keypress(XEvent *e)
|
||||
&& keys[i].func) {
|
||||
current = 1;
|
||||
keychain = keysym;
|
||||
- XGrabKey(dpy, AnyKey, AnyModifier, root, True, GrabModeAsync,
|
||||
- GrabModeAsync);
|
||||
+ for (j = 0; j < LENGTH(modifiers); j++)
|
||||
+ XGrabKey(dpy, AnyKey, 0 | modifiers[j], root,
|
||||
+ True, GrabModeAsync, GrabModeAsync);
|
||||
} else if (!current && keysym == keys[i].keysym
|
||||
&& keychain != -1
|
||||
&& keys[i].chain == keychain
|
||||
--
|
||||
2.28.0
|
||||
|
||||
95
KleinDwm/source/patches/dwm-movestack-20211115-a786211.diff
Normal file
95
KleinDwm/source/patches/dwm-movestack-20211115-a786211.diff
Normal file
@@ -0,0 +1,95 @@
|
||||
From 9a4037dc0ef56f91c009317e78e9e3790dafbb58 Mon Sep 17 00:00:00 2001
|
||||
From: BrunoCooper17 <BrunoCooper17@outlook.com>
|
||||
Date: Mon, 15 Nov 2021 14:04:53 -0600
|
||||
Subject: [PATCH] MoveStack patch
|
||||
|
||||
This plugin allows you to move clients around in the stack and swap them
|
||||
with the master. It emulates the behavior off mod+shift+j and mod+shift+k
|
||||
in Xmonad. movestack(+1) will swap the client with the current focus with
|
||||
the next client. movestack(-1) will swap the client with the current focus
|
||||
with the previous client.
|
||||
---
|
||||
config.def.h | 3 +++
|
||||
movestack.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 51 insertions(+)
|
||||
create mode 100644 movestack.c
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index a2ac963..33efa5b 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -60,6 +60,7 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn()
|
||||
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
||||
static const char *termcmd[] = { "st", NULL };
|
||||
|
||||
+#include "movestack.c"
|
||||
static Key keys[] = {
|
||||
/* modifier key function argument */
|
||||
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||
@@ -71,6 +72,8 @@ static Key keys[] = {
|
||||
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||
+ { MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } },
|
||||
+ { MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } },
|
||||
{ MODKEY, XK_Return, zoom, {0} },
|
||||
{ MODKEY, XK_Tab, view, {0} },
|
||||
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
|
||||
diff --git a/movestack.c b/movestack.c
|
||||
new file mode 100644
|
||||
index 0000000..520f4ae
|
||||
--- /dev/null
|
||||
+++ b/movestack.c
|
||||
@@ -0,0 +1,48 @@
|
||||
+void
|
||||
+movestack(const Arg *arg) {
|
||||
+ Client *c = NULL, *p = NULL, *pc = NULL, *i;
|
||||
+
|
||||
+ if(arg->i > 0) {
|
||||
+ /* find the client after selmon->sel */
|
||||
+ for(c = selmon->sel->next; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
|
||||
+ if(!c)
|
||||
+ for(c = selmon->clients; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
|
||||
+
|
||||
+ }
|
||||
+ else {
|
||||
+ /* find the client before selmon->sel */
|
||||
+ for(i = selmon->clients; i != selmon->sel; i = i->next)
|
||||
+ if(ISVISIBLE(i) && !i->isfloating)
|
||||
+ c = i;
|
||||
+ if(!c)
|
||||
+ for(; i; i = i->next)
|
||||
+ if(ISVISIBLE(i) && !i->isfloating)
|
||||
+ c = i;
|
||||
+ }
|
||||
+ /* find the client before selmon->sel and c */
|
||||
+ for(i = selmon->clients; i && (!p || !pc); i = i->next) {
|
||||
+ if(i->next == selmon->sel)
|
||||
+ p = i;
|
||||
+ if(i->next == c)
|
||||
+ pc = i;
|
||||
+ }
|
||||
+
|
||||
+ /* swap c and selmon->sel selmon->clients in the selmon->clients list */
|
||||
+ if(c && c != selmon->sel) {
|
||||
+ Client *temp = selmon->sel->next==c?selmon->sel:selmon->sel->next;
|
||||
+ selmon->sel->next = c->next==selmon->sel?c:c->next;
|
||||
+ c->next = temp;
|
||||
+
|
||||
+ if(p && p != c)
|
||||
+ p->next = c;
|
||||
+ if(pc && pc != selmon->sel)
|
||||
+ pc->next = selmon->sel;
|
||||
+
|
||||
+ if(selmon->sel == selmon->clients)
|
||||
+ selmon->clients = c;
|
||||
+ else if(c == selmon->clients)
|
||||
+ selmon->clients = selmon->sel;
|
||||
+
|
||||
+ arrange(selmon);
|
||||
+ }
|
||||
+}
|
||||
\ No newline at end of file
|
||||
--
|
||||
2.33.1
|
||||
|
||||
177
KleinDwm/source/patches/dwm-pertag-20200914-61bb8b2.diff
Normal file
177
KleinDwm/source/patches/dwm-pertag-20200914-61bb8b2.diff
Normal file
@@ -0,0 +1,177 @@
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 664c527..ac8e4ec 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -111,6 +111,7 @@ typedef struct {
|
||||
void (*arrange)(Monitor *);
|
||||
} Layout;
|
||||
|
||||
+typedef struct Pertag Pertag;
|
||||
struct Monitor {
|
||||
char ltsymbol[16];
|
||||
float mfact;
|
||||
@@ -130,6 +131,7 @@ struct Monitor {
|
||||
Monitor *next;
|
||||
Window barwin;
|
||||
const Layout *lt[2];
|
||||
+ Pertag *pertag;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
@@ -272,6 +274,15 @@ static Window root, wmcheckwin;
|
||||
/* configuration, allows nested code to access above variables */
|
||||
#include "config.h"
|
||||
|
||||
+struct Pertag {
|
||||
+ unsigned int curtag, prevtag; /* current and previous tag */
|
||||
+ int nmasters[LENGTH(tags) + 1]; /* number of windows in master area */
|
||||
+ float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */
|
||||
+ unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */
|
||||
+ const Layout *ltidxs[LENGTH(tags) + 1][2]; /* matrix of tags and layouts indexes */
|
||||
+ int showbars[LENGTH(tags) + 1]; /* display bar for the current tag */
|
||||
+};
|
||||
+
|
||||
/* compile-time check if all tags fit into an unsigned int bit array. */
|
||||
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
||||
|
||||
@@ -632,6 +643,7 @@ Monitor *
|
||||
createmon(void)
|
||||
{
|
||||
Monitor *m;
|
||||
+ unsigned int i;
|
||||
|
||||
m = ecalloc(1, sizeof(Monitor));
|
||||
m->tagset[0] = m->tagset[1] = 1;
|
||||
@@ -642,6 +654,20 @@ createmon(void)
|
||||
m->lt[0] = &layouts[0];
|
||||
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
||||
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
||||
+ m->pertag = ecalloc(1, sizeof(Pertag));
|
||||
+ m->pertag->curtag = m->pertag->prevtag = 1;
|
||||
+
|
||||
+ for (i = 0; i <= LENGTH(tags); i++) {
|
||||
+ m->pertag->nmasters[i] = m->nmaster;
|
||||
+ m->pertag->mfacts[i] = m->mfact;
|
||||
+
|
||||
+ m->pertag->ltidxs[i][0] = m->lt[0];
|
||||
+ m->pertag->ltidxs[i][1] = m->lt[1];
|
||||
+ m->pertag->sellts[i] = m->sellt;
|
||||
+
|
||||
+ m->pertag->showbars[i] = m->showbar;
|
||||
+ }
|
||||
+
|
||||
return m;
|
||||
}
|
||||
|
||||
@@ -967,7 +993,7 @@ grabkeys(void)
|
||||
void
|
||||
incnmaster(const Arg *arg)
|
||||
{
|
||||
- selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
|
||||
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0);
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
@@ -1502,9 +1528,9 @@ void
|
||||
setlayout(const Arg *arg)
|
||||
{
|
||||
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
|
||||
- selmon->sellt ^= 1;
|
||||
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag] ^= 1;
|
||||
if (arg && arg->v)
|
||||
- selmon->lt[selmon->sellt] = (Layout *)arg->v;
|
||||
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v;
|
||||
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
|
||||
if (selmon->sel)
|
||||
arrange(selmon);
|
||||
@@ -1523,7 +1549,7 @@ setmfact(const Arg *arg)
|
||||
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
|
||||
if (f < 0.05 || f > 0.95)
|
||||
return;
|
||||
- selmon->mfact = f;
|
||||
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag] = f;
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
@@ -1702,7 +1728,7 @@ tile(Monitor *m)
|
||||
void
|
||||
togglebar(const Arg *arg)
|
||||
{
|
||||
- selmon->showbar = !selmon->showbar;
|
||||
+ selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar;
|
||||
updatebarpos(selmon);
|
||||
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
|
||||
arrange(selmon);
|
||||
@@ -1741,9 +1767,33 @@ void
|
||||
toggleview(const Arg *arg)
|
||||
{
|
||||
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
|
||||
+ int i;
|
||||
|
||||
if (newtagset) {
|
||||
selmon->tagset[selmon->seltags] = newtagset;
|
||||
+
|
||||
+ if (newtagset == ~0) {
|
||||
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||
+ selmon->pertag->curtag = 0;
|
||||
+ }
|
||||
+
|
||||
+ /* test if the user did not select the same tag */
|
||||
+ if (!(newtagset & 1 << (selmon->pertag->curtag - 1))) {
|
||||
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||
+ for (i = 0; !(newtagset & 1 << i); i++) ;
|
||||
+ selmon->pertag->curtag = i + 1;
|
||||
+ }
|
||||
+
|
||||
+ /* apply settings for this view */
|
||||
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
||||
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
||||
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
||||
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
||||
+ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
||||
+
|
||||
+ if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
||||
+ togglebar(NULL);
|
||||
+
|
||||
focus(NULL);
|
||||
arrange(selmon);
|
||||
}
|
||||
@@ -2038,11 +2088,37 @@ updatewmhints(Client *c)
|
||||
void
|
||||
view(const Arg *arg)
|
||||
{
|
||||
+ int i;
|
||||
+ unsigned int tmptag;
|
||||
+
|
||||
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
||||
return;
|
||||
selmon->seltags ^= 1; /* toggle sel tagset */
|
||||
- if (arg->ui & TAGMASK)
|
||||
+ if (arg->ui & TAGMASK) {
|
||||
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
||||
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||
+
|
||||
+ if (arg->ui == ~0)
|
||||
+ selmon->pertag->curtag = 0;
|
||||
+ else {
|
||||
+ for (i = 0; !(arg->ui & 1 << i); i++) ;
|
||||
+ selmon->pertag->curtag = i + 1;
|
||||
+ }
|
||||
+ } else {
|
||||
+ tmptag = selmon->pertag->prevtag;
|
||||
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||
+ selmon->pertag->curtag = tmptag;
|
||||
+ }
|
||||
+
|
||||
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
||||
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
||||
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
||||
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
||||
+ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
||||
+
|
||||
+ if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
||||
+ togglebar(NULL);
|
||||
+
|
||||
focus(NULL);
|
||||
arrange(selmon);
|
||||
}
|
||||
59
KleinDwm/source/patches/dwm-rainbowtags-6.2.diff
Normal file
59
KleinDwm/source/patches/dwm-rainbowtags-6.2.diff
Normal file
@@ -0,0 +1,59 @@
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 1c0b587..3fb5cf8 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -21,6 +21,18 @@ static const char *colors[][3] = {
|
||||
/* tagging */
|
||||
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||
|
||||
+static const char *tagsel[][2] = {
|
||||
+ { "#ffffff", "#ff0000" },
|
||||
+ { "#ffffff", "#ff7f00" },
|
||||
+ { "#000000", "#ffff00" },
|
||||
+ { "#000000", "#00ff00" },
|
||||
+ { "#ffffff", "#0000ff" },
|
||||
+ { "#ffffff", "#4b0082" },
|
||||
+ { "#ffffff", "#9400d3" },
|
||||
+ { "#000000", "#ffffff" },
|
||||
+ { "#ffffff", "#000000" },
|
||||
+};
|
||||
+
|
||||
static const Rule rules[] = {
|
||||
/* xprop(1):
|
||||
* WM_CLASS(STRING) = instance, class
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index b0b3466..c16d5f5 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -264,6 +264,7 @@ static Atom wmatom[WMLast], netatom[NetLast];
|
||||
static int running = 1;
|
||||
static Cur *cursor[CurLast];
|
||||
static Clr **scheme;
|
||||
+static Clr **tagscheme;
|
||||
static Display *dpy;
|
||||
static Drw *drw;
|
||||
static Monitor *mons, *selmon;
|
||||
@@ -717,7 +718,7 @@ drawbar(Monitor *m)
|
||||
x = 0;
|
||||
for (i = 0; i < LENGTH(tags); i++) {
|
||||
w = TEXTW(tags[i]);
|
||||
- drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
|
||||
+ drw_setscheme(drw, (m->tagset[m->seltags] & 1 << i ? tagscheme[i] : scheme[SchemeNorm]));
|
||||
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
|
||||
if (occ & 1 << i)
|
||||
drw_rect(drw, x + boxs, boxs, boxw, boxw,
|
||||
@@ -1568,9 +1569,14 @@ setup(void)
|
||||
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
|
||||
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
|
||||
/* init appearance */
|
||||
+ if (LENGTH(tags) > LENGTH(tagsel))
|
||||
+ die("too few color schemes for the tags");
|
||||
scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
|
||||
for (i = 0; i < LENGTH(colors); i++)
|
||||
scheme[i] = drw_scm_create(drw, colors[i], 3);
|
||||
+ tagscheme = ecalloc(LENGTH(tagsel), sizeof(Clr *));
|
||||
+ for (i = 0; i < LENGTH(tagsel); i++)
|
||||
+ tagscheme[i] = drw_scm_create(drw, tagsel[i], 2);
|
||||
/* init bars */
|
||||
updatebars();
|
||||
updatestatus();
|
||||
139
KleinDwm/source/patches/dwm-restartsig-20180523-6.2.diff
Normal file
139
KleinDwm/source/patches/dwm-restartsig-20180523-6.2.diff
Normal file
@@ -0,0 +1,139 @@
|
||||
From 2991f37f0aaf44b9f9b11e7893ff0af8eb88f649 Mon Sep 17 00:00:00 2001
|
||||
From: Christopher Drelich <cd@cdrakka.com>
|
||||
Date: Wed, 23 May 2018 22:50:38 -0400
|
||||
Subject: [PATCH] Modifies quit to handle restarts and adds SIGHUP and SIGTERM
|
||||
handlers.
|
||||
|
||||
Modified quit() to restart if it receives arg .i = 1
|
||||
MOD+CTRL+SHIFT+Q was added to confid.def.h to do just that.
|
||||
|
||||
Signal handlers were handled for SIGHUP and SIGTERM.
|
||||
If dwm receives these signals it calls quit() with
|
||||
arg .i = to 1 or 0, respectively.
|
||||
|
||||
To restart dwm:
|
||||
MOD+CTRL+SHIFT+Q
|
||||
or
|
||||
kill -HUP dwmpid
|
||||
|
||||
To quit dwm cleanly:
|
||||
MOD+SHIFT+Q
|
||||
or
|
||||
kill -TERM dwmpid
|
||||
---
|
||||
config.def.h | 1 +
|
||||
dwm.1 | 10 ++++++++++
|
||||
dwm.c | 22 ++++++++++++++++++++++
|
||||
3 files changed, 33 insertions(+)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index a9ac303..e559429 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -94,6 +94,7 @@ static Key keys[] = {
|
||||
TAGKEYS( XK_8, 7)
|
||||
TAGKEYS( XK_9, 8)
|
||||
{ MODKEY|ShiftMask, XK_q, quit, {0} },
|
||||
+ { MODKEY|ControlMask|ShiftMask, XK_q, quit, {1} },
|
||||
};
|
||||
|
||||
/* button definitions */
|
||||
diff --git a/dwm.1 b/dwm.1
|
||||
index 13b3729..36a331c 100644
|
||||
--- a/dwm.1
|
||||
+++ b/dwm.1
|
||||
@@ -142,6 +142,9 @@ Add/remove all windows with nth tag to/from the view.
|
||||
.TP
|
||||
.B Mod1\-Shift\-q
|
||||
Quit dwm.
|
||||
+.TP
|
||||
+.B Mod1\-Control\-Shift\-q
|
||||
+Restart dwm.
|
||||
.SS Mouse commands
|
||||
.TP
|
||||
.B Mod1\-Button1
|
||||
@@ -155,6 +158,13 @@ Resize focused window while dragging. Tiled windows will be toggled to the float
|
||||
.SH CUSTOMIZATION
|
||||
dwm is customized by creating a custom config.h and (re)compiling the source
|
||||
code. This keeps it fast, secure and simple.
|
||||
+.SH SIGNALS
|
||||
+.TP
|
||||
+.B SIGHUP - 1
|
||||
+Restart the dwm process.
|
||||
+.TP
|
||||
+.B SIGTERM - 15
|
||||
+Cleanly terminate the dwm process.
|
||||
.SH SEE ALSO
|
||||
.BR dmenu (1),
|
||||
.BR st (1)
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index bb95e26..286eecd 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -205,6 +205,8 @@ static void setup(void);
|
||||
static void seturgent(Client *c, int urg);
|
||||
static void showhide(Client *c);
|
||||
static void sigchld(int unused);
|
||||
+static void sighup(int unused);
|
||||
+static void sigterm(int unused);
|
||||
static void spawn(const Arg *arg);
|
||||
static void tag(const Arg *arg);
|
||||
static void tagmon(const Arg *arg);
|
||||
@@ -260,6 +262,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
|
||||
[UnmapNotify] = unmapnotify
|
||||
};
|
||||
static Atom wmatom[WMLast], netatom[NetLast];
|
||||
+static int restart = 0;
|
||||
static int running = 1;
|
||||
static Cur *cursor[CurLast];
|
||||
static Clr **scheme;
|
||||
@@ -1248,6 +1251,7 @@ propertynotify(XEvent *e)
|
||||
void
|
||||
quit(const Arg *arg)
|
||||
{
|
||||
+ if(arg->i) restart = 1;
|
||||
running = 0;
|
||||
}
|
||||
|
||||
@@ -1536,6 +1540,9 @@ setup(void)
|
||||
/* clean up any zombies immediately */
|
||||
sigchld(0);
|
||||
|
||||
+ signal(SIGHUP, sighup);
|
||||
+ signal(SIGTERM, sigterm);
|
||||
+
|
||||
/* init screen */
|
||||
screen = DefaultScreen(dpy);
|
||||
sw = DisplayWidth(dpy, screen);
|
||||
@@ -1637,6 +1644,20 @@ sigchld(int unused)
|
||||
}
|
||||
|
||||
void
|
||||
+sighup(int unused)
|
||||
+{
|
||||
+ Arg a = {.i = 1};
|
||||
+ quit(&a);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+sigterm(int unused)
|
||||
+{
|
||||
+ Arg a = {.i = 0};
|
||||
+ quit(&a);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
spawn(const Arg *arg)
|
||||
{
|
||||
if (arg->v == dmenucmd)
|
||||
@@ -2139,6 +2160,7 @@ main(int argc, char *argv[])
|
||||
setup();
|
||||
scan();
|
||||
run();
|
||||
+ if(restart) execvp(argv[0], argv);
|
||||
cleanup();
|
||||
XCloseDisplay(dpy);
|
||||
return EXIT_SUCCESS;
|
||||
--
|
||||
2.7.4
|
||||
|
||||
888
KleinDwm/source/patches/dwm-status2d-systray-6.3.diff
Normal file
888
KleinDwm/source/patches/dwm-status2d-systray-6.3.diff
Normal file
@@ -0,0 +1,888 @@
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index a2ac963..86fcc84 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -3,8 +3,13 @@
|
||||
/* appearance */
|
||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||
static const unsigned int snap = 32; /* snap pixel */
|
||||
-static const int showbar = 1; /* 0 means no bar */
|
||||
-static const int topbar = 1; /* 0 means bottom bar */
|
||||
+static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */
|
||||
+static const unsigned int systrayonleft = 0; /* 0: systray in the right corner, >0: systray on left of status text */
|
||||
+static const unsigned int systrayspacing = 2; /* systray spacing */
|
||||
+static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor*/
|
||||
+static const int showsystray = 1; /* 0 means no systray */
|
||||
+static const int showbar = 1; /* 0 means no bar */
|
||||
+static const int topbar = 1; /* 0 means bottom bar */
|
||||
static const char *fonts[] = { "monospace:size=10" };
|
||||
static const char dmenufont[] = "monospace:size=10";
|
||||
static const char col_gray1[] = "#222222";
|
||||
@@ -101,8 +106,8 @@ static Key keys[] = {
|
||||
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
|
||||
static Button buttons[] = {
|
||||
/* click event mask button function argument */
|
||||
- { ClkLtSymbol, 0, Button1, setlayout, {0} },
|
||||
- { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
|
||||
+ { ClkTagBar, MODKEY, Button1, tag, {0} },
|
||||
+ { ClkTagBar, MODKEY, Button3, toggletag, {0} },
|
||||
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
||||
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
|
||||
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index a96f33c..8153bfe 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -57,12 +57,27 @@
|
||||
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
||||
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||
|
||||
+#define SYSTEM_TRAY_REQUEST_DOCK 0
|
||||
+/* XEMBED messages */
|
||||
+#define XEMBED_EMBEDDED_NOTIFY 0
|
||||
+#define XEMBED_WINDOW_ACTIVATE 1
|
||||
+#define XEMBED_FOCUS_IN 4
|
||||
+#define XEMBED_MODALITY_ON 10
|
||||
+#define XEMBED_MAPPED (1 << 0)
|
||||
+#define XEMBED_WINDOW_ACTIVATE 1
|
||||
+#define XEMBED_WINDOW_DEACTIVATE 2
|
||||
+#define VERSION_MAJOR 0
|
||||
+#define VERSION_MINOR 0
|
||||
+#define XEMBED_EMBEDDED_VERSION (VERSION_MAJOR << 16) | VERSION_MINOR
|
||||
+
|
||||
/* enums */
|
||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||
enum { SchemeNorm, SchemeSel }; /* color schemes */
|
||||
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
||||
+ NetSystemTray, NetSystemTrayOP, NetSystemTrayOrientation, NetSystemTrayOrientationHorz,
|
||||
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
||||
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
|
||||
+enum { Manager, Xembed, XembedInfo, XLast }; /* Xembed atoms */
|
||||
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
|
||||
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
|
||||
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
|
||||
@@ -141,6 +156,12 @@ typedef struct {
|
||||
int monitor;
|
||||
} Rule;
|
||||
|
||||
+typedef struct Systray Systray;
|
||||
+struct Systray {
|
||||
+ Window win;
|
||||
+ Client *icons;
|
||||
+};
|
||||
+
|
||||
/* function declarations */
|
||||
static void applyrules(Client *c);
|
||||
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
|
||||
@@ -163,6 +184,7 @@ static void detachstack(Client *c);
|
||||
static Monitor *dirtomon(int dir);
|
||||
static void drawbar(Monitor *m);
|
||||
static void drawbars(void);
|
||||
+static int drawstatusbar(Monitor *m, int bh, char* text);
|
||||
static void enternotify(XEvent *e);
|
||||
static void expose(XEvent *e);
|
||||
static void focus(Client *c);
|
||||
@@ -172,6 +194,7 @@ static void focusstack(const Arg *arg);
|
||||
static Atom getatomprop(Client *c, Atom prop);
|
||||
static int getrootptr(int *x, int *y);
|
||||
static long getstate(Window w);
|
||||
+static unsigned int getsystraywidth();
|
||||
static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
|
||||
static void grabbuttons(Client *c, int focused);
|
||||
static void grabkeys(void);
|
||||
@@ -189,13 +212,16 @@ static void pop(Client *);
|
||||
static void propertynotify(XEvent *e);
|
||||
static void quit(const Arg *arg);
|
||||
static Monitor *recttomon(int x, int y, int w, int h);
|
||||
+static void removesystrayicon(Client *i);
|
||||
static void resize(Client *c, int x, int y, int w, int h, int interact);
|
||||
+static void resizebarwin(Monitor *m);
|
||||
static void resizeclient(Client *c, int x, int y, int w, int h);
|
||||
static void resizemouse(const Arg *arg);
|
||||
+static void resizerequest(XEvent *e);
|
||||
static void restack(Monitor *m);
|
||||
static void run(void);
|
||||
static void scan(void);
|
||||
-static int sendevent(Client *c, Atom proto);
|
||||
+static int sendevent(Window w, Atom proto, int m, long d0, long d1, long d2, long d3, long d4);
|
||||
static void sendmon(Client *c, Monitor *m);
|
||||
static void setclientstate(Client *c, long state);
|
||||
static void setfocus(Client *c);
|
||||
@@ -207,6 +233,7 @@ static void seturgent(Client *c, int urg);
|
||||
static void showhide(Client *c);
|
||||
static void sigchld(int unused);
|
||||
static void spawn(const Arg *arg);
|
||||
+static Monitor *systraytomon(Monitor *m);
|
||||
static void tag(const Arg *arg);
|
||||
static void tagmon(const Arg *arg);
|
||||
static void tile(Monitor *);
|
||||
@@ -224,20 +251,25 @@ static int updategeom(void);
|
||||
static void updatenumlockmask(void);
|
||||
static void updatesizehints(Client *c);
|
||||
static void updatestatus(void);
|
||||
+static void updatesystray(void);
|
||||
+static void updatesystrayicongeom(Client *i, int w, int h);
|
||||
+static void updatesystrayiconstate(Client *i, XPropertyEvent *ev);
|
||||
static void updatetitle(Client *c);
|
||||
static void updatewindowtype(Client *c);
|
||||
static void updatewmhints(Client *c);
|
||||
static void view(const Arg *arg);
|
||||
static Client *wintoclient(Window w);
|
||||
static Monitor *wintomon(Window w);
|
||||
+static Client *wintosystrayicon(Window w);
|
||||
static int xerror(Display *dpy, XErrorEvent *ee);
|
||||
static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
||||
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||
static void zoom(const Arg *arg);
|
||||
|
||||
/* variables */
|
||||
+static Systray *systray = NULL;
|
||||
static const char broken[] = "broken";
|
||||
-static char stext[256];
|
||||
+static char stext[1024];
|
||||
static int screen;
|
||||
static int sw, sh; /* X display screen geometry width, height */
|
||||
static int bh, blw = 0; /* bar geometry */
|
||||
@@ -258,9 +290,10 @@ static void (*handler[LASTEvent]) (XEvent *) = {
|
||||
[MapRequest] = maprequest,
|
||||
[MotionNotify] = motionnotify,
|
||||
[PropertyNotify] = propertynotify,
|
||||
+ [ResizeRequest] = resizerequest,
|
||||
[UnmapNotify] = unmapnotify
|
||||
};
|
||||
-static Atom wmatom[WMLast], netatom[NetLast];
|
||||
+static Atom wmatom[WMLast], netatom[NetLast], xatom[XLast];
|
||||
static int running = 1;
|
||||
static Cur *cursor[CurLast];
|
||||
static Clr **scheme;
|
||||
@@ -440,7 +473,7 @@ buttonpress(XEvent *e)
|
||||
arg.ui = 1 << i;
|
||||
} else if (ev->x < x + blw)
|
||||
click = ClkLtSymbol;
|
||||
- else if (ev->x > selmon->ww - (int)TEXTW(stext))
|
||||
+ else if (ev->x > selmon->ww - (int)TEXTW(stext) - getsystraywidth())
|
||||
click = ClkStatusText;
|
||||
else
|
||||
click = ClkWinTitle;
|
||||
@@ -483,9 +516,16 @@ cleanup(void)
|
||||
XUngrabKey(dpy, AnyKey, AnyModifier, root);
|
||||
while (mons)
|
||||
cleanupmon(mons);
|
||||
- for (i = 0; i < CurLast; i++)
|
||||
+
|
||||
+ if (showsystray) {
|
||||
+ XUnmapWindow(dpy, systray->win);
|
||||
+ XDestroyWindow(dpy, systray->win);
|
||||
+ free(systray);
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < CurLast; i++)
|
||||
drw_cur_free(drw, cursor[i]);
|
||||
- for (i = 0; i < LENGTH(colors); i++)
|
||||
+ for (i = 0; i < LENGTH(colors) + 1; i++)
|
||||
free(scheme[i]);
|
||||
XDestroyWindow(dpy, wmcheckwin);
|
||||
drw_free(drw);
|
||||
@@ -513,9 +553,58 @@ cleanupmon(Monitor *mon)
|
||||
void
|
||||
clientmessage(XEvent *e)
|
||||
{
|
||||
+ XWindowAttributes wa;
|
||||
+ XSetWindowAttributes swa;
|
||||
XClientMessageEvent *cme = &e->xclient;
|
||||
Client *c = wintoclient(cme->window);
|
||||
|
||||
+ if (showsystray && cme->window == systray->win && cme->message_type == netatom[NetSystemTrayOP]) {
|
||||
+ /* add systray icons */
|
||||
+ if (cme->data.l[1] == SYSTEM_TRAY_REQUEST_DOCK) {
|
||||
+ if (!(c = (Client *)calloc(1, sizeof(Client))))
|
||||
+ die("fatal: could not malloc() %u bytes\n", sizeof(Client));
|
||||
+ if (!(c->win = cme->data.l[2])) {
|
||||
+ free(c);
|
||||
+ return;
|
||||
+ }
|
||||
+ c->mon = selmon;
|
||||
+ c->next = systray->icons;
|
||||
+ systray->icons = c;
|
||||
+ if (!XGetWindowAttributes(dpy, c->win, &wa)) {
|
||||
+ /* use sane defaults */
|
||||
+ wa.width = bh;
|
||||
+ wa.height = bh;
|
||||
+ wa.border_width = 0;
|
||||
+ }
|
||||
+ c->x = c->oldx = c->y = c->oldy = 0;
|
||||
+ c->w = c->oldw = wa.width;
|
||||
+ c->h = c->oldh = wa.height;
|
||||
+ c->oldbw = wa.border_width;
|
||||
+ c->bw = 0;
|
||||
+ c->isfloating = True;
|
||||
+ /* reuse tags field as mapped status */
|
||||
+ c->tags = 1;
|
||||
+ updatesizehints(c);
|
||||
+ updatesystrayicongeom(c, wa.width, wa.height);
|
||||
+ XAddToSaveSet(dpy, c->win);
|
||||
+ XSelectInput(dpy, c->win, StructureNotifyMask | PropertyChangeMask | ResizeRedirectMask);
|
||||
+ XReparentWindow(dpy, c->win, systray->win, 0, 0);
|
||||
+ /* use parents background color */
|
||||
+ swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||
+ XChangeWindowAttributes(dpy, c->win, CWBackPixel, &swa);
|
||||
+ sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_EMBEDDED_NOTIFY, 0 , systray->win, XEMBED_EMBEDDED_VERSION);
|
||||
+ /* FIXME not sure if I have to send these events, too */
|
||||
+ sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_FOCUS_IN, 0 , systray->win, XEMBED_EMBEDDED_VERSION);
|
||||
+ sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_WINDOW_ACTIVATE, 0 , systray->win, XEMBED_EMBEDDED_VERSION);
|
||||
+ sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_MODALITY_ON, 0 , systray->win, XEMBED_EMBEDDED_VERSION);
|
||||
+ XSync(dpy, False);
|
||||
+ resizebarwin(selmon);
|
||||
+ updatesystray();
|
||||
+ setclientstate(c, NormalState);
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
if (!c)
|
||||
return;
|
||||
if (cme->message_type == netatom[NetWMState]) {
|
||||
@@ -568,7 +657,7 @@ configurenotify(XEvent *e)
|
||||
for (c = m->clients; c; c = c->next)
|
||||
if (c->isfullscreen)
|
||||
resizeclient(c, m->mx, m->my, m->mw, m->mh);
|
||||
- XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
|
||||
+ resizebarwin(m);
|
||||
}
|
||||
focus(NULL);
|
||||
arrange(NULL);
|
||||
@@ -653,6 +742,11 @@ destroynotify(XEvent *e)
|
||||
|
||||
if ((c = wintoclient(ev->window)))
|
||||
unmanage(c, 1);
|
||||
+ else if ((c = wintosystrayicon(ev->window))) {
|
||||
+ removesystrayicon(c);
|
||||
+ resizebarwin(selmon);
|
||||
+ updatesystray();
|
||||
+ }
|
||||
}
|
||||
|
||||
void
|
||||
@@ -693,10 +787,119 @@ dirtomon(int dir)
|
||||
return m;
|
||||
}
|
||||
|
||||
+int
|
||||
+drawstatusbar(Monitor *m, int bh, char* stext) {
|
||||
+ int ret, i, w, x, len;
|
||||
+ short isCode = 0;
|
||||
+ char *text;
|
||||
+ char *p;
|
||||
+
|
||||
+ len = strlen(stext) + 1 ;
|
||||
+ if (!(text = (char*) malloc(sizeof(char)*len)))
|
||||
+ die("malloc");
|
||||
+ p = text;
|
||||
+ memcpy(text, stext, len);
|
||||
+
|
||||
+ /* compute width of the status text */
|
||||
+ w = 0;
|
||||
+ i = -1;
|
||||
+ while (text[++i]) {
|
||||
+ if (text[i] == '^') {
|
||||
+ if (!isCode) {
|
||||
+ isCode = 1;
|
||||
+ text[i] = '\0';
|
||||
+ w += TEXTW(text) - lrpad;
|
||||
+ text[i] = '^';
|
||||
+ if (text[++i] == 'f')
|
||||
+ w += atoi(text + ++i);
|
||||
+ } else {
|
||||
+ isCode = 0;
|
||||
+ text = text + i + 1;
|
||||
+ i = -1;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ if (!isCode)
|
||||
+ w += TEXTW(text) - lrpad;
|
||||
+ else
|
||||
+ isCode = 0;
|
||||
+ text = p;
|
||||
+
|
||||
+ w += 2; /* 1px padding on both sides */
|
||||
+ ret = m->ww - w;
|
||||
+ x = m->ww - w - getsystraywidth();
|
||||
+
|
||||
+ drw_setscheme(drw, scheme[LENGTH(colors)]);
|
||||
+ drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
|
||||
+ drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
|
||||
+ drw_rect(drw, x, 0, w, bh, 1, 1);
|
||||
+ x++;
|
||||
+
|
||||
+ /* process status text */
|
||||
+ i = -1;
|
||||
+ while (text[++i]) {
|
||||
+ if (text[i] == '^' && !isCode) {
|
||||
+ isCode = 1;
|
||||
+
|
||||
+ text[i] = '\0';
|
||||
+ w = TEXTW(text) - lrpad;
|
||||
+ drw_text(drw, x, 0, w, bh, 0, text, 0);
|
||||
+
|
||||
+ x += w;
|
||||
+
|
||||
+ /* process code */
|
||||
+ while (text[++i] != '^') {
|
||||
+ if (text[i] == 'c') {
|
||||
+ char buf[8];
|
||||
+ memcpy(buf, (char*)text+i+1, 7);
|
||||
+ buf[7] = '\0';
|
||||
+ drw_clr_create(drw, &drw->scheme[ColFg], buf);
|
||||
+ i += 7;
|
||||
+ } else if (text[i] == 'b') {
|
||||
+ char buf[8];
|
||||
+ memcpy(buf, (char*)text+i+1, 7);
|
||||
+ buf[7] = '\0';
|
||||
+ drw_clr_create(drw, &drw->scheme[ColBg], buf);
|
||||
+ i += 7;
|
||||
+ } else if (text[i] == 'd') {
|
||||
+ drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
|
||||
+ drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
|
||||
+ } else if (text[i] == 'r') {
|
||||
+ int rx = atoi(text + ++i);
|
||||
+ while (text[++i] != ',');
|
||||
+ int ry = atoi(text + ++i);
|
||||
+ while (text[++i] != ',');
|
||||
+ int rw = atoi(text + ++i);
|
||||
+ while (text[++i] != ',');
|
||||
+ int rh = atoi(text + ++i);
|
||||
+
|
||||
+ drw_rect(drw, rx + x, ry, rw, rh, 1, 0);
|
||||
+ } else if (text[i] == 'f') {
|
||||
+ x += atoi(text + ++i);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ text = text + i + 1;
|
||||
+ i=-1;
|
||||
+ isCode = 0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!isCode) {
|
||||
+ w = TEXTW(text) - lrpad;
|
||||
+ drw_text(drw, x, 0, w, bh, 0, text, 0);
|
||||
+ }
|
||||
+
|
||||
+ drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
+ free(p);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
void
|
||||
drawbar(Monitor *m)
|
||||
{
|
||||
- int x, w, tw = 0;
|
||||
+ int x, w, tw = 0, stw = 0;
|
||||
int boxs = drw->fonts->h / 9;
|
||||
int boxw = drw->fonts->h / 6 + 2;
|
||||
unsigned int i, occ = 0, urg = 0;
|
||||
@@ -705,13 +908,15 @@ drawbar(Monitor *m)
|
||||
if (!m->showbar)
|
||||
return;
|
||||
|
||||
+ if(showsystray && m == systraytomon(m) && !systrayonleft)
|
||||
+ stw = getsystraywidth();
|
||||
+
|
||||
/* draw status first so it can be overdrawn by tags later */
|
||||
if (m == selmon) { /* status is only drawn on selected monitor */
|
||||
- drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
- tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
|
||||
- drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
|
||||
+ tw = m->ww - drawstatusbar(m, bh, stext);
|
||||
}
|
||||
|
||||
+ resizebarwin(m);
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
occ |= c->tags;
|
||||
if (c->isurgent)
|
||||
@@ -732,7 +937,7 @@ drawbar(Monitor *m)
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
|
||||
|
||||
- if ((w = m->ww - tw - x) > bh) {
|
||||
+ if ((w = m->ww - tw - stw - x) > bh) {
|
||||
if (m->sel) {
|
||||
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
|
||||
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
|
||||
@@ -743,7 +948,7 @@ drawbar(Monitor *m)
|
||||
drw_rect(drw, x, 0, w, bh, 1, 1);
|
||||
}
|
||||
}
|
||||
- drw_map(drw, m->barwin, 0, 0, m->ww, bh);
|
||||
+ drw_map(drw, m->barwin, 0, 0, m->ww - stw, bh);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -780,8 +985,11 @@ expose(XEvent *e)
|
||||
Monitor *m;
|
||||
XExposeEvent *ev = &e->xexpose;
|
||||
|
||||
- if (ev->count == 0 && (m = wintomon(ev->window)))
|
||||
+ if (ev->count == 0 && (m = wintomon(ev->window))) {
|
||||
drawbar(m);
|
||||
+ if (m == selmon)
|
||||
+ updatesystray();
|
||||
+ }
|
||||
}
|
||||
|
||||
void
|
||||
@@ -867,9 +1075,17 @@ getatomprop(Client *c, Atom prop)
|
||||
unsigned char *p = NULL;
|
||||
Atom da, atom = None;
|
||||
|
||||
- if (XGetWindowProperty(dpy, c->win, prop, 0L, sizeof atom, False, XA_ATOM,
|
||||
+ /* FIXME getatomprop should return the number of items and a pointer to
|
||||
+ * the stored data instead of this workaround */
|
||||
+ Atom req = XA_ATOM;
|
||||
+ if (prop == xatom[XembedInfo])
|
||||
+ req = xatom[XembedInfo];
|
||||
+
|
||||
+ if (XGetWindowProperty(dpy, c->win, prop, 0L, sizeof atom, False, req,
|
||||
&da, &di, &dl, &dl, &p) == Success && p) {
|
||||
atom = *(Atom *)p;
|
||||
+ if (da == xatom[XembedInfo] && dl == 2)
|
||||
+ atom = ((Atom *)p)[1];
|
||||
XFree(p);
|
||||
}
|
||||
return atom;
|
||||
@@ -903,6 +1119,16 @@ getstate(Window w)
|
||||
return result;
|
||||
}
|
||||
|
||||
+unsigned int
|
||||
+getsystraywidth()
|
||||
+{
|
||||
+ unsigned int w = 0;
|
||||
+ Client *i;
|
||||
+ if(showsystray)
|
||||
+ for(i = systray->icons; i; w += i->w + systrayspacing, i = i->next) ;
|
||||
+ return w ? w + systrayspacing : 1;
|
||||
+}
|
||||
+
|
||||
int
|
||||
gettextprop(Window w, Atom atom, char *text, unsigned int size)
|
||||
{
|
||||
@@ -1007,7 +1233,8 @@ killclient(const Arg *arg)
|
||||
{
|
||||
if (!selmon->sel)
|
||||
return;
|
||||
- if (!sendevent(selmon->sel, wmatom[WMDelete])) {
|
||||
+
|
||||
+ if (!sendevent(selmon->sel->win, wmatom[WMDelete], NoEventMask, wmatom[WMDelete], CurrentTime, 0 , 0, 0)) {
|
||||
XGrabServer(dpy);
|
||||
XSetErrorHandler(xerrordummy);
|
||||
XSetCloseDownMode(dpy, DestroyAll);
|
||||
@@ -1096,6 +1323,13 @@ maprequest(XEvent *e)
|
||||
static XWindowAttributes wa;
|
||||
XMapRequestEvent *ev = &e->xmaprequest;
|
||||
|
||||
+ Client *i;
|
||||
+ if ((i = wintosystrayicon(ev->window))) {
|
||||
+ sendevent(i->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_WINDOW_ACTIVATE, 0, systray->win, XEMBED_EMBEDDED_VERSION);
|
||||
+ resizebarwin(selmon);
|
||||
+ updatesystray();
|
||||
+ }
|
||||
+
|
||||
if (!XGetWindowAttributes(dpy, ev->window, &wa))
|
||||
return;
|
||||
if (wa.override_redirect)
|
||||
@@ -1219,7 +1453,18 @@ propertynotify(XEvent *e)
|
||||
Window trans;
|
||||
XPropertyEvent *ev = &e->xproperty;
|
||||
|
||||
- if ((ev->window == root) && (ev->atom == XA_WM_NAME))
|
||||
+ if ((c = wintosystrayicon(ev->window))) {
|
||||
+ if (ev->atom == XA_WM_NORMAL_HINTS) {
|
||||
+ updatesizehints(c);
|
||||
+ updatesystrayicongeom(c, c->w, c->h);
|
||||
+ }
|
||||
+ else
|
||||
+ updatesystrayiconstate(c, ev);
|
||||
+ resizebarwin(selmon);
|
||||
+ updatesystray();
|
||||
+ }
|
||||
+
|
||||
+ if ((ev->window == root) && (ev->atom == XA_WM_NAME))
|
||||
updatestatus();
|
||||
else if (ev->state == PropertyDelete)
|
||||
return; /* ignore */
|
||||
@@ -1269,6 +1514,19 @@ recttomon(int x, int y, int w, int h)
|
||||
return r;
|
||||
}
|
||||
|
||||
+void
|
||||
+removesystrayicon(Client *i)
|
||||
+{
|
||||
+ Client **ii;
|
||||
+
|
||||
+ if (!showsystray || !i)
|
||||
+ return;
|
||||
+ for (ii = &systray->icons; *ii && *ii != i; ii = &(*ii)->next);
|
||||
+ if (ii)
|
||||
+ *ii = i->next;
|
||||
+ free(i);
|
||||
+}
|
||||
+
|
||||
void
|
||||
resize(Client *c, int x, int y, int w, int h, int interact)
|
||||
{
|
||||
@@ -1276,6 +1534,14 @@ resize(Client *c, int x, int y, int w, int h, int interact)
|
||||
resizeclient(c, x, y, w, h);
|
||||
}
|
||||
|
||||
+void
|
||||
+resizebarwin(Monitor *m) {
|
||||
+ unsigned int w = m->ww;
|
||||
+ if (showsystray && m == systraytomon(m) && !systrayonleft)
|
||||
+ w -= getsystraywidth();
|
||||
+ XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, w, bh);
|
||||
+}
|
||||
+
|
||||
void
|
||||
resizeclient(Client *c, int x, int y, int w, int h)
|
||||
{
|
||||
@@ -1348,6 +1614,19 @@ resizemouse(const Arg *arg)
|
||||
}
|
||||
}
|
||||
|
||||
+void
|
||||
+resizerequest(XEvent *e)
|
||||
+{
|
||||
+ XResizeRequestEvent *ev = &e->xresizerequest;
|
||||
+ Client *i;
|
||||
+
|
||||
+ if ((i = wintosystrayicon(ev->window))) {
|
||||
+ updatesystrayicongeom(i, ev->width, ev->height);
|
||||
+ resizebarwin(selmon);
|
||||
+ updatesystray();
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
restack(Monitor *m)
|
||||
{
|
||||
@@ -1437,26 +1716,37 @@ setclientstate(Client *c, long state)
|
||||
}
|
||||
|
||||
int
|
||||
-sendevent(Client *c, Atom proto)
|
||||
+sendevent(Window w, Atom proto, int mask, long d0, long d1, long d2, long d3, long d4)
|
||||
{
|
||||
int n;
|
||||
- Atom *protocols;
|
||||
+ Atom *protocols, mt;
|
||||
int exists = 0;
|
||||
XEvent ev;
|
||||
|
||||
- if (XGetWMProtocols(dpy, c->win, &protocols, &n)) {
|
||||
- while (!exists && n--)
|
||||
- exists = protocols[n] == proto;
|
||||
- XFree(protocols);
|
||||
+ if (proto == wmatom[WMTakeFocus] || proto == wmatom[WMDelete]) {
|
||||
+ mt = wmatom[WMProtocols];
|
||||
+ if (XGetWMProtocols(dpy, w, &protocols, &n)) {
|
||||
+ while (!exists && n--)
|
||||
+ exists = protocols[n] == proto;
|
||||
+ XFree(protocols);
|
||||
+ }
|
||||
}
|
||||
+ else {
|
||||
+ exists = True;
|
||||
+ mt = proto;
|
||||
+ }
|
||||
+
|
||||
if (exists) {
|
||||
ev.type = ClientMessage;
|
||||
- ev.xclient.window = c->win;
|
||||
- ev.xclient.message_type = wmatom[WMProtocols];
|
||||
+ ev.xclient.window = w;
|
||||
+ ev.xclient.message_type = mt;
|
||||
ev.xclient.format = 32;
|
||||
- ev.xclient.data.l[0] = proto;
|
||||
- ev.xclient.data.l[1] = CurrentTime;
|
||||
- XSendEvent(dpy, c->win, False, NoEventMask, &ev);
|
||||
+ ev.xclient.data.l[0] = d0;
|
||||
+ ev.xclient.data.l[1] = d1;
|
||||
+ ev.xclient.data.l[2] = d2;
|
||||
+ ev.xclient.data.l[3] = d3;
|
||||
+ ev.xclient.data.l[4] = d4;
|
||||
+ XSendEvent(dpy, w, False, mask, &ev);
|
||||
}
|
||||
return exists;
|
||||
}
|
||||
@@ -1470,7 +1760,7 @@ setfocus(Client *c)
|
||||
XA_WINDOW, 32, PropModeReplace,
|
||||
(unsigned char *) &(c->win), 1);
|
||||
}
|
||||
- sendevent(c, wmatom[WMTakeFocus]);
|
||||
+ sendevent(c->win, wmatom[WMTakeFocus], NoEventMask, wmatom[WMTakeFocus], CurrentTime, 0, 0, 0);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1558,22 +1848,32 @@ setup(void)
|
||||
wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
|
||||
wmatom[WMTakeFocus] = XInternAtom(dpy, "WM_TAKE_FOCUS", False);
|
||||
netatom[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
|
||||
- netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
|
||||
- netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
|
||||
+ netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
|
||||
+ netatom[NetSystemTray] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_S0", False);
|
||||
+ netatom[NetSystemTrayOP] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_OPCODE", False);
|
||||
+ netatom[NetSystemTrayOrientation] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_ORIENTATION", False);
|
||||
+ netatom[NetSystemTrayOrientationHorz] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_ORIENTATION_HORZ", False);
|
||||
+ netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
|
||||
netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False);
|
||||
netatom[NetWMCheck] = XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False);
|
||||
netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);
|
||||
netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
|
||||
netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
|
||||
netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
|
||||
- /* init cursors */
|
||||
+ xatom[Manager] = XInternAtom(dpy, "MANAGER", False);
|
||||
+ xatom[Xembed] = XInternAtom(dpy, "_XEMBED", False);
|
||||
+ xatom[XembedInfo] = XInternAtom(dpy, "_XEMBED_INFO", False);
|
||||
+ /* init cursors */
|
||||
cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
|
||||
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
|
||||
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
|
||||
/* init appearance */
|
||||
- scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
|
||||
+ scheme = ecalloc(LENGTH(colors) + 1, sizeof(Clr *));
|
||||
+ scheme[LENGTH(colors)] = drw_scm_create(drw, colors[0], 3);
|
||||
for (i = 0; i < LENGTH(colors); i++)
|
||||
scheme[i] = drw_scm_create(drw, colors[i], 3);
|
||||
+ /* init system tray */
|
||||
+ updatesystray();
|
||||
/* init bars */
|
||||
updatebars();
|
||||
updatestatus();
|
||||
@@ -1707,7 +2007,18 @@ togglebar(const Arg *arg)
|
||||
{
|
||||
selmon->showbar = !selmon->showbar;
|
||||
updatebarpos(selmon);
|
||||
- XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
|
||||
+ resizebarwin(selmon);
|
||||
+ if (showsystray) {
|
||||
+ XWindowChanges wc;
|
||||
+ if (!selmon->showbar)
|
||||
+ wc.y = -bh;
|
||||
+ else if (selmon->showbar) {
|
||||
+ wc.y = 0;
|
||||
+ if (!selmon->topbar)
|
||||
+ wc.y = selmon->mh - bh;
|
||||
+ }
|
||||
+ XConfigureWindow(dpy, systray->win, CWY, &wc);
|
||||
+ }
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
@@ -1802,11 +2113,18 @@ unmapnotify(XEvent *e)
|
||||
else
|
||||
unmanage(c, 0);
|
||||
}
|
||||
+ else if ((c = wintosystrayicon(ev->window))) {
|
||||
+ /* KLUDGE! sometimes icons occasionally unmap their windows, but do
|
||||
+ * _not_ destroy them. We map those windows back */
|
||||
+ XMapRaised(dpy, c->win);
|
||||
+ updatesystray();
|
||||
+ }
|
||||
}
|
||||
|
||||
void
|
||||
updatebars(void)
|
||||
{
|
||||
+ unsigned int w;
|
||||
Monitor *m;
|
||||
XSetWindowAttributes wa = {
|
||||
.override_redirect = True,
|
||||
@@ -1817,10 +2135,15 @@ updatebars(void)
|
||||
for (m = mons; m; m = m->next) {
|
||||
if (m->barwin)
|
||||
continue;
|
||||
- m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen),
|
||||
+ w = m->ww;
|
||||
+ if (showsystray && m == systraytomon(m))
|
||||
+ w -= getsystraywidth();
|
||||
+ m->barwin = XCreateWindow(dpy, root, m->wx, m->by, w, bh, 0, DefaultDepth(dpy, screen),
|
||||
CopyFromParent, DefaultVisual(dpy, screen),
|
||||
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
|
||||
XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
|
||||
+ if (showsystray && m == systraytomon(m))
|
||||
+ XMapRaised(dpy, systray->win);
|
||||
XMapRaised(dpy, m->barwin);
|
||||
XSetClassHint(dpy, m->barwin, &ch);
|
||||
}
|
||||
@@ -1996,6 +2319,125 @@ updatestatus(void)
|
||||
if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
|
||||
strcpy(stext, "dwm-"VERSION);
|
||||
drawbar(selmon);
|
||||
+ updatesystray();
|
||||
+}
|
||||
+
|
||||
+
|
||||
+void
|
||||
+updatesystrayicongeom(Client *i, int w, int h)
|
||||
+{
|
||||
+ if (i) {
|
||||
+ i->h = bh;
|
||||
+ if (w == h)
|
||||
+ i->w = bh;
|
||||
+ else if (h == bh)
|
||||
+ i->w = w;
|
||||
+ else
|
||||
+ i->w = (int) ((float)bh * ((float)w / (float)h));
|
||||
+ applysizehints(i, &(i->x), &(i->y), &(i->w), &(i->h), False);
|
||||
+ /* force icons into the systray dimensions if they don't want to */
|
||||
+ if (i->h > bh) {
|
||||
+ if (i->w == i->h)
|
||||
+ i->w = bh;
|
||||
+ else
|
||||
+ i->w = (int) ((float)bh * ((float)i->w / (float)i->h));
|
||||
+ i->h = bh;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+updatesystrayiconstate(Client *i, XPropertyEvent *ev)
|
||||
+{
|
||||
+ long flags;
|
||||
+ int code = 0;
|
||||
+
|
||||
+ if (!showsystray || !i || ev->atom != xatom[XembedInfo] ||
|
||||
+ !(flags = getatomprop(i, xatom[XembedInfo])))
|
||||
+ return;
|
||||
+
|
||||
+ if (flags & XEMBED_MAPPED && !i->tags) {
|
||||
+ i->tags = 1;
|
||||
+ code = XEMBED_WINDOW_ACTIVATE;
|
||||
+ XMapRaised(dpy, i->win);
|
||||
+ setclientstate(i, NormalState);
|
||||
+ }
|
||||
+ else if (!(flags & XEMBED_MAPPED) && i->tags) {
|
||||
+ i->tags = 0;
|
||||
+ code = XEMBED_WINDOW_DEACTIVATE;
|
||||
+ XUnmapWindow(dpy, i->win);
|
||||
+ setclientstate(i, WithdrawnState);
|
||||
+ }
|
||||
+ else
|
||||
+ return;
|
||||
+ sendevent(i->win, xatom[Xembed], StructureNotifyMask, CurrentTime, code, 0,
|
||||
+ systray->win, XEMBED_EMBEDDED_VERSION);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+updatesystray(void)
|
||||
+{
|
||||
+ XSetWindowAttributes wa;
|
||||
+ XWindowChanges wc;
|
||||
+ Client *i;
|
||||
+ Monitor *m = systraytomon(NULL);
|
||||
+ unsigned int x = m->mx + m->mw;
|
||||
+ unsigned int sw = TEXTW(stext) - lrpad + systrayspacing;
|
||||
+ unsigned int w = 1;
|
||||
+
|
||||
+ if (!showsystray)
|
||||
+ return;
|
||||
+ if (systrayonleft)
|
||||
+ x -= sw + lrpad / 2;
|
||||
+ if (!systray) {
|
||||
+ /* init systray */
|
||||
+ if (!(systray = (Systray *)calloc(1, sizeof(Systray))))
|
||||
+ die("fatal: could not malloc() %u bytes\n", sizeof(Systray));
|
||||
+ systray->win = XCreateSimpleWindow(dpy, root, x, m->by, w, bh, 0, 0, scheme[SchemeSel][ColBg].pixel);
|
||||
+ wa.event_mask = ButtonPressMask | ExposureMask;
|
||||
+ wa.override_redirect = True;
|
||||
+ wa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||
+ XSelectInput(dpy, systray->win, SubstructureNotifyMask);
|
||||
+ XChangeProperty(dpy, systray->win, netatom[NetSystemTrayOrientation], XA_CARDINAL, 32,
|
||||
+ PropModeReplace, (unsigned char *)&netatom[NetSystemTrayOrientationHorz], 1);
|
||||
+ XChangeWindowAttributes(dpy, systray->win, CWEventMask|CWOverrideRedirect|CWBackPixel, &wa);
|
||||
+ XMapRaised(dpy, systray->win);
|
||||
+ XSetSelectionOwner(dpy, netatom[NetSystemTray], systray->win, CurrentTime);
|
||||
+ if (XGetSelectionOwner(dpy, netatom[NetSystemTray]) == systray->win) {
|
||||
+ sendevent(root, xatom[Manager], StructureNotifyMask, CurrentTime, netatom[NetSystemTray], systray->win, 0, 0);
|
||||
+ XSync(dpy, False);
|
||||
+ }
|
||||
+ else {
|
||||
+ fprintf(stderr, "dwm: unable to obtain system tray.\n");
|
||||
+ free(systray);
|
||||
+ systray = NULL;
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ for (w = 0, i = systray->icons; i; i = i->next) {
|
||||
+ /* make sure the background color stays the same */
|
||||
+ wa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||
+ XChangeWindowAttributes(dpy, i->win, CWBackPixel, &wa);
|
||||
+ XMapRaised(dpy, i->win);
|
||||
+ w += systrayspacing;
|
||||
+ i->x = w;
|
||||
+ XMoveResizeWindow(dpy, i->win, i->x, 0, i->w, i->h);
|
||||
+ w += i->w;
|
||||
+ if (i->mon != m)
|
||||
+ i->mon = m;
|
||||
+ }
|
||||
+ w = w ? w + systrayspacing : 1;
|
||||
+ x -= w;
|
||||
+ XMoveResizeWindow(dpy, systray->win, x, m->by, w, bh);
|
||||
+ wc.x = x; wc.y = m->by; wc.width = w; wc.height = bh;
|
||||
+ wc.stack_mode = Above; wc.sibling = m->barwin;
|
||||
+ XConfigureWindow(dpy, systray->win, CWX|CWY|CWWidth|CWHeight|CWSibling|CWStackMode, &wc);
|
||||
+ XMapWindow(dpy, systray->win);
|
||||
+ XMapSubwindows(dpy, systray->win);
|
||||
+ /* redraw background */
|
||||
+ XSetForeground(dpy, drw->gc, scheme[SchemeNorm][ColBg].pixel);
|
||||
+ XFillRectangle(dpy, systray->win, drw->gc, 0, 0, w, bh);
|
||||
+ XSync(dpy, False);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2063,6 +2505,16 @@ wintoclient(Window w)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+Client *
|
||||
+wintosystrayicon(Window w) {
|
||||
+ Client *i = NULL;
|
||||
+
|
||||
+ if (!showsystray || !w)
|
||||
+ return i;
|
||||
+ for (i = systray->icons; i && i->win != w; i = i->next) ;
|
||||
+ return i;
|
||||
+}
|
||||
+
|
||||
Monitor *
|
||||
wintomon(Window w)
|
||||
{
|
||||
@@ -2116,6 +2568,22 @@ xerrorstart(Display *dpy, XErrorEvent *ee)
|
||||
return -1;
|
||||
}
|
||||
|
||||
+Monitor *
|
||||
+systraytomon(Monitor *m) {
|
||||
+ Monitor *t;
|
||||
+ int i, n;
|
||||
+ if(!systraypinning) {
|
||||
+ if(!m)
|
||||
+ return selmon;
|
||||
+ return m == selmon ? m : NULL;
|
||||
+ }
|
||||
+ for(n = 1, t = mons; t && t->next; n++, t = t->next) ;
|
||||
+ for(i = 1, t = mons; t && t->next && i < systraypinning; i++, t = t->next) ;
|
||||
+ if(systraypinningfailfirst && n < systraypinning)
|
||||
+ return mons;
|
||||
+ return t;
|
||||
+}
|
||||
+
|
||||
void
|
||||
zoom(const Arg *arg)
|
||||
{
|
||||
@@ -0,0 +1,47 @@
|
||||
From 45a45a0e67f3841d8c4aed2c52b57c2a7ddf2a9a Mon Sep 17 00:00:00 2001
|
||||
From: Jack Bird <jack.bird@durham.ac.uk>
|
||||
Date: Sun, 15 Aug 2021 23:15:52 +0100
|
||||
Subject: [PATCH] Updated title color patch for 7162335
|
||||
|
||||
---
|
||||
config.def.h | 1 +
|
||||
dwm.c | 4 ++--
|
||||
2 files changed, 3 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index a2ac963..5b9ae00 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -16,6 +16,7 @@ static const char *colors[][3] = {
|
||||
/* fg bg border */
|
||||
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
||||
+ [SchemeTitle] = { col_gray4, col_cyan, col_cyan },
|
||||
};
|
||||
|
||||
/* tagging */
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 5e4d494..73d335e 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -59,7 +59,7 @@
|
||||
|
||||
/* enums */
|
||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||
-enum { SchemeNorm, SchemeSel }; /* color schemes */
|
||||
+enum { SchemeNorm, SchemeSel, SchemeTitle }; /* color schemes */
|
||||
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
||||
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
||||
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
|
||||
@@ -731,7 +731,7 @@ drawbar(Monitor *m)
|
||||
|
||||
if ((w = m->ww - tw - x) > bh) {
|
||||
if (m->sel) {
|
||||
- drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
|
||||
+ drw_setscheme(drw, scheme[m == selmon ? SchemeTitle : SchemeNorm]);
|
||||
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
|
||||
if (m->sel->isfloating)
|
||||
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
|
||||
--
|
||||
2.32.0
|
||||
|
||||
371
KleinDwm/source/patches/dwm-winicon-6.3-v2.1.diff
Normal file
371
KleinDwm/source/patches/dwm-winicon-6.3-v2.1.diff
Normal file
@@ -0,0 +1,371 @@
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index a2ac963..322d181 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -5,6 +5,8 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||
static const unsigned int snap = 32; /* snap pixel */
|
||||
static const int showbar = 1; /* 0 means no bar */
|
||||
static const int topbar = 1; /* 0 means bottom bar */
|
||||
+#define ICONSIZE 16 /* icon size */
|
||||
+#define ICONSPACING 5 /* space between icon and title */
|
||||
static const char *fonts[] = { "monospace:size=10" };
|
||||
static const char dmenufont[] = "monospace:size=10";
|
||||
static const char col_gray1[] = "#222222";
|
||||
diff --git a/config.mk b/config.mk
|
||||
index b6eb7e0..f3c01b0 100644
|
||||
--- a/config.mk
|
||||
+++ b/config.mk
|
||||
@@ -22,7 +22,7 @@ FREETYPEINC = /usr/include/freetype2
|
||||
|
||||
# includes and libs
|
||||
INCS = -I${X11INC} -I${FREETYPEINC}
|
||||
-LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
|
||||
+LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXrender -lImlib2
|
||||
|
||||
# flags
|
||||
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||
diff --git a/drw.c b/drw.c
|
||||
index 4cdbcbe..9b474c5 100644
|
||||
--- a/drw.c
|
||||
+++ b/drw.c
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xft/Xft.h>
|
||||
+#include <Imlib2.h>
|
||||
|
||||
#include "drw.h"
|
||||
#include "util.h"
|
||||
@@ -71,6 +72,7 @@ drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h
|
||||
drw->w = w;
|
||||
drw->h = h;
|
||||
drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen));
|
||||
+ drw->picture = XRenderCreatePicture(dpy, drw->drawable, XRenderFindVisualFormat(dpy, DefaultVisual(dpy, screen)), 0, NULL);
|
||||
drw->gc = XCreateGC(dpy, root, 0, NULL);
|
||||
XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter);
|
||||
|
||||
@@ -85,14 +87,18 @@ drw_resize(Drw *drw, unsigned int w, unsigned int h)
|
||||
|
||||
drw->w = w;
|
||||
drw->h = h;
|
||||
+ if (drw->picture)
|
||||
+ XRenderFreePicture(drw->dpy, drw->picture);
|
||||
if (drw->drawable)
|
||||
XFreePixmap(drw->dpy, drw->drawable);
|
||||
drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen));
|
||||
+ drw->picture = XRenderCreatePicture(drw->dpy, drw->drawable, XRenderFindVisualFormat(drw->dpy, DefaultVisual(drw->dpy, drw->screen)), 0, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
drw_free(Drw *drw)
|
||||
{
|
||||
+ XRenderFreePicture(drw->dpy, drw->picture);
|
||||
XFreePixmap(drw->dpy, drw->drawable);
|
||||
XFreeGC(drw->dpy, drw->gc);
|
||||
drw_fontset_free(drw->fonts);
|
||||
@@ -236,6 +242,67 @@ drw_setscheme(Drw *drw, Clr *scm)
|
||||
drw->scheme = scm;
|
||||
}
|
||||
|
||||
+Picture
|
||||
+drw_picture_create_resized(Drw *drw, char *src, unsigned int srcw, unsigned int srch, unsigned int dstw, unsigned int dsth) {
|
||||
+ Pixmap pm;
|
||||
+ Picture pic;
|
||||
+ GC gc;
|
||||
+
|
||||
+ if (srcw <= (dstw << 1u) && srch <= (dsth << 1u)) {
|
||||
+ XImage img = {
|
||||
+ srcw, srch, 0, ZPixmap, src,
|
||||
+ ImageByteOrder(drw->dpy), BitmapUnit(drw->dpy), BitmapBitOrder(drw->dpy), 32,
|
||||
+ 32, 0, 32,
|
||||
+ 0, 0, 0
|
||||
+ };
|
||||
+ XInitImage(&img);
|
||||
+
|
||||
+ pm = XCreatePixmap(drw->dpy, drw->root, srcw, srch, 32);
|
||||
+ gc = XCreateGC(drw->dpy, pm, 0, NULL);
|
||||
+ XPutImage(drw->dpy, pm, gc, &img, 0, 0, 0, 0, srcw, srch);
|
||||
+ XFreeGC(drw->dpy, gc);
|
||||
+
|
||||
+ pic = XRenderCreatePicture(drw->dpy, pm, XRenderFindStandardFormat(drw->dpy, PictStandardARGB32), 0, NULL);
|
||||
+ XFreePixmap(drw->dpy, pm);
|
||||
+
|
||||
+ XRenderSetPictureFilter(drw->dpy, pic, FilterBilinear, NULL, 0);
|
||||
+ XTransform xf;
|
||||
+ xf.matrix[0][0] = (srcw << 16u) / dstw; xf.matrix[0][1] = 0; xf.matrix[0][2] = 0;
|
||||
+ xf.matrix[1][0] = 0; xf.matrix[1][1] = (srch << 16u) / dsth; xf.matrix[1][2] = 0;
|
||||
+ xf.matrix[2][0] = 0; xf.matrix[2][1] = 0; xf.matrix[2][2] = 65536;
|
||||
+ XRenderSetPictureTransform(drw->dpy, pic, &xf);
|
||||
+ } else {
|
||||
+ Imlib_Image origin = imlib_create_image_using_data(srcw, srch, (DATA32 *)src);
|
||||
+ if (!origin) return None;
|
||||
+ imlib_context_set_image(origin);
|
||||
+ imlib_image_set_has_alpha(1);
|
||||
+ Imlib_Image scaled = imlib_create_cropped_scaled_image(0, 0, srcw, srch, dstw, dsth);
|
||||
+ imlib_free_image_and_decache();
|
||||
+ if (!scaled) return None;
|
||||
+ imlib_context_set_image(scaled);
|
||||
+ imlib_image_set_has_alpha(1);
|
||||
+
|
||||
+ XImage img = {
|
||||
+ dstw, dsth, 0, ZPixmap, (char *)imlib_image_get_data_for_reading_only(),
|
||||
+ ImageByteOrder(drw->dpy), BitmapUnit(drw->dpy), BitmapBitOrder(drw->dpy), 32,
|
||||
+ 32, 0, 32,
|
||||
+ 0, 0, 0
|
||||
+ };
|
||||
+ XInitImage(&img);
|
||||
+
|
||||
+ pm = XCreatePixmap(drw->dpy, drw->root, dstw, dsth, 32);
|
||||
+ gc = XCreateGC(drw->dpy, pm, 0, NULL);
|
||||
+ XPutImage(drw->dpy, pm, gc, &img, 0, 0, 0, 0, dstw, dsth);
|
||||
+ imlib_free_image_and_decache();
|
||||
+ XFreeGC(drw->dpy, gc);
|
||||
+
|
||||
+ pic = XRenderCreatePicture(drw->dpy, pm, XRenderFindStandardFormat(drw->dpy, PictStandardARGB32), 0, NULL);
|
||||
+ XFreePixmap(drw->dpy, pm);
|
||||
+ }
|
||||
+
|
||||
+ return pic;
|
||||
+}
|
||||
+
|
||||
void
|
||||
drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert)
|
||||
{
|
||||
@@ -379,6 +446,14 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
||||
return x + (render ? w : 0);
|
||||
}
|
||||
|
||||
+void
|
||||
+drw_pic(Drw *drw, int x, int y, unsigned int w, unsigned int h, Picture pic)
|
||||
+{
|
||||
+ if (!drw)
|
||||
+ return;
|
||||
+ XRenderComposite(drw->dpy, PictOpOver, pic, None, drw->picture, 0, 0, 0, 0, x, y, w, h);
|
||||
+}
|
||||
+
|
||||
void
|
||||
drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h)
|
||||
{
|
||||
diff --git a/drw.h b/drw.h
|
||||
index 4bcd5ad..71aefa2 100644
|
||||
--- a/drw.h
|
||||
+++ b/drw.h
|
||||
@@ -21,6 +21,7 @@ typedef struct {
|
||||
int screen;
|
||||
Window root;
|
||||
Drawable drawable;
|
||||
+ Picture picture;
|
||||
GC gc;
|
||||
Clr *scheme;
|
||||
Fnt *fonts;
|
||||
@@ -49,9 +50,12 @@ void drw_cur_free(Drw *drw, Cur *cursor);
|
||||
void drw_setfontset(Drw *drw, Fnt *set);
|
||||
void drw_setscheme(Drw *drw, Clr *scm);
|
||||
|
||||
+Picture drw_picture_create_resized(Drw *drw, char *src, unsigned int src_w, unsigned int src_h, unsigned int dst_w, unsigned int dst_h);
|
||||
+
|
||||
/* Drawing functions */
|
||||
void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert);
|
||||
int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert);
|
||||
+void drw_pic(Drw *drw, int x, int y, unsigned int w, unsigned int h, Picture pic);
|
||||
|
||||
/* Map functions */
|
||||
void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index a96f33c..033ccec 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
+#include <limits.h>
|
||||
+#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <X11/cursorfont.h>
|
||||
@@ -60,7 +62,7 @@
|
||||
/* enums */
|
||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||
enum { SchemeNorm, SchemeSel }; /* color schemes */
|
||||
-enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
||||
+enum { NetSupported, NetWMName, NetWMIcon, NetWMState, NetWMCheck,
|
||||
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
||||
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
|
||||
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
|
||||
@@ -93,6 +95,7 @@ struct Client {
|
||||
int bw, oldbw;
|
||||
unsigned int tags;
|
||||
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
|
||||
+ unsigned int icw, ich; Picture icon;
|
||||
Client *next;
|
||||
Client *snext;
|
||||
Monitor *mon;
|
||||
@@ -170,6 +173,7 @@ static void focusin(XEvent *e);
|
||||
static void focusmon(const Arg *arg);
|
||||
static void focusstack(const Arg *arg);
|
||||
static Atom getatomprop(Client *c, Atom prop);
|
||||
+static Picture geticonprop(Window w, unsigned int *icw, unsigned int *ich);
|
||||
static int getrootptr(int *x, int *y);
|
||||
static long getstate(Window w);
|
||||
static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
|
||||
@@ -214,6 +218,7 @@ static void togglebar(const Arg *arg);
|
||||
static void togglefloating(const Arg *arg);
|
||||
static void toggletag(const Arg *arg);
|
||||
static void toggleview(const Arg *arg);
|
||||
+static void freeicon(Client *c);
|
||||
static void unfocus(Client *c, int setfocus);
|
||||
static void unmanage(Client *c, int destroyed);
|
||||
static void unmapnotify(XEvent *e);
|
||||
@@ -225,6 +230,7 @@ static void updatenumlockmask(void);
|
||||
static void updatesizehints(Client *c);
|
||||
static void updatestatus(void);
|
||||
static void updatetitle(Client *c);
|
||||
+static void updateicon(Client *c);
|
||||
static void updatewindowtype(Client *c);
|
||||
static void updatewmhints(Client *c);
|
||||
static void view(const Arg *arg);
|
||||
@@ -735,7 +741,8 @@ drawbar(Monitor *m)
|
||||
if ((w = m->ww - tw - x) > bh) {
|
||||
if (m->sel) {
|
||||
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
|
||||
- drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
|
||||
+ drw_text(drw, x, 0, w, bh, lrpad / 2 + (m->sel->icon ? m->sel->icw + ICONSPACING : 0), m->sel->name, 0);
|
||||
+ if (m->sel->icon) drw_pic(drw, x + lrpad / 2, (bh - m->sel->ich) / 2, m->sel->icw, m->sel->ich, m->sel->icon);
|
||||
if (m->sel->isfloating)
|
||||
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
|
||||
} else {
|
||||
@@ -875,6 +882,67 @@ getatomprop(Client *c, Atom prop)
|
||||
return atom;
|
||||
}
|
||||
|
||||
+static uint32_t prealpha(uint32_t p) {
|
||||
+ uint8_t a = p >> 24u;
|
||||
+ uint32_t rb = (a * (p & 0xFF00FFu)) >> 8u;
|
||||
+ uint32_t g = (a * (p & 0x00FF00u)) >> 8u;
|
||||
+ return (rb & 0xFF00FFu) | (g & 0x00FF00u) | (a << 24u);
|
||||
+}
|
||||
+
|
||||
+Picture
|
||||
+geticonprop(Window win, unsigned int *picw, unsigned int *pich)
|
||||
+{
|
||||
+ int format;
|
||||
+ unsigned long n, extra, *p = NULL;
|
||||
+ Atom real;
|
||||
+
|
||||
+ if (XGetWindowProperty(dpy, win, netatom[NetWMIcon], 0L, LONG_MAX, False, AnyPropertyType,
|
||||
+ &real, &format, &n, &extra, (unsigned char **)&p) != Success)
|
||||
+ return None;
|
||||
+ if (n == 0 || format != 32) { XFree(p); return None; }
|
||||
+
|
||||
+ unsigned long *bstp = NULL;
|
||||
+ uint32_t w, h, sz;
|
||||
+ {
|
||||
+ unsigned long *i; const unsigned long *end = p + n;
|
||||
+ uint32_t bstd = UINT32_MAX, d, m;
|
||||
+ for (i = p; i < end - 1; i += sz) {
|
||||
+ if ((w = *i++) >= 16384 || (h = *i++) >= 16384) { XFree(p); return None; }
|
||||
+ if ((sz = w * h) > end - i) break;
|
||||
+ if ((m = w > h ? w : h) >= ICONSIZE && (d = m - ICONSIZE) < bstd) { bstd = d; bstp = i; }
|
||||
+ }
|
||||
+ if (!bstp) {
|
||||
+ for (i = p; i < end - 1; i += sz) {
|
||||
+ if ((w = *i++) >= 16384 || (h = *i++) >= 16384) { XFree(p); return None; }
|
||||
+ if ((sz = w * h) > end - i) break;
|
||||
+ if ((d = ICONSIZE - (w > h ? w : h)) < bstd) { bstd = d; bstp = i; }
|
||||
+ }
|
||||
+ }
|
||||
+ if (!bstp) { XFree(p); return None; }
|
||||
+ }
|
||||
+
|
||||
+ if ((w = *(bstp - 2)) == 0 || (h = *(bstp - 1)) == 0) { XFree(p); return None; }
|
||||
+
|
||||
+ uint32_t icw, ich;
|
||||
+ if (w <= h) {
|
||||
+ ich = ICONSIZE; icw = w * ICONSIZE / h;
|
||||
+ if (icw == 0) icw = 1;
|
||||
+ }
|
||||
+ else {
|
||||
+ icw = ICONSIZE; ich = h * ICONSIZE / w;
|
||||
+ if (ich == 0) ich = 1;
|
||||
+ }
|
||||
+ *picw = icw; *pich = ich;
|
||||
+
|
||||
+ uint32_t i, *bstp32 = (uint32_t *)bstp;
|
||||
+ for (sz = w * h, i = 0; i < sz; ++i) bstp32[i] = prealpha(bstp[i]);
|
||||
+
|
||||
+ Picture ret = drw_picture_create_resized(drw, (char *)bstp, w, h, icw, ich);
|
||||
+ XFree(p);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
int
|
||||
getrootptr(int *x, int *y)
|
||||
{
|
||||
@@ -1034,6 +1102,7 @@ manage(Window w, XWindowAttributes *wa)
|
||||
c->h = c->oldh = wa->height;
|
||||
c->oldbw = wa->border_width;
|
||||
|
||||
+ updateicon(c);
|
||||
updatetitle(c);
|
||||
if (XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) {
|
||||
c->mon = t->mon;
|
||||
@@ -1244,6 +1313,11 @@ propertynotify(XEvent *e)
|
||||
if (c == c->mon->sel)
|
||||
drawbar(c->mon);
|
||||
}
|
||||
+ else if (ev->atom == netatom[NetWMIcon]) {
|
||||
+ updateicon(c);
|
||||
+ if (c == c->mon->sel)
|
||||
+ drawbar(c->mon);
|
||||
+ }
|
||||
if (ev->atom == netatom[NetWMWindowType])
|
||||
updatewindowtype(c);
|
||||
}
|
||||
@@ -1560,6 +1634,7 @@ setup(void)
|
||||
netatom[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
|
||||
netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
|
||||
netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
|
||||
+ netatom[NetWMIcon] = XInternAtom(dpy, "_NET_WM_ICON", False);
|
||||
netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False);
|
||||
netatom[NetWMCheck] = XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False);
|
||||
netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);
|
||||
@@ -1752,6 +1827,15 @@ toggleview(const Arg *arg)
|
||||
}
|
||||
}
|
||||
|
||||
+void
|
||||
+freeicon(Client *c)
|
||||
+{
|
||||
+ if (c->icon) {
|
||||
+ XRenderFreePicture(dpy, c->icon);
|
||||
+ c->icon = None;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
unfocus(Client *c, int setfocus)
|
||||
{
|
||||
@@ -1773,6 +1857,7 @@ unmanage(Client *c, int destroyed)
|
||||
|
||||
detach(c);
|
||||
detachstack(c);
|
||||
+ freeicon(c);
|
||||
if (!destroyed) {
|
||||
wc.border_width = c->oldbw;
|
||||
XGrabServer(dpy); /* avoid race conditions */
|
||||
@@ -2007,6 +2092,13 @@ updatetitle(Client *c)
|
||||
strcpy(c->name, broken);
|
||||
}
|
||||
|
||||
+void
|
||||
+updateicon(Client *c)
|
||||
+{
|
||||
+ freeicon(c);
|
||||
+ c->icon = geticonprop(c->win, &c->icw, &c->ich);
|
||||
+}
|
||||
+
|
||||
void
|
||||
updatewindowtype(Client *c)
|
||||
{
|
||||
496
KleinDwm/source/tags
Normal file
496
KleinDwm/source/tags
Normal file
@@ -0,0 +1,496 @@
|
||||
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
|
||||
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
|
||||
!_TAG_OUTPUT_EXCMD mixed /number, pattern, mixed, or combineV2/
|
||||
!_TAG_OUTPUT_FILESEP slash /slash or backslash/
|
||||
!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/
|
||||
!_TAG_PATTERN_LENGTH_LIMIT 96 /0 for no limit/
|
||||
!_TAG_PROC_CWD /home/klein/KleinWindowManagement/KleinDwm/source/ //
|
||||
!_TAG_PROGRAM_AUTHOR Universal Ctags Team //
|
||||
!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/
|
||||
!_TAG_PROGRAM_URL https://ctags.io/ /official site/
|
||||
!_TAG_PROGRAM_VERSION 5.9.0 //
|
||||
${OBJ} Makefile /^${OBJ}: config.h config.mk$/;" t
|
||||
.c.o Makefile /^.c.o:$/;" t
|
||||
Arg dwm.c /^} Arg;$/;" t typeref:union:__anon0f53a99e070a file:
|
||||
BETWEEN util.h /^#define BETWEEN(/;" d
|
||||
BUGS dwm.1 /^.SH BUGS$/;" s title:DWM
|
||||
BUTTONMASK dwm.c /^#define BUTTONMASK /;" d file:
|
||||
Button dwm.c /^} Button;$/;" t typeref:struct:__anon0f53a99e0808 file:
|
||||
CC config.mk /^CC = cc$/;" m
|
||||
CFLAGS config.mk /^CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}$/;" m
|
||||
CLEANMASK dwm.c /^#define CLEANMASK(/;" d file:
|
||||
CPPFLAGS config.mk /^CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\\"${VERSION}\\" /;" m
|
||||
CUSTOMIZATION dwm.1 /^.SH CUSTOMIZATION$/;" s title:DWM
|
||||
CenterThisWindow dwm.c /^ int CenterThisWindow;$/;" m struct:__anon0f53a99e0b08 typeref:typename:int file:
|
||||
CenterThisWindow dwm.c /^ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, CenterThisWindow;$/;" m struct:Client typeref:typename:int file:
|
||||
Client dwm.c /^struct Client {$/;" s file:
|
||||
Client dwm.c /^typedef struct Client Client;$/;" t typeref:struct:Client file:
|
||||
ClkClientWin dwm.c /^ ClkClientWin, ClkRootWin, ClkLast }; \/* clicks *\/$/;" e enum:__anon0f53a99e0603 file:
|
||||
ClkLast dwm.c /^ ClkClientWin, ClkRootWin, ClkLast }; \/* clicks *\/$/;" e enum:__anon0f53a99e0603 file:
|
||||
ClkLtSymbol dwm.c /^enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,$/;" e enum:__anon0f53a99e0603 file:
|
||||
ClkRootWin dwm.c /^ ClkClientWin, ClkRootWin, ClkLast }; \/* clicks *\/$/;" e enum:__anon0f53a99e0603 file:
|
||||
ClkStatusText dwm.c /^enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,$/;" e enum:__anon0f53a99e0603 file:
|
||||
ClkTagBar dwm.c /^enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,$/;" e enum:__anon0f53a99e0603 file:
|
||||
ClkWinTitle dwm.c /^enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,$/;" e enum:__anon0f53a99e0603 file:
|
||||
Clr drw.h /^typedef XftColor Clr;$/;" t typeref:typename:XftColor
|
||||
ColBg drw.h /^enum { ColFg, ColBg, ColBorder }; \/* Clr scheme index *\/$/;" e enum:__anon0f5116480203
|
||||
ColBorder drw.h /^enum { ColFg, ColBg, ColBorder }; \/* Clr scheme index *\/$/;" e enum:__anon0f5116480203
|
||||
ColFg drw.h /^enum { ColFg, ColBg, ColBorder }; \/* Clr scheme index *\/$/;" e enum:__anon0f5116480203
|
||||
Cur drw.h /^} Cur;$/;" t typeref:struct:__anon0f5116480108
|
||||
CurLast dwm.c /^enum { CurNormal, CurResize, CurMove, CurLast }; \/* cursor *\/$/;" e enum:__anon0f53a99e0103 file:
|
||||
CurMove dwm.c /^enum { CurNormal, CurResize, CurMove, CurLast }; \/* cursor *\/$/;" e enum:__anon0f53a99e0103 file:
|
||||
CurNormal dwm.c /^enum { CurNormal, CurResize, CurMove, CurLast }; \/* cursor *\/$/;" e enum:__anon0f53a99e0103 file:
|
||||
CurResize dwm.c /^enum { CurNormal, CurResize, CurMove, CurLast }; \/* cursor *\/$/;" e enum:__anon0f53a99e0103 file:
|
||||
DESCRIPTION dwm.1 /^.SH DESCRIPTION$/;" s title:DWM
|
||||
DWM dwm.1 /^.TH DWM 1 dwm\\-VERSION$/;" t
|
||||
Drw drw.h /^} Drw;$/;" t typeref:struct:__anon0f5116480308
|
||||
FILES dwm.1 /^.SH FILES$/;" s title:DWM
|
||||
FREETYPEINC config.mk /^FREETYPEINC = \/usr\/include\/freetype2$/;" m
|
||||
FREETYPELIBS config.mk /^FREETYPELIBS = -lfontconfig -lXft$/;" m
|
||||
Fnt drw.h /^typedef struct Fnt {$/;" s
|
||||
Fnt drw.h /^} Fnt;$/;" t typeref:struct:Fnt
|
||||
HEIGHT dwm.c /^#define HEIGHT(/;" d file:
|
||||
ICONSIZE config.def.h /^#define ICONSIZE /;" d
|
||||
ICONSIZE config.h /^#define ICONSIZE /;" d
|
||||
ICONSPACING config.def.h /^#define ICONSPACING /;" d
|
||||
ICONSPACING config.h /^#define ICONSPACING /;" d
|
||||
INCS config.mk /^INCS = -I${X11INC} -I${FREETYPEINC}$/;" m
|
||||
INTERSECT dwm.c /^#define INTERSECT(/;" d file:
|
||||
ISSUES dwm.1 /^.SH ISSUES$/;" s title:DWM
|
||||
ISVISIBLE dwm.c /^#define ISVISIBLE(/;" d file:
|
||||
Key dwm.c /^} Key;$/;" t typeref:struct:__anon0f53a99e0908 file:
|
||||
LDFLAGS config.mk /^LDFLAGS = ${LIBS}$/;" m
|
||||
LENGTH dwm.c /^#define LENGTH(/;" d file:
|
||||
LIBS config.mk /^LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXrender -lImlib2$/;" m
|
||||
Layout dwm.c /^} Layout;$/;" t typeref:struct:__anon0f53a99e0a08 file:
|
||||
MANPREFIX config.mk /^MANPREFIX = ${PREFIX}\/share\/man$/;" m
|
||||
MAX util.h /^#define MAX(/;" d
|
||||
MIN util.h /^#define MIN(/;" d
|
||||
MODKEY keys.h /^#define MODKEY /;" d
|
||||
MOUSEMASK dwm.c /^#define MOUSEMASK /;" d file:
|
||||
Manager dwm.c /^enum { Manager, Xembed, XembedInfo, XLast }; \/* Xembed atoms *\/$/;" e enum:__anon0f53a99e0403 file:
|
||||
Monitor dwm.c /^struct Monitor {$/;" s file:
|
||||
Monitor dwm.c /^typedef struct Monitor Monitor;$/;" t typeref:struct:Monitor file:
|
||||
NAME dwm.1 /^.SH NAME$/;" s title:DWM
|
||||
NetActiveWindow dwm.c /^ NetWMFullscreen, NetActiveWindow, NetWMWindowType,$/;" e enum:__anon0f53a99e0303 file:
|
||||
NetClientList dwm.c /^ NetWMWindowTypeDialog, NetClientList, NetLast }; \/* EWMH atoms *\/$/;" e enum:__anon0f53a99e0303 file:
|
||||
NetLast dwm.c /^ NetWMWindowTypeDialog, NetClientList, NetLast }; \/* EWMH atoms *\/$/;" e enum:__anon0f53a99e0303 file:
|
||||
NetSupported dwm.c /^enum { NetSupported, NetWMName, NetWMIcon, NetWMState, NetWMCheck, $/;" e enum:__anon0f53a99e0303 file:
|
||||
NetSystemTray dwm.c /^ NetSystemTray, NetSystemTrayOP, NetSystemTrayOrientation, NetSystemTrayOrientationHorz,$/;" e enum:__anon0f53a99e0303 file:
|
||||
NetSystemTrayOP dwm.c /^ NetSystemTray, NetSystemTrayOP, NetSystemTrayOrientation, NetSystemTrayOrientationHorz,$/;" e enum:__anon0f53a99e0303 file:
|
||||
NetSystemTrayOrientation dwm.c /^ NetSystemTray, NetSystemTrayOP, NetSystemTrayOrientation, NetSystemTrayOrientationHorz,$/;" e enum:__anon0f53a99e0303 file:
|
||||
NetSystemTrayOrientationHorz dwm.c /^ NetSystemTray, NetSystemTrayOP, NetSystemTrayOrientation, NetSystemTrayOrientationHorz,$/;" e enum:__anon0f53a99e0303 file:
|
||||
NetWMCheck dwm.c /^enum { NetSupported, NetWMName, NetWMIcon, NetWMState, NetWMCheck, $/;" e enum:__anon0f53a99e0303 file:
|
||||
NetWMFullscreen dwm.c /^ NetWMFullscreen, NetActiveWindow, NetWMWindowType,$/;" e enum:__anon0f53a99e0303 file:
|
||||
NetWMIcon dwm.c /^enum { NetSupported, NetWMName, NetWMIcon, NetWMState, NetWMCheck, $/;" e enum:__anon0f53a99e0303 file:
|
||||
NetWMName dwm.c /^enum { NetSupported, NetWMName, NetWMIcon, NetWMState, NetWMCheck, $/;" e enum:__anon0f53a99e0303 file:
|
||||
NetWMState dwm.c /^enum { NetSupported, NetWMName, NetWMIcon, NetWMState, NetWMCheck, $/;" e enum:__anon0f53a99e0303 file:
|
||||
NetWMWindowType dwm.c /^ NetWMFullscreen, NetActiveWindow, NetWMWindowType,$/;" e enum:__anon0f53a99e0303 file:
|
||||
NetWMWindowTypeDialog dwm.c /^ NetWMWindowTypeDialog, NetClientList, NetLast }; \/* EWMH atoms *\/$/;" e enum:__anon0f53a99e0303 file:
|
||||
NumTags dwm.c /^struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };$/;" s file:
|
||||
OBJ Makefile /^OBJ = ${SRC:.c=.o}$/;" m
|
||||
OPTIONS dwm.1 /^.SH OPTIONS$/;" s title:DWM
|
||||
PREFIX config.mk /^PREFIX = \/usr\/local$/;" m
|
||||
Pertag dwm.c /^struct Pertag {$/;" s file:
|
||||
Pertag dwm.c /^typedef struct Pertag Pertag;$/;" t typeref:struct:Pertag file:
|
||||
Rule dwm.c /^} Rule;$/;" t typeref:struct:__anon0f53a99e0b08 file:
|
||||
SEE dwm.1 /^.SH SEE ALSO$/;" s title:DWM
|
||||
SHCMD keys.h /^#define SHCMD(/;" d
|
||||
SIGNALS dwm.1 /^.SH SIGNALS$/;" s title:DWM
|
||||
SRC Makefile /^SRC = drw.c dwm.c util.c$/;" m
|
||||
SYNOPSIS dwm.1 /^.SH SYNOPSIS$/;" s title:DWM
|
||||
SYSTEM_TRAY_REQUEST_DOCK dwm.c /^#define SYSTEM_TRAY_REQUEST_DOCK /;" d file:
|
||||
SchemeNorm dwm.c /^enum { SchemeNorm, SchemeSel, SchemeUrg, SchemeTitle }; \/* color schemes *\/$/;" e enum:__anon0f53a99e0203 file:
|
||||
SchemeSel dwm.c /^enum { SchemeNorm, SchemeSel, SchemeUrg, SchemeTitle }; \/* color schemes *\/$/;" e enum:__anon0f53a99e0203 file:
|
||||
SchemeTitle dwm.c /^enum { SchemeNorm, SchemeSel, SchemeUrg, SchemeTitle }; \/* color schemes *\/$/;" e enum:__anon0f53a99e0203 file:
|
||||
SchemeUrg dwm.c /^enum { SchemeNorm, SchemeSel, SchemeUrg, SchemeTitle }; \/* color schemes *\/$/;" e enum:__anon0f53a99e0203 file:
|
||||
Systray dwm.c /^struct Systray {$/;" s file:
|
||||
Systray dwm.c /^typedef struct Systray Systray;$/;" t typeref:struct:Systray file:
|
||||
TAGKEYS keys.h /^#define TAGKEYS(/;" d
|
||||
TAGMASK dwm.c /^#define TAGMASK /;" d file:
|
||||
TERMINAL config.def.h /^#define TERMINAL /;" d
|
||||
TERMINAL config.h /^#define TERMINAL /;" d
|
||||
TERMINAL keys.h /^#define TERMINAL /;" d
|
||||
TEXTW dwm.c /^#define TEXTW(/;" d file:
|
||||
USAGE dwm.1 /^.SH USAGE$/;" s title:DWM
|
||||
UTF_INVALID drw.c /^#define UTF_INVALID /;" d file:
|
||||
UTF_SIZ drw.c /^#define UTF_SIZ /;" d file:
|
||||
VERSION config.mk /^VERSION = 6.5$/;" m
|
||||
VERSION_MAJOR dwm.c /^#define VERSION_MAJOR /;" d file:
|
||||
VERSION_MINOR dwm.c /^#define VERSION_MINOR /;" d file:
|
||||
WIDTH dwm.c /^#define WIDTH(/;" d file:
|
||||
WMDelete dwm.c /^enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; \/* default atoms *\/$/;" e enum:__anon0f53a99e0503 file:
|
||||
WMLast dwm.c /^enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; \/* default atoms *\/$/;" e enum:__anon0f53a99e0503 file:
|
||||
WMProtocols dwm.c /^enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; \/* default atoms *\/$/;" e enum:__anon0f53a99e0503 file:
|
||||
WMState dwm.c /^enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; \/* default atoms *\/$/;" e enum:__anon0f53a99e0503 file:
|
||||
WMTakeFocus dwm.c /^enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; \/* default atoms *\/$/;" e enum:__anon0f53a99e0503 file:
|
||||
X11INC config.mk /^X11INC = \/usr\/X11R6\/include$/;" m
|
||||
X11LIB config.mk /^X11LIB = \/usr\/X11R6\/lib$/;" m
|
||||
XEMBED_EMBEDDED_NOTIFY dwm.c /^#define XEMBED_EMBEDDED_NOTIFY /;" d file:
|
||||
XEMBED_EMBEDDED_VERSION dwm.c /^#define XEMBED_EMBEDDED_VERSION /;" d file:
|
||||
XEMBED_FOCUS_IN dwm.c /^#define XEMBED_FOCUS_IN /;" d file:
|
||||
XEMBED_MAPPED dwm.c /^#define XEMBED_MAPPED /;" d file:
|
||||
XEMBED_MODALITY_ON dwm.c /^#define XEMBED_MODALITY_ON /;" d file:
|
||||
XEMBED_WINDOW_ACTIVATE dwm.c /^#define XEMBED_WINDOW_ACTIVATE /;" d file:
|
||||
XEMBED_WINDOW_DEACTIVATE dwm.c /^#define XEMBED_WINDOW_DEACTIVATE /;" d file:
|
||||
XINERAMAFLAGS config.mk /^XINERAMAFLAGS = -DXINERAMA$/;" m
|
||||
XINERAMALIBS config.mk /^XINERAMALIBS = -lXinerama$/;" m
|
||||
XLast dwm.c /^enum { Manager, Xembed, XembedInfo, XLast }; \/* Xembed atoms *\/$/;" e enum:__anon0f53a99e0403 file:
|
||||
Xembed dwm.c /^enum { Manager, Xembed, XembedInfo, XLast }; \/* Xembed atoms *\/$/;" e enum:__anon0f53a99e0403 file:
|
||||
XembedInfo dwm.c /^enum { Manager, Xembed, XembedInfo, XLast }; \/* Xembed atoms *\/$/;" e enum:__anon0f53a99e0403 file:
|
||||
__anon0f5116430103 drw.c /^ enum { nomatches_len = 64 };$/;" g function:drw_text file:
|
||||
__anon0f5116430208 drw.c /^ static struct { long codepoint[nomatches_len]; unsigned int idx; } nomatches;$/;" s function:drw_text file:
|
||||
__anon0f5116480108 drw.h /^typedef struct {$/;" s
|
||||
__anon0f5116480203 drw.h /^enum { ColFg, ColBg, ColBorder }; \/* Clr scheme index *\/$/;" g
|
||||
__anon0f5116480308 drw.h /^typedef struct {$/;" s
|
||||
__anon0f53a99e0103 dwm.c /^enum { CurNormal, CurResize, CurMove, CurLast }; \/* cursor *\/$/;" g file:
|
||||
__anon0f53a99e0203 dwm.c /^enum { SchemeNorm, SchemeSel, SchemeUrg, SchemeTitle }; \/* color schemes *\/$/;" g file:
|
||||
__anon0f53a99e0303 dwm.c /^enum { NetSupported, NetWMName, NetWMIcon, NetWMState, NetWMCheck, $/;" g file:
|
||||
__anon0f53a99e0403 dwm.c /^enum { Manager, Xembed, XembedInfo, XLast }; \/* Xembed atoms *\/$/;" g file:
|
||||
__anon0f53a99e0503 dwm.c /^enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; \/* default atoms *\/$/;" g file:
|
||||
__anon0f53a99e0603 dwm.c /^enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,$/;" g file:
|
||||
__anon0f53a99e070a dwm.c /^typedef union {$/;" u file:
|
||||
__anon0f53a99e0808 dwm.c /^typedef struct {$/;" s file:
|
||||
__anon0f53a99e0908 dwm.c /^typedef struct {$/;" s file:
|
||||
__anon0f53a99e0a08 dwm.c /^typedef struct {$/;" s file:
|
||||
__anon0f53a99e0b08 dwm.c /^typedef struct {$/;" s file:
|
||||
all Makefile /^all: options dwm$/;" t
|
||||
applyrules dwm.c /^applyrules(Client *c)$/;" f typeref:typename:void
|
||||
applysizehints dwm.c /^applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact)$/;" f typeref:typename:int
|
||||
arg dwm.c /^ const Arg arg;$/;" m struct:__anon0f53a99e0808 typeref:typename:const Arg file:
|
||||
arg dwm.c /^ const Arg arg;$/;" m struct:__anon0f53a99e0908 typeref:typename:const Arg file:
|
||||
arrange dwm.c /^ void (*arrange)(Monitor *);$/;" m struct:__anon0f53a99e0a08 typeref:typename:void (*)(Monitor *) file:
|
||||
arrange dwm.c /^arrange(Monitor *m)$/;" f typeref:typename:void
|
||||
arrangemon dwm.c /^arrangemon(Monitor *m)$/;" f typeref:typename:void
|
||||
attach dwm.c /^attach(Client *c)$/;" f typeref:typename:void
|
||||
attachstack dwm.c /^attachstack(Client *c)$/;" f typeref:typename:void
|
||||
autostartblocksh dwm.c /^static const char autostartblocksh[] = "autostart_blocking.sh";$/;" v typeref:typename:const char[] file:
|
||||
autostartsh dwm.c /^static const char autostartsh[] = "autostart.sh";$/;" v typeref:typename:const char[] file:
|
||||
barwin dwm.c /^ Window barwin;$/;" m struct:Monitor typeref:typename:Window file:
|
||||
baseh dwm.c /^ int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;$/;" m struct:Client typeref:typename:int file:
|
||||
basew dwm.c /^ int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;$/;" m struct:Client typeref:typename:int file:
|
||||
bh dwm.c /^static int bh; \/* bar height *\/$/;" v typeref:typename:int file:
|
||||
borderpx config.def.h /^static const unsigned int borderpx = 2; \/* border pixel of windows *\/$/;" v typeref:typename:const unsigned int
|
||||
borderpx config.h /^static const unsigned int borderpx = 2; \/* border pixel of windows *\/$/;" v typeref:typename:const unsigned int
|
||||
broken dwm.c /^static const char broken[] = "broken";$/;" v typeref:typename:const char[] file:
|
||||
button dwm.c /^ unsigned int button;$/;" m struct:__anon0f53a99e0808 typeref:typename:unsigned int file:
|
||||
buttonpress dwm.c /^buttonpress(XEvent *e)$/;" f typeref:typename:void
|
||||
buttons keys.h /^static const Button buttons[] = {$/;" v typeref:typename:const Button[]
|
||||
bw dwm.c /^ int bw, oldbw;$/;" m struct:Client typeref:typename:int file:
|
||||
by dwm.c /^ int by; \/* bar geometry *\/$/;" m struct:Monitor typeref:typename:int file:
|
||||
chain dwm.c /^ KeySym chain;$/;" m struct:__anon0f53a99e0908 typeref:typename:KeySym file:
|
||||
checkotherwm dwm.c /^checkotherwm(void)$/;" f typeref:typename:void
|
||||
class dwm.c /^ const char *class;$/;" m struct:__anon0f53a99e0b08 typeref:typename:const char * file:
|
||||
clean Makefile /^clean:$/;" t
|
||||
cleanup dwm.c /^cleanup(void)$/;" f typeref:typename:void
|
||||
cleanupmon dwm.c /^cleanupmon(Monitor *mon)$/;" f typeref:typename:void
|
||||
click dwm.c /^ unsigned int click;$/;" m struct:__anon0f53a99e0808 typeref:typename:unsigned int file:
|
||||
clientmessage dwm.c /^clientmessage(XEvent *e)$/;" f typeref:typename:void
|
||||
clients dwm.c /^ Client *clients;$/;" m struct:Monitor typeref:typename:Client * file:
|
||||
codepoint drw.c /^ static struct { long codepoint[nomatches_len]; unsigned int idx; } nomatches;$/;" m struct:drw_text::__anon0f5116430208 typeref:typename:long[] file:
|
||||
config.h Makefile /^config.h:$/;" t
|
||||
configure dwm.c /^configure(Client *c)$/;" f typeref:typename:void
|
||||
configurenotify dwm.c /^configurenotify(XEvent *e)$/;" f typeref:typename:void
|
||||
configurerequest dwm.c /^configurerequest(XEvent *e)$/;" f typeref:typename:void
|
||||
createmon dwm.c /^createmon(void)$/;" f typeref:typename:Monitor *
|
||||
cursor drw.h /^ Cursor cursor;$/;" m struct:__anon0f5116480108 typeref:typename:Cursor
|
||||
cursor dwm.c /^static Cur *cursor[CurLast];$/;" v typeref:typename:Cur * [] file:
|
||||
curtag dwm.c /^ unsigned int curtag, prevtag; \/* current and previous tag *\/$/;" m struct:Pertag typeref:typename:unsigned int file:
|
||||
dec_light keys.h /^static const char *dec_light[] = { "brightnessctl", "set", "10%-", NULL };$/;" v typeref:typename:const char * []
|
||||
destroynotify dwm.c /^destroynotify(XEvent *e)$/;" f typeref:typename:void
|
||||
detach dwm.c /^detach(Client *c)$/;" f typeref:typename:void
|
||||
detachstack dwm.c /^detachstack(Client *c)$/;" f typeref:typename:void
|
||||
die util.c /^die(const char *fmt, ...)$/;" f typeref:typename:void
|
||||
dirtomon dwm.c /^dirtomon(int dir)$/;" f typeref:typename:Monitor *
|
||||
dist Makefile /^dist: clean$/;" t
|
||||
dmenucmd keys.h /^static const char *dmenucmd[] = { "dmenu_run", "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gr/;" v typeref:typename:const char * []
|
||||
dmenufont keys.h /^static const char dmenufont[] = "monospace:size=10";$/;" v typeref:typename:const char[]
|
||||
dpy drw.h /^ Display *dpy;$/;" m struct:Fnt typeref:typename:Display *
|
||||
dpy drw.h /^ Display *dpy;$/;" m struct:__anon0f5116480308 typeref:typename:Display *
|
||||
dpy dwm.c /^static Display *dpy;$/;" v typeref:typename:Display * file:
|
||||
drawable drw.h /^ Drawable drawable;$/;" m struct:__anon0f5116480308 typeref:typename:Drawable
|
||||
drawbar dwm.c /^drawbar(Monitor *m)$/;" f typeref:typename:void
|
||||
drawbars dwm.c /^drawbars(void)$/;" f typeref:typename:void
|
||||
drawstatusbar dwm.c /^drawstatusbar(Monitor *m, int bh, char* stext) {$/;" f typeref:typename:int
|
||||
drw dwm.c /^static Drw *drw;$/;" v typeref:typename:Drw * file:
|
||||
drw_clr_create drw.c /^drw_clr_create(Drw *drw, Clr *dest, const char *clrname)$/;" f typeref:typename:void
|
||||
drw_create drw.c /^drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h)$/;" f typeref:typename:Drw *
|
||||
drw_cur_create drw.c /^drw_cur_create(Drw *drw, int shape)$/;" f typeref:typename:Cur *
|
||||
drw_cur_free drw.c /^drw_cur_free(Drw *drw, Cur *cursor)$/;" f typeref:typename:void
|
||||
drw_font_getexts drw.c /^drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h/;" f typeref:typename:void
|
||||
drw_fontset_create drw.c /^drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount)$/;" f typeref:typename:Fnt *
|
||||
drw_fontset_free drw.c /^drw_fontset_free(Fnt *font)$/;" f typeref:typename:void
|
||||
drw_fontset_getwidth drw.c /^drw_fontset_getwidth(Drw *drw, const char *text)$/;" f typeref:typename:unsigned int
|
||||
drw_fontset_getwidth_clamp drw.c /^drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n)$/;" f typeref:typename:unsigned int
|
||||
drw_free drw.c /^drw_free(Drw *drw)$/;" f typeref:typename:void
|
||||
drw_map drw.c /^drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h)$/;" f typeref:typename:void
|
||||
drw_pic drw.c /^drw_pic(Drw *drw, int x, int y, unsigned int w, unsigned int h, Picture pic)$/;" f typeref:typename:void
|
||||
drw_picture_create_resized drw.c /^drw_picture_create_resized(Drw *drw, char *src, unsigned int srcw, unsigned int srch, unsigned i/;" f typeref:typename:Picture
|
||||
drw_rect drw.c /^drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert)$/;" f typeref:typename:void
|
||||
drw_resize drw.c /^drw_resize(Drw *drw, unsigned int w, unsigned int h)$/;" f typeref:typename:void
|
||||
drw_scm_create drw.c /^drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)$/;" f typeref:typename:Clr *
|
||||
drw_setfontset drw.c /^drw_setfontset(Drw *drw, Fnt *set)$/;" f typeref:typename:void
|
||||
drw_setscheme drw.c /^drw_setscheme(Drw *drw, Clr *scm)$/;" f typeref:typename:void
|
||||
drw_text drw.c /^drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char */;" f typeref:typename:int
|
||||
dwindle fibonacci.c /^dwindle(Monitor *mon) {$/;" f typeref:typename:void
|
||||
dwm Makefile /^dwm: ${OBJ}$/;" t
|
||||
dwmdir dwm.c /^static const char dwmdir[] = "dwm";$/;" v typeref:typename:const char[] file:
|
||||
ecalloc util.c /^ecalloc(size_t nmemb, size_t size)$/;" f typeref:typename:void *
|
||||
enternotify dwm.c /^enternotify(XEvent *e)$/;" f typeref:typename:void
|
||||
expose dwm.c /^expose(XEvent *e)$/;" f typeref:typename:void
|
||||
f dwm.c /^ float f;$/;" m union:__anon0f53a99e070a typeref:typename:float file:
|
||||
fibonacci fibonacci.c /^fibonacci(Monitor *mon, int s) {$/;" f typeref:typename:void
|
||||
focus dwm.c /^focus(Client *c)$/;" f typeref:typename:void
|
||||
focusin dwm.c /^focusin(XEvent *e)$/;" f typeref:typename:void
|
||||
focusmon dwm.c /^focusmon(const Arg *arg)$/;" f typeref:typename:void
|
||||
focusstack dwm.c /^focusstack(const Arg *arg)$/;" f typeref:typename:void
|
||||
fonts config.def.h /^static const char *fonts[] = { "monospace:size=9", "DroidSansMono Nerd Font:size=8", "N/;" v typeref:typename:const char * []
|
||||
fonts config.h /^static const char *fonts[] = { "monospace:size=9", "DroidSansMono Nerd Font:size=8", "N/;" v typeref:typename:const char * []
|
||||
fonts drw.h /^ Fnt *fonts;$/;" m struct:__anon0f5116480308 typeref:typename:Fnt *
|
||||
freeicon dwm.c /^freeicon(Client *c)$/;" f typeref:typename:void
|
||||
func dwm.c /^ void (*func)(const Arg *);$/;" m struct:__anon0f53a99e0908 typeref:typename:void (*)(const Arg *) file:
|
||||
func dwm.c /^ void (*func)(const Arg *arg);$/;" m struct:__anon0f53a99e0808 typeref:typename:void (*)(const Arg * arg) file:
|
||||
gappx config.def.h /^static const unsigned int gappx = 10; \/* gaps between windows *\/$/;" v typeref:typename:const unsigned int
|
||||
gappx config.h /^static const unsigned int gappx = 10; \/* gaps between windows *\/$/;" v typeref:typename:const unsigned int
|
||||
gappx dwm.c /^ int gappx; \/* gaps between windows *\/$/;" m struct:Monitor typeref:typename:int file:
|
||||
gc drw.h /^ GC gc;$/;" m struct:__anon0f5116480308 typeref:typename:GC
|
||||
getatomprop dwm.c /^getatomprop(Client *c, Atom prop)$/;" f typeref:typename:Atom
|
||||
geticonprop dwm.c /^geticonprop(Window win, unsigned int *picw, unsigned int *pich)$/;" f typeref:typename:Picture
|
||||
getrootptr dwm.c /^getrootptr(int *x, int *y)$/;" f typeref:typename:int
|
||||
getstate dwm.c /^getstate(Window w)$/;" f typeref:typename:long
|
||||
getsystraywidth dwm.c /^getsystraywidth()$/;" f typeref:typename:unsigned int
|
||||
gettextprop dwm.c /^gettextprop(Window w, Atom atom, char *text, unsigned int size)$/;" f typeref:typename:int
|
||||
grabbuttons dwm.c /^grabbuttons(Client *c, int focused)$/;" f typeref:typename:void
|
||||
grabkeys dwm.c /^grabkeys(void)$/;" f typeref:typename:void
|
||||
h drw.h /^ unsigned int h;$/;" m struct:Fnt typeref:typename:unsigned int
|
||||
h drw.h /^ unsigned int w, h;$/;" m struct:__anon0f5116480308 typeref:typename:unsigned int
|
||||
h dwm.c /^ int x, y, w, h;$/;" m struct:Client typeref:typename:int file:
|
||||
handler dwm.c /^static void (*handler[LASTEvent]) (XEvent *) = {$/;" v typeref:typename:void (* [LASTEvent])(XEvent *) file:
|
||||
hintsvalid dwm.c /^ int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;$/;" m struct:Client typeref:typename:int file:
|
||||
i dwm.c /^ int i;$/;" m union:__anon0f53a99e070a typeref:typename:int file:
|
||||
ich dwm.c /^ unsigned int icw, ich; Picture icon;$/;" m struct:Client typeref:typename:unsigned int file:
|
||||
icon dwm.c /^ unsigned int icw, ich; Picture icon;$/;" m struct:Client typeref:typename:Picture file:
|
||||
icons dwm.c /^ Client *icons;$/;" m struct:Systray typeref:typename:Client * file:
|
||||
icw dwm.c /^ unsigned int icw, ich; Picture icon;$/;" m struct:Client typeref:typename:unsigned int file:
|
||||
idx drw.c /^ static struct { long codepoint[nomatches_len]; unsigned int idx; } nomatches;$/;" m struct:drw_text::__anon0f5116430208 typeref:typename:unsigned int file:
|
||||
inc_light keys.h /^static const char *inc_light[] = { "brightnessctl", "set", "+10%", NULL };$/;" v typeref:typename:const char * []
|
||||
inch dwm.c /^ int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;$/;" m struct:Client typeref:typename:int file:
|
||||
incnmaster dwm.c /^incnmaster(const Arg *arg)$/;" f typeref:typename:void
|
||||
incw dwm.c /^ int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;$/;" m struct:Client typeref:typename:int file:
|
||||
install Makefile /^install: all$/;" t
|
||||
instance dwm.c /^ const char *instance;$/;" m struct:__anon0f53a99e0b08 typeref:typename:const char * file:
|
||||
isfixed dwm.c /^ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, CenterThisWindow;$/;" m struct:Client typeref:typename:int file:
|
||||
isfloating dwm.c /^ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, CenterThisWindow;$/;" m struct:Client typeref:typename:int file:
|
||||
isfloating dwm.c /^ int isfloating;$/;" m struct:__anon0f53a99e0b08 typeref:typename:int file:
|
||||
isfullscreen dwm.c /^ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, CenterThisWindow;$/;" m struct:Client typeref:typename:int file:
|
||||
isuniquegeom dwm.c /^isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info)$/;" f typeref:typename:int file:
|
||||
isurgent dwm.c /^ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, CenterThisWindow;$/;" m struct:Client typeref:typename:int file:
|
||||
keychain dwm.c /^static KeySym keychain = -1;$/;" v typeref:typename:KeySym file:
|
||||
keypress dwm.c /^keypress(XEvent *e)$/;" f typeref:typename:void
|
||||
keys keys.h /^static const Key keys[] = {$/;" v typeref:typename:const Key[]
|
||||
keysym dwm.c /^ KeySym keysym;$/;" m struct:__anon0f53a99e0908 typeref:typename:KeySym file:
|
||||
killclient dwm.c /^killclient(const Arg *arg)$/;" f typeref:typename:void
|
||||
layouts layouts.h /^static const Layout layouts[] = {$/;" v typeref:typename:const Layout[]
|
||||
limitexceeded dwm.c /^struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };$/;" m struct:NumTags typeref:typename:char[] file:
|
||||
localshare dwm.c /^static const char localshare[] = ".local\/share";$/;" v typeref:typename:const char[] file:
|
||||
lockfullscreen layouts.h /^static const int lockfullscreen = 0; \/* 1 will force focus on the fullscreen window *\/$/;" v typeref:typename:const int
|
||||
lrpad dwm.c /^static int lrpad; \/* sum of left and right padding for text *\/$/;" v typeref:typename:int file:
|
||||
lt dwm.c /^ const Layout *lt[2];$/;" m struct:Monitor typeref:typename:const Layout * [2] file:
|
||||
ltidxs dwm.c /^ const Layout *ltidxs[LENGTH(tags) + 1][2]; \/* matrix of tags and layouts indexes *\/$/;" m struct:Pertag typeref:typename:const Layout * [][2] file:
|
||||
ltsymbol dwm.c /^ char ltsymbol[16];$/;" m struct:Monitor typeref:typename:char[16] file:
|
||||
main dwm.c /^main(int argc, char *argv[])$/;" f typeref:typename:int
|
||||
main transient.c /^int main(void) {$/;" f typeref:typename:int
|
||||
manage dwm.c /^manage(Window w, XWindowAttributes *wa)$/;" f typeref:typename:void
|
||||
mappingnotify dwm.c /^mappingnotify(XEvent *e)$/;" f typeref:typename:void
|
||||
maprequest dwm.c /^maprequest(XEvent *e)$/;" f typeref:typename:void
|
||||
mask dwm.c /^ unsigned int mask;$/;" m struct:__anon0f53a99e0808 typeref:typename:unsigned int file:
|
||||
maxa dwm.c /^ float mina, maxa;$/;" m struct:Client typeref:typename:float file:
|
||||
maxh dwm.c /^ int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;$/;" m struct:Client typeref:typename:int file:
|
||||
maxw dwm.c /^ int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;$/;" m struct:Client typeref:typename:int file:
|
||||
mfact dwm.c /^ float mfact;$/;" m struct:Monitor typeref:typename:float file:
|
||||
mfact layouts.h /^static const float mfact = 0.55; \/* factor of master area size [0.05..0.95] *\/$/;" v typeref:typename:const float
|
||||
mfacts dwm.c /^ float mfacts[LENGTH(tags) + 1]; \/* mfacts per tag *\/$/;" m struct:Pertag typeref:typename:float[] file:
|
||||
mh dwm.c /^ int mx, my, mw, mh; \/* screen size *\/$/;" m struct:Monitor typeref:typename:int file:
|
||||
mina dwm.c /^ float mina, maxa;$/;" m struct:Client typeref:typename:float file:
|
||||
minh dwm.c /^ int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;$/;" m struct:Client typeref:typename:int file:
|
||||
minw dwm.c /^ int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;$/;" m struct:Client typeref:typename:int file:
|
||||
mod dwm.c /^ unsigned int mod;$/;" m struct:__anon0f53a99e0908 typeref:typename:unsigned int file:
|
||||
mon dwm.c /^ Monitor *mon;$/;" m struct:Client typeref:typename:Monitor * file:
|
||||
monitor dwm.c /^ int monitor;$/;" m struct:__anon0f53a99e0b08 typeref:typename:int file:
|
||||
monocle dwm.c /^monocle(Monitor *m)$/;" f typeref:typename:void
|
||||
mons dwm.c /^static Monitor *mons, *selmon;$/;" v typeref:typename:Monitor * file:
|
||||
motionnotify dwm.c /^motionnotify(XEvent *e)$/;" f typeref:typename:void
|
||||
movemouse dwm.c /^movemouse(const Arg *arg)$/;" f typeref:typename:void
|
||||
movestack movestack.c /^movestack(const Arg *arg) {$/;" f typeref:typename:void
|
||||
mw dwm.c /^ int mx, my, mw, mh; \/* screen size *\/$/;" m struct:Monitor typeref:typename:int file:
|
||||
mx dwm.c /^ int mx, my, mw, mh; \/* screen size *\/$/;" m struct:Monitor typeref:typename:int file:
|
||||
my dwm.c /^ int mx, my, mw, mh; \/* screen size *\/$/;" m struct:Monitor typeref:typename:int file:
|
||||
name dwm.c /^ char name[256];$/;" m struct:Client typeref:typename:char[256] file:
|
||||
netatom dwm.c /^static Atom wmatom[WMLast], netatom[NetLast], xatom[XLast];$/;" v typeref:typename:Atom[] file:
|
||||
neverfocus dwm.c /^ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, CenterThisWindow;$/;" m struct:Client typeref:typename:int file:
|
||||
next drw.h /^ struct Fnt *next;$/;" m struct:Fnt typeref:struct:Fnt *
|
||||
next dwm.c /^ Client *next;$/;" m struct:Client typeref:typename:Client * file:
|
||||
next dwm.c /^ Monitor *next;$/;" m struct:Monitor typeref:typename:Monitor * file:
|
||||
nexttiled dwm.c /^nexttiled(Client *c)$/;" f typeref:typename:Client *
|
||||
nmaster dwm.c /^ int nmaster;$/;" m struct:Monitor typeref:typename:int file:
|
||||
nmaster layouts.h /^static const int nmaster = 1; \/* number of clients in master area *\/$/;" v typeref:typename:const int
|
||||
nmasters dwm.c /^ int nmasters[LENGTH(tags) + 1]; \/* number of windows in master area *\/$/;" m struct:Pertag typeref:typename:int[] file:
|
||||
nomatches_len drw.c /^ enum { nomatches_len = 64 };$/;" e enum:drw_text::__anon0f5116430103 file:
|
||||
num dwm.c /^ int num;$/;" m struct:Monitor typeref:typename:int file:
|
||||
numlockmask dwm.c /^static unsigned int numlockmask = 0;$/;" v typeref:typename:unsigned int file:
|
||||
nvimcmd keys.h /^static const char *nvimcmd[] = { TERMINAL, "-e", "nvim", "KleinWiki\/index.md", NULL };$/;" v typeref:typename:const char * []
|
||||
oldbw dwm.c /^ int bw, oldbw;$/;" m struct:Client typeref:typename:int file:
|
||||
oldh dwm.c /^ int oldx, oldy, oldw, oldh;$/;" m struct:Client typeref:typename:int file:
|
||||
oldstate dwm.c /^ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, CenterThisWindow;$/;" m struct:Client typeref:typename:int file:
|
||||
oldw dwm.c /^ int oldx, oldy, oldw, oldh;$/;" m struct:Client typeref:typename:int file:
|
||||
oldx dwm.c /^ int oldx, oldy, oldw, oldh;$/;" m struct:Client typeref:typename:int file:
|
||||
oldy dwm.c /^ int oldx, oldy, oldw, oldh;$/;" m struct:Client typeref:typename:int file:
|
||||
options Makefile /^options:$/;" t
|
||||
pattern drw.h /^ FcPattern *pattern;$/;" m struct:Fnt typeref:typename:FcPattern *
|
||||
pertag dwm.c /^ Pertag *pertag;$/;" m struct:Monitor typeref:typename:Pertag * file:
|
||||
picture drw.h /^ Picture picture;$/;" m struct:__anon0f5116480308 typeref:typename:Picture
|
||||
pop dwm.c /^pop(Client *c)$/;" f typeref:typename:void
|
||||
prealpha dwm.c /^static uint32_t prealpha(uint32_t p) {$/;" f typeref:typename:uint32_t file:
|
||||
prevtag dwm.c /^ unsigned int curtag, prevtag; \/* current and previous tag *\/$/;" m struct:Pertag typeref:typename:unsigned int file:
|
||||
propertynotify dwm.c /^propertynotify(XEvent *e)$/;" f typeref:typename:void
|
||||
quit dwm.c /^quit(const Arg *arg)$/;" f typeref:typename:void
|
||||
recttomon dwm.c /^recttomon(int x, int y, int w, int h)$/;" f typeref:typename:Monitor *
|
||||
removesystrayicon dwm.c /^removesystrayicon(Client *i)$/;" f typeref:typename:void
|
||||
resize dwm.c /^resize(Client *c, int x, int y, int w, int h, int interact)$/;" f typeref:typename:void
|
||||
resizebarwin dwm.c /^resizebarwin(Monitor *m) {$/;" f typeref:typename:void
|
||||
resizeclient dwm.c /^resizeclient(Client *c, int x, int y, int w, int h)$/;" f typeref:typename:void
|
||||
resizehints layouts.h /^static const int resizehints = 1; \/* 1 means respect size hints in tiled resizals *\/$/;" v typeref:typename:const int
|
||||
resizemouse dwm.c /^resizemouse(const Arg *arg)$/;" f typeref:typename:void
|
||||
resizerequest dwm.c /^resizerequest(XEvent *e)$/;" f typeref:typename:void
|
||||
restack dwm.c /^restack(Monitor *m)$/;" f typeref:typename:void
|
||||
restart dwm.c /^static int restart = 0;$/;" v typeref:typename:int file:
|
||||
root drw.h /^ Window root;$/;" m struct:__anon0f5116480308 typeref:typename:Window
|
||||
root dwm.c /^static Window root, wmcheckwin;$/;" v typeref:typename:Window file:
|
||||
rules config.def.h /^static const Rule rules[] = {$/;" v typeref:typename:const Rule[]
|
||||
rules config.h /^static const Rule rules[] = {$/;" v typeref:typename:const Rule[]
|
||||
run dwm.c /^run(void)$/;" f typeref:typename:void
|
||||
runautostart dwm.c /^runautostart(void)$/;" f typeref:typename:void
|
||||
running dwm.c /^static int running = 1;$/;" v typeref:typename:int file:
|
||||
scan dwm.c /^scan(void)$/;" f typeref:typename:void
|
||||
scheme drw.h /^ Clr *scheme;$/;" m struct:__anon0f5116480308 typeref:typename:Clr *
|
||||
scheme dwm.c /^static Clr **scheme;$/;" v typeref:typename:Clr ** file:
|
||||
screen drw.h /^ int screen;$/;" m struct:__anon0f5116480308 typeref:typename:int
|
||||
screen dwm.c /^static int screen;$/;" v typeref:typename:int file:
|
||||
scrotselcmd keys.h /^static const char *scrotselcmd[] = { "scrot", "-s", "\/home\/klein\/Pictures\/screenshots\/Scree/;" v typeref:typename:const char * []
|
||||
sel dwm.c /^ Client *sel;$/;" m struct:Monitor typeref:typename:Client * file:
|
||||
sellt dwm.c /^ unsigned int sellt;$/;" m struct:Monitor typeref:typename:unsigned int file:
|
||||
sellts dwm.c /^ unsigned int sellts[LENGTH(tags) + 1]; \/* selected layouts *\/$/;" m struct:Pertag typeref:typename:unsigned int[] file:
|
||||
selmon dwm.c /^static Monitor *mons, *selmon;$/;" v typeref:typename:Monitor * file:
|
||||
seltags dwm.c /^ unsigned int seltags;$/;" m struct:Monitor typeref:typename:unsigned int file:
|
||||
sendevent dwm.c /^sendevent(Window w, Atom proto, int mask, long d0, long d1, long d2, long d3, long d4)$/;" f typeref:typename:int
|
||||
sendmon dwm.c /^sendmon(Client *c, Monitor *m)$/;" f typeref:typename:void
|
||||
setclientstate dwm.c /^setclientstate(Client *c, long state)$/;" f typeref:typename:void
|
||||
setfocus dwm.c /^setfocus(Client *c)$/;" f typeref:typename:void
|
||||
setfullscreen dwm.c /^setfullscreen(Client *c, int fullscreen)$/;" f typeref:typename:void
|
||||
setgaps dwm.c /^setgaps(const Arg *arg)$/;" f typeref:typename:void
|
||||
setlayout dwm.c /^setlayout(const Arg *arg)$/;" f typeref:typename:void
|
||||
setmfact dwm.c /^setmfact(const Arg *arg)$/;" f typeref:typename:void
|
||||
setup dwm.c /^setup(void)$/;" f typeref:typename:void
|
||||
seturgent dwm.c /^seturgent(Client *c, int urg)$/;" f typeref:typename:void
|
||||
sh dwm.c /^static int sw, sh; \/* X display screen geometry width, height *\/$/;" v typeref:typename:int file:
|
||||
showbar config.def.h /^static const int showbar = 1; \/* 0 means no bar *\/$/;" v typeref:typename:const int
|
||||
showbar config.h /^static const int showbar = 1; \/* 0 means no bar *\/$/;" v typeref:typename:const int
|
||||
showbar dwm.c /^ int showbar;$/;" m struct:Monitor typeref:typename:int file:
|
||||
showbars dwm.c /^ int showbars[LENGTH(tags) + 1]; \/* display bar for the current tag *\/$/;" m struct:Pertag typeref:typename:int[] file:
|
||||
showhide dwm.c /^showhide(Client *c)$/;" f typeref:typename:void
|
||||
showsystray config.def.h /^static const int showsystray = 1; \/* 0 means no systray *\/$/;" v typeref:typename:const int
|
||||
showsystray config.h /^static const int showsystray = 1; \/* 0 means no systray *\/$/;" v typeref:typename:const int
|
||||
sigchld dwm.c /^sigchld(int unused)$/;" f typeref:typename:void
|
||||
sighup dwm.c /^sighup(int unused)$/;" f typeref:typename:void
|
||||
sigterm dwm.c /^sigterm(int unused)$/;" f typeref:typename:void
|
||||
snap config.def.h /^static const unsigned int snap = 32; \/* snap pixel *\/$/;" v typeref:typename:const unsigned int
|
||||
snap config.h /^static const unsigned int snap = 32; \/* snap pixel *\/$/;" v typeref:typename:const unsigned int
|
||||
snext dwm.c /^ Client *snext;$/;" m struct:Client typeref:typename:Client * file:
|
||||
spawn dwm.c /^spawn(const Arg *arg)$/;" f typeref:typename:void
|
||||
spiral fibonacci.c /^spiral(Monitor *mon) {$/;" f typeref:typename:void
|
||||
stack dwm.c /^ Client *stack;$/;" m struct:Monitor typeref:typename:Client * file:
|
||||
stext dwm.c /^static char stext[1024];$/;" v typeref:typename:char[1024] file:
|
||||
sw dwm.c /^static int sw, sh; \/* X display screen geometry width, height *\/$/;" v typeref:typename:int file:
|
||||
symbol dwm.c /^ const char *symbol;$/;" m struct:__anon0f53a99e0a08 typeref:typename:const char * file:
|
||||
systray dwm.c /^static Systray *systray = NULL;$/;" v typeref:typename:Systray * file:
|
||||
systrayonleft config.def.h /^static const unsigned int systrayonleft = 0; \/* 0: systray in the right corner, >0: systray /;" v typeref:typename:const unsigned int
|
||||
systrayonleft config.h /^static const unsigned int systrayonleft = 0; \/* 0: systray in the right corner, >0: systray /;" v typeref:typename:const unsigned int
|
||||
systraypinning config.def.h /^static const unsigned int systraypinning = 0; \/* 0: sloppy systray follows selected monitor, /;" v typeref:typename:const unsigned int
|
||||
systraypinning config.h /^static const unsigned int systraypinning = 0; \/* 0: sloppy systray follows selected monitor, /;" v typeref:typename:const unsigned int
|
||||
systraypinningfailfirst config.def.h /^static const int systraypinningfailfirst = 1; \/* 1: if pinning fails, display systray on the /;" v typeref:typename:const int
|
||||
systraypinningfailfirst config.h /^static const int systraypinningfailfirst = 1; \/* 1: if pinning fails, display systray on the /;" v typeref:typename:const int
|
||||
systrayspacing config.def.h /^static const unsigned int systrayspacing = 2; \/* systray spacing *\/$/;" v typeref:typename:const unsigned int
|
||||
systrayspacing config.h /^static const unsigned int systrayspacing = 2; \/* systray spacing *\/$/;" v typeref:typename:const unsigned int
|
||||
systraytomon dwm.c /^systraytomon(Monitor *m) {$/;" f typeref:typename:Monitor *
|
||||
tag dwm.c /^tag(const Arg *arg)$/;" f typeref:typename:void
|
||||
tagmon dwm.c /^tagmon(const Arg *arg)$/;" f typeref:typename:void
|
||||
tags config.def.h /^static const char *tags[] = { " \\uf17c ", " \\uf1d8 ", " \\uf0ac ", " \\uf109 ", " \\uf09b ", "/;" v typeref:typename:const char * []
|
||||
tags config.h /^static const char *tags[] = { " \\uf17c ", " \\uf1d8 ", " \\uf0ac ", " \\uf109 ", " \\uf09b ", "/;" v typeref:typename:const char * []
|
||||
tags dwm.c /^ unsigned int tags;$/;" m struct:Client typeref:typename:unsigned int file:
|
||||
tags dwm.c /^ unsigned int tags;$/;" m struct:__anon0f53a99e0b08 typeref:typename:unsigned int file:
|
||||
tagscheme dwm.c /^static Clr **tagscheme;$/;" v typeref:typename:Clr ** file:
|
||||
tagset dwm.c /^ unsigned int tagset[2];$/;" m struct:Monitor typeref:typename:unsigned int[2] file:
|
||||
termcmd keys.h /^static const char *termcmd[] = { TERMINAL, NULL };$/;" v typeref:typename:const char * []
|
||||
tile dwm.c /^tile(Monitor *m)$/;" f typeref:typename:void
|
||||
title dwm.c /^ const char *title;$/;" m struct:__anon0f53a99e0b08 typeref:typename:const char * file:
|
||||
togglebar dwm.c /^togglebar(const Arg *arg)$/;" f typeref:typename:void
|
||||
togglefloating dwm.c /^togglefloating(const Arg *arg)$/;" f typeref:typename:void
|
||||
toggletag dwm.c /^toggletag(const Arg *arg)$/;" f typeref:typename:void
|
||||
toggleview dwm.c /^toggleview(const Arg *arg)$/;" f typeref:typename:void
|
||||
topbar config.def.h /^static const int topbar = 1; \/* 0 means bottom bar *\/$/;" v typeref:typename:const int
|
||||
topbar config.h /^static const int topbar = 1; \/* 0 means bottom bar *\/$/;" v typeref:typename:const int
|
||||
topbar dwm.c /^ int topbar;$/;" m struct:Monitor typeref:typename:int file:
|
||||
ui dwm.c /^ unsigned int ui;$/;" m union:__anon0f53a99e070a typeref:typename:unsigned int file:
|
||||
unfocus dwm.c /^unfocus(Client *c, int setfocus)$/;" f typeref:typename:void
|
||||
uninstall Makefile /^uninstall:$/;" t
|
||||
unmanage dwm.c /^unmanage(Client *c, int destroyed)$/;" f typeref:typename:void
|
||||
unmapnotify dwm.c /^unmapnotify(XEvent *e)$/;" f typeref:typename:void
|
||||
updatebarpos dwm.c /^updatebarpos(Monitor *m)$/;" f typeref:typename:void
|
||||
updatebars dwm.c /^updatebars(void)$/;" f typeref:typename:void
|
||||
updateclientlist dwm.c /^updateclientlist()$/;" f typeref:typename:void
|
||||
updategeom dwm.c /^updategeom(void)$/;" f typeref:typename:int
|
||||
updateicon dwm.c /^updateicon(Client *c)$/;" f typeref:typename:void
|
||||
updatenumlockmask dwm.c /^updatenumlockmask(void)$/;" f typeref:typename:void
|
||||
updatesizehints dwm.c /^updatesizehints(Client *c)$/;" f typeref:typename:void
|
||||
updatestatus dwm.c /^updatestatus(void)$/;" f typeref:typename:void
|
||||
updatesystray dwm.c /^updatesystray(void)$/;" f typeref:typename:void
|
||||
updatesystrayicongeom dwm.c /^updatesystrayicongeom(Client *i, int w, int h)$/;" f typeref:typename:void
|
||||
updatesystrayiconstate dwm.c /^updatesystrayiconstate(Client *i, XPropertyEvent *ev)$/;" f typeref:typename:void
|
||||
updatetitle dwm.c /^updatetitle(Client *c)$/;" f typeref:typename:void
|
||||
updatewindowtype dwm.c /^updatewindowtype(Client *c)$/;" f typeref:typename:void
|
||||
updatewmhints dwm.c /^updatewmhints(Client *c)$/;" f typeref:typename:void
|
||||
user_bh config.def.h /^static const int user_bh = 8; \/* 2 is the default spacing around the bar's fo/;" v typeref:typename:const int
|
||||
user_bh config.h /^static const int user_bh = 8; \/* 2 is the default spacing around the bar's fo/;" v typeref:typename:const int
|
||||
utf8decode drw.c /^utf8decode(const char *c, long *u, size_t clen)$/;" f typeref:typename:size_t file:
|
||||
utf8decodebyte drw.c /^utf8decodebyte(const char c, size_t *i)$/;" f typeref:typename:long file:
|
||||
utf8validate drw.c /^utf8validate(long *u, size_t i)$/;" f typeref:typename:size_t file:
|
||||
utfbyte drw.c /^static const unsigned char utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};$/;" v typeref:typename:const unsigned char[] file:
|
||||
utfmask drw.c /^static const unsigned char utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};$/;" v typeref:typename:const unsigned char[] file:
|
||||
utfmax drw.c /^static const long utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};$/;" v typeref:typename:const long[] file:
|
||||
utfmin drw.c /^static const long utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};$/;" v typeref:typename:const long[] file:
|
||||
v dwm.c /^ const void *v;$/;" m union:__anon0f53a99e070a typeref:typename:const void * file:
|
||||
view dwm.c /^view(const Arg *arg)$/;" f typeref:typename:void
|
||||
w drw.h /^ unsigned int w, h;$/;" m struct:__anon0f5116480308 typeref:typename:unsigned int
|
||||
w dwm.c /^ int x, y, w, h;$/;" m struct:Client typeref:typename:int file:
|
||||
wh dwm.c /^ int wx, wy, ww, wh; \/* window area *\/$/;" m struct:Monitor typeref:typename:int file:
|
||||
win dwm.c /^ Window win;$/;" m struct:Client typeref:typename:Window file:
|
||||
win dwm.c /^ Window win;$/;" m struct:Systray typeref:typename:Window file:
|
||||
wintoclient dwm.c /^wintoclient(Window w)$/;" f typeref:typename:Client *
|
||||
wintomon dwm.c /^wintomon(Window w)$/;" f typeref:typename:Monitor *
|
||||
wintosystrayicon dwm.c /^wintosystrayicon(Window w) {$/;" f typeref:typename:Client *
|
||||
wmatom dwm.c /^static Atom wmatom[WMLast], netatom[NetLast], xatom[XLast];$/;" v typeref:typename:Atom[] file:
|
||||
wmcheckwin dwm.c /^static Window root, wmcheckwin;$/;" v typeref:typename:Window file:
|
||||
ww dwm.c /^ int wx, wy, ww, wh; \/* window area *\/$/;" m struct:Monitor typeref:typename:int file:
|
||||
wx dwm.c /^ int wx, wy, ww, wh; \/* window area *\/$/;" m struct:Monitor typeref:typename:int file:
|
||||
wy dwm.c /^ int wx, wy, ww, wh; \/* window area *\/$/;" m struct:Monitor typeref:typename:int file:
|
||||
x dwm.c /^ int x, y, w, h;$/;" m struct:Client typeref:typename:int file:
|
||||
xatom dwm.c /^static Atom wmatom[WMLast], netatom[NetLast], xatom[XLast];$/;" v typeref:typename:Atom[] file:
|
||||
xerror dwm.c /^xerror(Display *dpy, XErrorEvent *ee)$/;" f typeref:typename:int
|
||||
xerrordummy dwm.c /^xerrordummy(Display *dpy, XErrorEvent *ee)$/;" f typeref:typename:int
|
||||
xerrorstart dwm.c /^xerrorstart(Display *dpy, XErrorEvent *ee)$/;" f typeref:typename:int
|
||||
xerrorxlib dwm.c /^static int (*xerrorxlib)(Display *, XErrorEvent *);$/;" v typeref:typename:int (*)(Display *,XErrorEvent *) file:
|
||||
xfont drw.h /^ XftFont *xfont;$/;" m struct:Fnt typeref:typename:XftFont *
|
||||
xfont_create drw.c /^xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)$/;" f typeref:typename:Fnt * file:
|
||||
xfont_free drw.c /^xfont_free(Fnt *font)$/;" f typeref:typename:void file:
|
||||
y dwm.c /^ int x, y, w, h;$/;" m struct:Client typeref:typename:int file:
|
||||
zoom dwm.c /^zoom(const Arg *arg)$/;" f typeref:typename:void
|
||||
42
KleinDwm/source/transient.c
Normal file
42
KleinDwm/source/transient.c
Normal file
@@ -0,0 +1,42 @@
|
||||
/* cc transient.c -o transient -lX11 */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
int main(void) {
|
||||
Display *d;
|
||||
Window r, f, t = None;
|
||||
XSizeHints h;
|
||||
XEvent e;
|
||||
|
||||
d = XOpenDisplay(NULL);
|
||||
if (!d)
|
||||
exit(1);
|
||||
r = DefaultRootWindow(d);
|
||||
|
||||
f = XCreateSimpleWindow(d, r, 100, 100, 400, 400, 0, 0, 0);
|
||||
h.min_width = h.max_width = h.min_height = h.max_height = 400;
|
||||
h.flags = PMinSize | PMaxSize;
|
||||
XSetWMNormalHints(d, f, &h);
|
||||
XStoreName(d, f, "floating");
|
||||
XMapWindow(d, f);
|
||||
|
||||
XSelectInput(d, f, ExposureMask);
|
||||
while (1) {
|
||||
XNextEvent(d, &e);
|
||||
|
||||
if (t == None) {
|
||||
sleep(5);
|
||||
t = XCreateSimpleWindow(d, r, 50, 50, 100, 100, 0, 0, 0);
|
||||
XSetTransientForHint(d, t, f);
|
||||
XStoreName(d, t, "transient");
|
||||
XMapWindow(d, t);
|
||||
XSelectInput(d, t, ExposureMask);
|
||||
}
|
||||
}
|
||||
|
||||
XCloseDisplay(d);
|
||||
exit(0);
|
||||
}
|
||||
171
KleinDwm/source/util.c
Normal file
171
KleinDwm/source/util.c
Normal file
@@ -0,0 +1,171 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
void
|
||||
die(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
|
||||
fputc(' ', stderr);
|
||||
perror(NULL);
|
||||
} else {
|
||||
fputc('\n', stderr);
|
||||
}
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void *
|
||||
ecalloc(size_t nmemb, size_t size)
|
||||
{
|
||||
void *p;
|
||||
|
||||
if (!(p = calloc(nmemb, size)))
|
||||
die("calloc:");
|
||||
return p;
|
||||
}
|
||||
|
||||
int
|
||||
normalizepath(const char *path, char **normal)
|
||||
{
|
||||
size_t len = strlen(path);
|
||||
*normal = (char *)malloc((len + 1) * sizeof(char));
|
||||
const char *walk = path;
|
||||
const char *match;
|
||||
size_t newlen = 0;
|
||||
|
||||
while ((match = strchr(walk, '/'))) {
|
||||
// Copy everything between match and walk
|
||||
strncpy(*normal + newlen, walk, match - walk);
|
||||
newlen += match - walk;
|
||||
walk += match - walk;
|
||||
|
||||
// Skip all repeating slashes
|
||||
while (*walk == '/')
|
||||
walk++;
|
||||
|
||||
// If not last character in path
|
||||
if (walk != path + len)
|
||||
(*normal)[newlen++] = '/';
|
||||
}
|
||||
|
||||
(*normal)[newlen++] = '\0';
|
||||
|
||||
// Copy remaining path
|
||||
strcat(*normal, walk);
|
||||
newlen += strlen(walk);
|
||||
|
||||
*normal = (char *)realloc(*normal, newlen * sizeof(char));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
parentdir(const char *path, char **parent)
|
||||
{
|
||||
char *normal;
|
||||
char *walk;
|
||||
|
||||
normalizepath(path, &normal);
|
||||
|
||||
// Pointer to last '/'
|
||||
if (!(walk = strrchr(normal, '/'))) {
|
||||
free(normal);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Get path up to last '/'
|
||||
size_t len = walk - normal;
|
||||
*parent = (char *)malloc((len + 1) * sizeof(char));
|
||||
|
||||
// Copy path up to last '/'
|
||||
strncpy(*parent, normal, len);
|
||||
// Add null char
|
||||
(*parent)[len] = '\0';
|
||||
|
||||
free(normal);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
mkdirp(const char *path)
|
||||
{
|
||||
char *normal;
|
||||
char *walk;
|
||||
size_t normallen;
|
||||
|
||||
normalizepath(path, &normal);
|
||||
normallen = strlen(normal);
|
||||
walk = normal;
|
||||
|
||||
while (walk < normal + normallen + 1) {
|
||||
// Get length from walk to next /
|
||||
size_t n = strcspn(walk, "/");
|
||||
|
||||
// Skip path /
|
||||
if (n == 0) {
|
||||
walk++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Length of current path segment
|
||||
size_t curpathlen = walk - normal + n;
|
||||
char curpath[curpathlen + 1];
|
||||
struct stat s;
|
||||
|
||||
// Copy path segment to stat
|
||||
strncpy(curpath, normal, curpathlen);
|
||||
strcpy(curpath + curpathlen, "");
|
||||
int res = stat(curpath, &s);
|
||||
|
||||
if (res < 0) {
|
||||
if (errno == ENOENT) {
|
||||
DEBUG("Making directory %s\n", curpath);
|
||||
if (mkdir(curpath, 0700) < 0) {
|
||||
fprintf(stderr, "Failed to make directory %s\n", curpath);
|
||||
perror("");
|
||||
free(normal);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Error statting directory %s\n", curpath);
|
||||
perror("");
|
||||
free(normal);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Continue to next path segment
|
||||
walk += n;
|
||||
}
|
||||
|
||||
free(normal);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
nullterminate(char **str, size_t *len)
|
||||
{
|
||||
if ((*str)[*len - 1] == '\0')
|
||||
return 0;
|
||||
|
||||
(*len)++;
|
||||
*str = (char*)realloc(*str, *len * sizeof(char));
|
||||
(*str)[*len - 1] = '\0';
|
||||
|
||||
return 0;
|
||||
}
|
||||
36
KleinDwm/source/util.c.orig
Normal file
36
KleinDwm/source/util.c.orig
Normal file
@@ -0,0 +1,36 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
void
|
||||
die(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
|
||||
fputc(' ', stderr);
|
||||
perror(NULL);
|
||||
} else {
|
||||
fputc('\n', stderr);
|
||||
}
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void *
|
||||
ecalloc(size_t nmemb, size_t size)
|
||||
{
|
||||
void *p;
|
||||
|
||||
if (!(p = calloc(nmemb, size)))
|
||||
die("calloc:");
|
||||
return p;
|
||||
}
|
||||
18
KleinDwm/source/util.h
Normal file
18
KleinDwm/source/util.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
#define MAX(A, B) ((A) > (B) ? (A) : (B))
|
||||
#define MIN(A, B) ((A) < (B) ? (A) : (B))
|
||||
#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B))
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG(...)
|
||||
#endif
|
||||
|
||||
void die(const char *fmt, ...);
|
||||
void *ecalloc(size_t nmemb, size_t size);
|
||||
int normalizepath(const char *path, char **normal);
|
||||
int mkdirp(const char *path);
|
||||
int parentdir(const char *path, char **parent);
|
||||
int nullterminate(char **str, size_t *len);
|
||||
BIN
KleinDwm/source/util.o
Normal file
BIN
KleinDwm/source/util.o
Normal file
Binary file not shown.
351
KleinDwm/source/yajl_dumps.c
Normal file
351
KleinDwm/source/yajl_dumps.c
Normal file
@@ -0,0 +1,351 @@
|
||||
#include "yajl_dumps.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
int
|
||||
dump_tag(yajl_gen gen, const char *name, const int tag_mask)
|
||||
{
|
||||
// clang-format off
|
||||
YMAP(
|
||||
YSTR("bit_mask"); YINT(tag_mask);
|
||||
YSTR("name"); YSTR(name);
|
||||
)
|
||||
// clang-format on
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
dump_tags(yajl_gen gen, const char *tags[], int tags_len)
|
||||
{
|
||||
// clang-format off
|
||||
YARR(
|
||||
for (int i = 0; i < tags_len; i++)
|
||||
dump_tag(gen, tags[i], 1 << i);
|
||||
)
|
||||
// clang-format on
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
dump_client(yajl_gen gen, Client *c)
|
||||
{
|
||||
// clang-format off
|
||||
YMAP(
|
||||
YSTR("name"); YSTR(c->name);
|
||||
YSTR("tags"); YINT(c->tags);
|
||||
YSTR("window_id"); YINT(c->win);
|
||||
YSTR("monitor_number"); YINT(c->mon->num);
|
||||
|
||||
YSTR("geometry"); YMAP(
|
||||
YSTR("current"); YMAP (
|
||||
YSTR("x"); YINT(c->x);
|
||||
YSTR("y"); YINT(c->y);
|
||||
YSTR("width"); YINT(c->w);
|
||||
YSTR("height"); YINT(c->h);
|
||||
)
|
||||
YSTR("old"); YMAP(
|
||||
YSTR("x"); YINT(c->oldx);
|
||||
YSTR("y"); YINT(c->oldy);
|
||||
YSTR("width"); YINT(c->oldw);
|
||||
YSTR("height"); YINT(c->oldh);
|
||||
)
|
||||
)
|
||||
|
||||
YSTR("size_hints"); YMAP(
|
||||
YSTR("base"); YMAP(
|
||||
YSTR("width"); YINT(c->basew);
|
||||
YSTR("height"); YINT(c->baseh);
|
||||
)
|
||||
YSTR("step"); YMAP(
|
||||
YSTR("width"); YINT(c->incw);
|
||||
YSTR("height"); YINT(c->inch);
|
||||
)
|
||||
YSTR("max"); YMAP(
|
||||
YSTR("width"); YINT(c->maxw);
|
||||
YSTR("height"); YINT(c->maxh);
|
||||
)
|
||||
YSTR("min"); YMAP(
|
||||
YSTR("width"); YINT(c->minw);
|
||||
YSTR("height"); YINT(c->minh);
|
||||
)
|
||||
YSTR("aspect_ratio"); YMAP(
|
||||
YSTR("min"); YDOUBLE(c->mina);
|
||||
YSTR("max"); YDOUBLE(c->maxa);
|
||||
)
|
||||
)
|
||||
|
||||
YSTR("border_width"); YMAP(
|
||||
YSTR("current"); YINT(c->bw);
|
||||
YSTR("old"); YINT(c->oldbw);
|
||||
)
|
||||
|
||||
YSTR("states"); YMAP(
|
||||
YSTR("is_fixed"); YBOOL(c->isfixed);
|
||||
YSTR("is_floating"); YBOOL(c->isfloating);
|
||||
YSTR("is_urgent"); YBOOL(c->isurgent);
|
||||
YSTR("never_focus"); YBOOL(c->neverfocus);
|
||||
YSTR("old_state"); YBOOL(c->oldstate);
|
||||
YSTR("is_fullscreen"); YBOOL(c->isfullscreen);
|
||||
)
|
||||
)
|
||||
// clang-format on
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
dump_monitor(yajl_gen gen, Monitor *mon, int is_selected)
|
||||
{
|
||||
// clang-format off
|
||||
YMAP(
|
||||
YSTR("master_factor"); YDOUBLE(mon->mfact);
|
||||
YSTR("num_master"); YINT(mon->nmaster);
|
||||
YSTR("num"); YINT(mon->num);
|
||||
YSTR("is_selected"); YBOOL(is_selected);
|
||||
|
||||
YSTR("monitor_geometry"); YMAP(
|
||||
YSTR("x"); YINT(mon->mx);
|
||||
YSTR("y"); YINT(mon->my);
|
||||
YSTR("width"); YINT(mon->mw);
|
||||
YSTR("height"); YINT(mon->mh);
|
||||
)
|
||||
|
||||
YSTR("window_geometry"); YMAP(
|
||||
YSTR("x"); YINT(mon->wx);
|
||||
YSTR("y"); YINT(mon->wy);
|
||||
YSTR("width"); YINT(mon->ww);
|
||||
YSTR("height"); YINT(mon->wh);
|
||||
)
|
||||
|
||||
YSTR("tagset"); YMAP(
|
||||
YSTR("current"); YINT(mon->tagset[mon->seltags]);
|
||||
YSTR("old"); YINT(mon->tagset[mon->seltags ^ 1]);
|
||||
)
|
||||
|
||||
YSTR("tag_state"); dump_tag_state(gen, mon->tagstate);
|
||||
|
||||
YSTR("clients"); YMAP(
|
||||
YSTR("selected"); YINT(mon->sel ? mon->sel->win : 0);
|
||||
YSTR("stack"); YARR(
|
||||
for (Client* c = mon->stack; c; c = c->snext)
|
||||
YINT(c->win);
|
||||
)
|
||||
YSTR("all"); YARR(
|
||||
for (Client* c = mon->clients; c; c = c->next)
|
||||
YINT(c->win);
|
||||
)
|
||||
)
|
||||
|
||||
YSTR("layout"); YMAP(
|
||||
YSTR("symbol"); YMAP(
|
||||
YSTR("current"); YSTR(mon->ltsymbol);
|
||||
YSTR("old"); YSTR(mon->lastltsymbol);
|
||||
)
|
||||
YSTR("address"); YMAP(
|
||||
YSTR("current"); YINT((uintptr_t)mon->lt[mon->sellt]);
|
||||
YSTR("old"); YINT((uintptr_t)mon->lt[mon->sellt ^ 1]);
|
||||
)
|
||||
)
|
||||
|
||||
YSTR("bar"); YMAP(
|
||||
YSTR("y"); YINT(mon->by);
|
||||
YSTR("is_shown"); YBOOL(mon->showbar);
|
||||
YSTR("is_top"); YBOOL(mon->topbar);
|
||||
YSTR("window_id"); YINT(mon->barwin);
|
||||
)
|
||||
)
|
||||
// clang-format on
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
dump_monitors(yajl_gen gen, Monitor *mons, Monitor *selmon)
|
||||
{
|
||||
// clang-format off
|
||||
YARR(
|
||||
for (Monitor *mon = mons; mon; mon = mon->next) {
|
||||
if (mon == selmon)
|
||||
dump_monitor(gen, mon, 1);
|
||||
else
|
||||
dump_monitor(gen, mon, 0);
|
||||
}
|
||||
)
|
||||
// clang-format on
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
dump_layouts(yajl_gen gen, const Layout layouts[], const int layouts_len)
|
||||
{
|
||||
// clang-format off
|
||||
YARR(
|
||||
for (int i = 0; i < layouts_len; i++) {
|
||||
YMAP(
|
||||
// Check for a NULL pointer. The cycle layouts patch adds an entry at
|
||||
// the end of the layouts array with a NULL pointer for the symbol
|
||||
YSTR("symbol"); YSTR((layouts[i].symbol ? layouts[i].symbol : ""));
|
||||
YSTR("address"); YINT((uintptr_t)(layouts + i));
|
||||
)
|
||||
}
|
||||
)
|
||||
// clang-format on
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
dump_tag_state(yajl_gen gen, TagState state)
|
||||
{
|
||||
// clang-format off
|
||||
YMAP(
|
||||
YSTR("selected"); YINT(state.selected);
|
||||
YSTR("occupied"); YINT(state.occupied);
|
||||
YSTR("urgent"); YINT(state.urgent);
|
||||
)
|
||||
// clang-format on
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
dump_tag_event(yajl_gen gen, int mon_num, TagState old_state,
|
||||
TagState new_state)
|
||||
{
|
||||
// clang-format off
|
||||
YMAP(
|
||||
YSTR("tag_change_event"); YMAP(
|
||||
YSTR("monitor_number"); YINT(mon_num);
|
||||
YSTR("old_state"); dump_tag_state(gen, old_state);
|
||||
YSTR("new_state"); dump_tag_state(gen, new_state);
|
||||
)
|
||||
)
|
||||
// clang-format on
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
dump_client_focus_change_event(yajl_gen gen, Client *old_client,
|
||||
Client *new_client, int mon_num)
|
||||
{
|
||||
// clang-format off
|
||||
YMAP(
|
||||
YSTR("client_focus_change_event"); YMAP(
|
||||
YSTR("monitor_number"); YINT(mon_num);
|
||||
YSTR("old_win_id"); old_client == NULL ? YNULL() : YINT(old_client->win);
|
||||
YSTR("new_win_id"); new_client == NULL ? YNULL() : YINT(new_client->win);
|
||||
)
|
||||
)
|
||||
// clang-format on
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
dump_layout_change_event(yajl_gen gen, const int mon_num,
|
||||
const char *old_symbol, const Layout *old_layout,
|
||||
const char *new_symbol, const Layout *new_layout)
|
||||
{
|
||||
// clang-format off
|
||||
YMAP(
|
||||
YSTR("layout_change_event"); YMAP(
|
||||
YSTR("monitor_number"); YINT(mon_num);
|
||||
YSTR("old_symbol"); YSTR(old_symbol);
|
||||
YSTR("old_address"); YINT((uintptr_t)old_layout);
|
||||
YSTR("new_symbol"); YSTR(new_symbol);
|
||||
YSTR("new_address"); YINT((uintptr_t)new_layout);
|
||||
)
|
||||
)
|
||||
// clang-format on
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
dump_monitor_focus_change_event(yajl_gen gen, const int last_mon_num,
|
||||
const int new_mon_num)
|
||||
{
|
||||
// clang-format off
|
||||
YMAP(
|
||||
YSTR("monitor_focus_change_event"); YMAP(
|
||||
YSTR("old_monitor_number"); YINT(last_mon_num);
|
||||
YSTR("new_monitor_number"); YINT(new_mon_num);
|
||||
)
|
||||
)
|
||||
// clang-format on
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
dump_focused_title_change_event(yajl_gen gen, const int mon_num,
|
||||
const Window client_id, const char *old_name,
|
||||
const char *new_name)
|
||||
{
|
||||
// clang-format off
|
||||
YMAP(
|
||||
YSTR("focused_title_change_event"); YMAP(
|
||||
YSTR("monitor_number"); YINT(mon_num);
|
||||
YSTR("client_window_id"); YINT(client_id);
|
||||
YSTR("old_name"); YSTR(old_name);
|
||||
YSTR("new_name"); YSTR(new_name);
|
||||
)
|
||||
)
|
||||
// clang-format on
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
dump_client_state(yajl_gen gen, const ClientState *state)
|
||||
{
|
||||
// clang-format off
|
||||
YMAP(
|
||||
YSTR("old_state"); YBOOL(state->oldstate);
|
||||
YSTR("is_fixed"); YBOOL(state->isfixed);
|
||||
YSTR("is_floating"); YBOOL(state->isfloating);
|
||||
YSTR("is_fullscreen"); YBOOL(state->isfullscreen);
|
||||
YSTR("is_urgent"); YBOOL(state->isurgent);
|
||||
YSTR("never_focus"); YBOOL(state->neverfocus);
|
||||
)
|
||||
// clang-format on
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
dump_focused_state_change_event(yajl_gen gen, const int mon_num,
|
||||
const Window client_id,
|
||||
const ClientState *old_state,
|
||||
const ClientState *new_state)
|
||||
{
|
||||
// clang-format off
|
||||
YMAP(
|
||||
YSTR("focused_state_change_event"); YMAP(
|
||||
YSTR("monitor_number"); YINT(mon_num);
|
||||
YSTR("client_window_id"); YINT(client_id);
|
||||
YSTR("old_state"); dump_client_state(gen, old_state);
|
||||
YSTR("new_state"); dump_client_state(gen, new_state);
|
||||
)
|
||||
)
|
||||
// clang-format on
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
dump_error_message(yajl_gen gen, const char *reason)
|
||||
{
|
||||
// clang-format off
|
||||
YMAP(
|
||||
YSTR("result"); YSTR("error");
|
||||
YSTR("reason"); YSTR(reason);
|
||||
)
|
||||
// clang-format on
|
||||
|
||||
return 0;
|
||||
}
|
||||
65
KleinDwm/source/yajl_dumps.h
Normal file
65
KleinDwm/source/yajl_dumps.h
Normal file
@@ -0,0 +1,65 @@
|
||||
#ifndef YAJL_DUMPS_H_
|
||||
#define YAJL_DUMPS_H_
|
||||
|
||||
#include <string.h>
|
||||
#include <yajl/yajl_gen.h>
|
||||
|
||||
#define YSTR(str) yajl_gen_string(gen, (unsigned char *)str, strlen(str))
|
||||
#define YINT(num) yajl_gen_integer(gen, num)
|
||||
#define YDOUBLE(num) yajl_gen_double(gen, num)
|
||||
#define YBOOL(v) yajl_gen_bool(gen, v)
|
||||
#define YNULL() yajl_gen_null(gen)
|
||||
#define YARR(body) \
|
||||
{ \
|
||||
yajl_gen_array_open(gen); \
|
||||
body; \
|
||||
yajl_gen_array_close(gen); \
|
||||
}
|
||||
#define YMAP(body) \
|
||||
{ \
|
||||
yajl_gen_map_open(gen); \
|
||||
body; \
|
||||
yajl_gen_map_close(gen); \
|
||||
}
|
||||
|
||||
int dump_tag(yajl_gen gen, const char *name, const int tag_mask);
|
||||
|
||||
int dump_tags(yajl_gen gen, const char *tags[], int tags_len);
|
||||
|
||||
int dump_client(yajl_gen gen, Client *c);
|
||||
|
||||
int dump_monitor(yajl_gen gen, Monitor *mon, int is_selected);
|
||||
|
||||
int dump_monitors(yajl_gen gen, Monitor *mons, Monitor *selmon);
|
||||
|
||||
int dump_layouts(yajl_gen gen, const Layout layouts[], const int layouts_len);
|
||||
|
||||
int dump_tag_state(yajl_gen gen, TagState state);
|
||||
|
||||
int dump_tag_event(yajl_gen gen, int mon_num, TagState old_state,
|
||||
TagState new_state);
|
||||
|
||||
int dump_client_focus_change_event(yajl_gen gen, Client *old_client,
|
||||
Client *new_client, int mon_num);
|
||||
|
||||
int dump_layout_change_event(yajl_gen gen, const int mon_num,
|
||||
const char *old_symbol, const Layout *old_layout,
|
||||
const char *new_symbol, const Layout *new_layout);
|
||||
|
||||
int dump_monitor_focus_change_event(yajl_gen gen, const int last_mon_num,
|
||||
const int new_mon_num);
|
||||
|
||||
int dump_focused_title_change_event(yajl_gen gen, const int mon_num,
|
||||
const Window client_id,
|
||||
const char *old_name, const char *new_name);
|
||||
|
||||
int dump_client_state(yajl_gen gen, const ClientState *state);
|
||||
|
||||
int dump_focused_state_change_event(yajl_gen gen, const int mon_num,
|
||||
const Window client_id,
|
||||
const ClientState *old_state,
|
||||
const ClientState *new_state);
|
||||
|
||||
int dump_error_message(yajl_gen gen, const char *reason);
|
||||
|
||||
#endif // YAJL_DUMPS_H_
|
||||
11
customstatusbar/statusbars/colorvars.sh
Normal file
11
customstatusbar/statusbars/colorvars.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#Colors for status bar, allows for various theme Colors
|
||||
|
||||
## Default Colors
|
||||
|
||||
black="#000000"
|
||||
white="#ffffff"
|
||||
grey="#555555"
|
||||
green="#00ff00"
|
||||
yellow="#ffff00"
|
||||
red="#ff0000"
|
||||
|
||||
38
customstatusbar/statusbars/install.sh
Executable file
38
customstatusbar/statusbars/install.sh
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#Check if command exits
|
||||
command_exists() {
|
||||
command -v "$1" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
#DWM dependency is running
|
||||
if ! pgrep -x "dwm" > /dev/null; then
|
||||
echo "DWM is not running. Please ensure that you got that shit installed and its your window manager."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#status2d dependency (update later if you find out how)
|
||||
if command_exists dwm; then
|
||||
echo "DWM is installed. Make sure you got status2D patch applied for properrendering."
|
||||
fi
|
||||
|
||||
#Package dependcies
|
||||
requires_packages=("grep" "gawk" "procps" "coreutils" "lm-sensors" "network-manager" "x11-xserver-utils")
|
||||
|
||||
for pkg in "${requires_packages[@]}"; do
|
||||
if ! dpkg -s "$pkg" >/dev/null 2>&1; then
|
||||
echo "Package $pkg is not installed. Installing..."
|
||||
sudo apt update
|
||||
sudo apt install -y "$pkg"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to install $pkg. Install it manually, or its equivalent and edit source code"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Package $pkg is installed already. YAY"
|
||||
fi
|
||||
done
|
||||
|
||||
sudo cp /home/klein/KleinWindowManagement/customstatusbar/statusbars/statusbar.sh /usr/bin/
|
||||
|
||||
echo "Installation done. Run statusbar.sh in shell"
|
||||
328
customstatusbar/statusbars/oldstatus2dbar.sh
Executable file
328
customstatusbar/statusbars/oldstatus2dbar.sh
Executable file
@@ -0,0 +1,328 @@
|
||||
#!/bin/bash
|
||||
# This is a relic of the old. Shit sucks
|
||||
|
||||
|
||||
##Global Definitions
|
||||
#Color definitions
|
||||
color_black="#000000" #outline
|
||||
color_white="#ffffff" #default
|
||||
color_green="#00ff00"
|
||||
color_yellow="#ffff00"
|
||||
color_red="#ff0000"
|
||||
color_grey="#555555"
|
||||
|
||||
#Primary scheme - medium orchid
|
||||
color_scheme_1="#c067dd" #background
|
||||
color_scheme_2="#a656c2"
|
||||
color_scheme_3="#8B45A7"
|
||||
color_scheme_4="#71348C" #highlight
|
||||
color_scheme_5="#572371"
|
||||
color_scheme_6="#3C1256"
|
||||
color_scheme_7="#22013B" #default text color
|
||||
|
||||
#Complimentary scheme - pastel green
|
||||
c_color_scheme_1="#84dd67" #Complimentary background color
|
||||
c_color_scheme_2="#72c059"
|
||||
c_color_scheme_3="#60a44b"
|
||||
c_color_scheme_4="#4f883d" #Complimentary highlight
|
||||
c_color_scheme_5="#3f6e30"
|
||||
c_color_scheme_6="#2f5523"
|
||||
c_color_scheme_7="#203d17" #Complimentary txt color
|
||||
|
||||
#GLobal basics
|
||||
basic_y=27
|
||||
basic_x=0
|
||||
|
||||
get_cpu() {
|
||||
local cpu_stats=$(top -bn1 | rep "%pu(s)")
|
||||
local us=$(echo $cpu_stats | awk '{print $2}' | tr -d '%')
|
||||
local sy=$(echo $cpu_stats | awk '{print $4}' | tr -d '%')
|
||||
local ni=$(echo $cpu_stats | awk '{print $6}' | tr -d '%')
|
||||
local id=$(echo $cpu_stats | awk '{print $8}' | tr -d '%')
|
||||
local wa=$(echo $cpu_stats | awk '{print $10}' | tr -d '%')
|
||||
local hi=$(echo $cpu_stats | awk '{print $12}' | tr -d '%')
|
||||
local si=$(echo $cpu_stats | awk '{print $14}' | tr -d '%')
|
||||
local st=$(echo $cpu_stats | awk '{print $16}' | tr -d '%')
|
||||
|
||||
local top_cpu_consumer=$(ps -eo %cpu,comm --sort=-%cpu | head -n 2 | tail -n 1 | awk '{print $2}')
|
||||
top_cpu_consumer="${top_cpu_consumer:0:8}"
|
||||
|
||||
local base_x=$basic_x
|
||||
local base_y=$basic_y
|
||||
local max_height=16
|
||||
local bar_width=3
|
||||
local status_line=""
|
||||
local bg=$color_grey
|
||||
|
||||
declare -A colors=( [us]="#ffd700" [sy]="#ff4500" [ni]="#ff8c00" [id]="#008000"
|
||||
[wa]="#0000ff" [hi]="#4b0082" [si]="#800080" [st]="#a0522d" )
|
||||
|
||||
for state in us sy ni id wa hi si st; do
|
||||
local percentage=$(echo ${!state})
|
||||
if [[ ! "$percentage" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then
|
||||
percentage=0
|
||||
fi
|
||||
|
||||
local bar_height=$(echo "$percentage * $max_height / 100" | bc)
|
||||
|
||||
status_line+="^c$bg^^r${base_x},$((base_y - max_height)),${bar_width},${max_height}^"
|
||||
|
||||
local upper_y=$((base_y - bar_height))
|
||||
status_line+="^c${colors[$state]}^^r$base_x,$upper_y,$bar_width,$bar_height^"
|
||||
base_x=$((base_x + bar_width + 2))
|
||||
done
|
||||
|
||||
status_line+="^d^^f30^"
|
||||
|
||||
echo "{[$status_line][User:$us|Sys:$sy]$top_cpu_consumer]}"
|
||||
}
|
||||
|
||||
get_ram() {
|
||||
local mem_info=$(free -m)
|
||||
local total_mem=$(echo "$mem_info" | awk '/^Mem:/ {print $2}')
|
||||
local used_mem=$(echo "$mem_info" | awk '/^Mem:/ {print $3}')
|
||||
|
||||
local mem_usage=$(awk "BEGIN {printf \"%.0f\", ($used_mem/$total_mem)*100}")
|
||||
|
||||
local max_height=20
|
||||
local bar_height=$((max_height * mem_usage / 100))
|
||||
local bar_width=5
|
||||
local base_x=$basic_x
|
||||
local base_y=$basic_y
|
||||
local color=$color_white
|
||||
local border=$color_black
|
||||
local bg=$color_grey
|
||||
|
||||
local status_line=""
|
||||
status_line+="^c$bg^"
|
||||
status_line+="^r$base_x,$((base_y - max_height)),$((bar_width + 2)),$((max_height + 2))^"
|
||||
status_line+="^c$color^"
|
||||
status_line+="^r$((base_x + 1)),$((base_y - bar_height - 1)),${bar_width},${bar_height}^"
|
||||
status_line+="^d^^f8^"
|
||||
status_line+="${mem_usage}%"
|
||||
|
||||
echo "{[$status_line]}"
|
||||
}
|
||||
|
||||
get_df() {
|
||||
# Fetch disk usage data
|
||||
local usage_p2=$(df -h | grep '/dev/nvme0n1p2' | awk '{print $5}' | tr -d '%')
|
||||
local usage_p4=$(df -h | grep '/dev/nvme0n1p4' | awk '{print $5}' | tr -d '%')
|
||||
|
||||
# Safeguard against malformed input
|
||||
if [[ ! "$usage_p2" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then
|
||||
usage_p2=0
|
||||
fi
|
||||
if [[ ! "$usage_p4" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then
|
||||
usage_p4=0
|
||||
fi
|
||||
|
||||
# Base settings for drawing
|
||||
local base_x=$basic_x
|
||||
local base_y=$basic_y
|
||||
local max_height=20
|
||||
local bar_width=3
|
||||
local status_line=""
|
||||
local bg=$color_grey
|
||||
|
||||
# Define colors for each partition
|
||||
declare -A colors=(
|
||||
[p2]="#FFD700"
|
||||
[p4]="#FF4500"
|
||||
)
|
||||
|
||||
# Define percentages
|
||||
local -A usages=(
|
||||
[p2]=$usage_p2
|
||||
[p4]=$usage_p4
|
||||
)
|
||||
|
||||
# Create a vertical bar for each partition
|
||||
for partition in p2 p4; do
|
||||
local percentage=${usages[$partition]}
|
||||
local bar_height=$(echo "$percentage * $max_height / 100" | bc)
|
||||
|
||||
# Draw the background rectangle for 100% capacity
|
||||
status_line+="^c$bg^^r${base_x},$((base_y - max_height)),${bar_width},${max_height}^"
|
||||
|
||||
# Draw the usage bar on top of the background
|
||||
local upper_y=$((base_y - bar_height))
|
||||
status_line+="^c${colors[$partition]}^^r$base_x,$upper_y,$bar_width,$bar_height^"
|
||||
base_x=$((base_x + bar_width + 2))
|
||||
done
|
||||
|
||||
# Reset formatting and move forward
|
||||
status_line+="^d^^f10^"
|
||||
|
||||
echo "{[$status_line][Sys:$usage_p2%|User:$usage_p4%]}"
|
||||
}
|
||||
|
||||
get_temperature() {
|
||||
local temp=$(sensors | awk '/Package id 0/ {gsub(/[^0-9.]/, "", $4); print int($4)}')
|
||||
local max_temp=70
|
||||
|
||||
local color=$color_white
|
||||
local bg=$color_scheme_1
|
||||
local outline=$color_white
|
||||
|
||||
if [ "$temp" -gt "$max_temp" ]; then
|
||||
color=$color_red
|
||||
elif [ "$temp" -lt "$max_temp" ]; then
|
||||
color=$color_green
|
||||
fi
|
||||
|
||||
local fill_height=$(($temp * 10 / $max_temp))
|
||||
local base_y=$((basic_y - 22))
|
||||
local temp_icon="^c$outline^"
|
||||
temp_icon+="^r5,$base_y,4,11^"
|
||||
temp_icon+="^c$bg^"
|
||||
temp_icon+="^r6,$((base_y + 4)),2,9^"
|
||||
temp_icon+="^c$color^"
|
||||
temp_icon+="^r6,$((base_y + 7 - fill_height)),2,$fill_height^"
|
||||
temp_icon+="^c$outline^"
|
||||
temp_icon+="^r4,$((base_y + 8)),7,4^"
|
||||
temp_icon+="^r5,$((base_y + 9)),5,4^"
|
||||
temp_icon+="^d^^f10^"
|
||||
echo "^c$color_white^{[^d^$temp_icon $temp°C^c$color_white^]}^d^"
|
||||
}
|
||||
|
||||
get_battery() {
|
||||
local status=$(cat /sys/class/power_supply/BAT0/status)
|
||||
local capacity=$(cat /sys/class/power_supply/BAT0/capacity)
|
||||
local current_now=$(cat /sys/class/power_supply/BAT0/current_now)
|
||||
local voltage_now=$(cat /sys/class/power_supply/BAT0/voltage_now)
|
||||
local power_consumption=$(awk "BEGIN {printf \"%.2f\n\", ($current_now/1000000)*($voltage_now/1000000)}")
|
||||
|
||||
local color=$color_scheme_7
|
||||
local bg=$color_scheme_1
|
||||
local outline=$color_black
|
||||
local color_status=$color_white
|
||||
|
||||
if [[ "$capacity" -le 15 ]]; then
|
||||
color=$color_red
|
||||
shutdown -h now
|
||||
elif [[ "$capacity" -le 25 ]]; then
|
||||
color=$color_yellow
|
||||
else
|
||||
color=$color_green
|
||||
fi
|
||||
|
||||
local fill_width=$(($capacity * 20 / 100))
|
||||
local base_y=$((basic_y - 20))
|
||||
local battery_icon="^c$outline^"
|
||||
battery_icon+="^r2,$base_y,22,10^"
|
||||
battery_icon+="^c$bg^"
|
||||
battery_icon+="^r3,$((base_y +1)),20,8^"
|
||||
battery_icon+="^c$color^"
|
||||
battery_icon+="^r3,$((base_y + 1)),$fill_width,8^"
|
||||
battery_icon+="^c$outline^"
|
||||
battery_icon+="^r0,$((base_y + 3)),2,4^"
|
||||
battery_icon+="^d^^f24^"
|
||||
|
||||
if [[ "$status" == "Full" ]]; then
|
||||
status="F"
|
||||
color_status=$color_green
|
||||
elif [[ "$status" == "Charging" ]]; then
|
||||
status="C"
|
||||
color_status=$c_color_scheme_1
|
||||
elif [[ "$status" == "Discharging" ]]; then
|
||||
status="D"
|
||||
color_status=$color_yellow
|
||||
elif [[ "$status" == "Not charging" ]]; then
|
||||
status="NC"
|
||||
color_status=$color_scheme_4
|
||||
else
|
||||
status="NA"
|
||||
fi
|
||||
|
||||
echo "{[$battery_icon^c$color^$capacity^d^%]}"
|
||||
}
|
||||
|
||||
get_wifi() {
|
||||
local color=$color_black
|
||||
local bg=$color_grey
|
||||
local ssid=$(nmcli -t -f active,ssid dev wifi | grep '^yes' | cut -d':' -f2)
|
||||
ssid="${ssid:-No WiFi}"
|
||||
ssid="${ssid:0:15}"
|
||||
|
||||
local dwm=$(grep wlp0s20f3 /proc/net/wireless | awk '{ print int($4) }')
|
||||
local signal_normalized=$(( (dwm + 90) * 100 / 60 ))
|
||||
local signal
|
||||
if [ $signal_normalized -gt 100 ]; then
|
||||
signal=100
|
||||
elif [ $signal_normalized -lt 0 ]; then
|
||||
signal=0
|
||||
else
|
||||
signal=$signal_normalized
|
||||
fi
|
||||
|
||||
local color=$color_white
|
||||
if [ $signal -ge 66 ]; then
|
||||
color=$color_green
|
||||
elif [ $signal -le 33 ]; then
|
||||
color=$color_red
|
||||
elif [ $signal -gt 33 ] && [ $signal -lt 66 ]; then
|
||||
color=$color_yellow
|
||||
fi
|
||||
|
||||
local base_x=$basic_x
|
||||
local base_y=$((basic_y - 7))
|
||||
local max_bars=5
|
||||
local bars_filled=$((signal / 20))
|
||||
|
||||
local wifi_icon="^c$color^"
|
||||
for i in 1 2 3 4 5; do
|
||||
local width=$((3 * i + 1))
|
||||
local height=$((3 * i + 1))
|
||||
local height_placement=$((base_y - height))
|
||||
if [ $i -le $bars_filled ]; then
|
||||
wifi_icon+="^c$color^"
|
||||
else
|
||||
wifi_icon+="^c$bg^"
|
||||
fi
|
||||
wifi_icon+="^r$((base_x + 3 * (i - 1))),$height_placement,$width,$height^"
|
||||
done
|
||||
wifi_icon+="^d^^f18^"
|
||||
|
||||
echo "{[$wifi_icon$ssid[$signal%]]}"
|
||||
}
|
||||
|
||||
get_screen_width() {
|
||||
local screen_width_px=$(xdpyinfo | awk '/dimensions:/ {print $2}' | cut -dx -f1)
|
||||
echo $((screen_width_px / 1))
|
||||
}
|
||||
|
||||
get_status() {
|
||||
local screen_width=$(get_screen_width)
|
||||
declare -A components=(
|
||||
[cpu]="$(get_cpu)"
|
||||
[ram]="$(get_ram)"
|
||||
[df]="$(get_df)"
|
||||
[temperature]="$(get_temperature)"
|
||||
[battery]="$(get_battery)"
|
||||
[wifi]="$(get_wifi)"
|
||||
)
|
||||
local status_line=""
|
||||
local separator=""
|
||||
local total_length=0
|
||||
local sep_length=${#separator}
|
||||
|
||||
for component in date wifi battery temperature df ram cpu; do
|
||||
local component_output="${components[$component]}"
|
||||
local component_length=$(( ${#component_output} + sep_length ))
|
||||
|
||||
if [[ $((total_length + component_length)) -le $screen_width ]]; then
|
||||
status_line="${component_output}${status_line}"
|
||||
total_length=$((total_length + component_length))
|
||||
else
|
||||
echo "Skipped: $component due to space constraints"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "$status_line"
|
||||
}
|
||||
|
||||
while true; do
|
||||
xsetroot -name "$(get_status)"
|
||||
sleep 1
|
||||
done
|
||||
220
customstatusbar/statusbars/statusbar.sh
Executable file
220
customstatusbar/statusbars/statusbar.sh
Executable file
@@ -0,0 +1,220 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Source color vars
|
||||
source /home/klein/KleinWindowManagement/customstatusbar/statusbars/colorvars.sh
|
||||
|
||||
# Define Basic Dimentions
|
||||
base_x=0
|
||||
base_y=2
|
||||
max_height=23
|
||||
bar_width=5
|
||||
gap=5
|
||||
|
||||
cpu() {
|
||||
local cpu_line1=$(grep '^cpu ' /proc/stat)
|
||||
sleep 2
|
||||
local cpu_line2=$(grep '^cpu ' /proc/stat)
|
||||
local -a cpu1=(${cpu_line1//cpu/})
|
||||
local -a cpu2=(${cpu_line2//cpu/})
|
||||
local total1=0
|
||||
local total2=0
|
||||
local idle1=${cpu1[3]}
|
||||
local idle2=${cpu2[3]}
|
||||
for i in "${cpu1[@]}"; do
|
||||
total1=$((total1 + i))
|
||||
done
|
||||
for i in "${cpu2[@]}"; do
|
||||
total2=$((total2 + i))
|
||||
done
|
||||
local total_delta=$((total2 - total1))
|
||||
local idle_delta=$((idle2 - idle1))
|
||||
|
||||
local usage=$((100 * (total_delta - idle_delta) / total_delta))
|
||||
|
||||
local usage_height=$(( (max_height * usage) / 100 ))
|
||||
local usage_y=$((base_y + max_height - usage_height))
|
||||
local color=$white
|
||||
if [ $usage -gt 50 ]; then
|
||||
color=$red
|
||||
fi
|
||||
local status_line=""
|
||||
status_line+="^c${grey}^^r${base_x},${base_y},${bar_width},${max_height}^"
|
||||
status_line+="^c${color}^^r${base_x},${usage_y},${bar_width},${usage_height}^"
|
||||
status_line+="^d^^f5^"
|
||||
local topcon=$( ps -eo %cpu,comm --sort=-%cpu | head -n 2 | tail -n 1 | awk '{print $2}')
|
||||
topcon="${topcon:0:5}" # trunkate output
|
||||
echo "{CPU:${status_line}${usage}% : ${topcon}}"
|
||||
}
|
||||
|
||||
ram() {
|
||||
local m_mem=$(free -m)
|
||||
local t_mem=$(echo "$m_mem" | awk '/^Mem:/ {print $2}')
|
||||
local u_mem=$(echo "$m_mem" | awk '/^Mem:/ {print $3}')
|
||||
local p_mem=$(awk "BEGIN {printf \"%.0f\", ($u_mem/$t_mem)*100}")
|
||||
local usage_height=$((max_height * mem_usage / 100))
|
||||
local usage_y=$((base_y + max_height - usage_height))
|
||||
local status_line=""
|
||||
status_line+="^c$grey^^r$base_x,${base_y},${bar_width},${max_height}^"
|
||||
status_line+="^c$white^^r${base_x},${usage_y},${bar_width},${usage_height}^"
|
||||
status_line+="^d^^f5^"
|
||||
status_line+="${p_mem}%"
|
||||
echo "{Mem:$status_line}"
|
||||
}
|
||||
|
||||
swap() {
|
||||
local m_swap=$(free -m)
|
||||
local t_swap=$(echo "$m_mem" | awk '/^Swap:/ {print $2}')
|
||||
local u_swap=$(echo "$m_mem" | awk '/^Swap:/ {print $3}')
|
||||
if [[ "$u_swap" -eq 0 ]]; then
|
||||
return
|
||||
fi
|
||||
local p_swap=$(awk "BEGIN {printf \"%.0f\", ($u_swap/$t_swap)*100}")
|
||||
local usage_height=$((max_height * mem_usage / 100))
|
||||
local usage_y=$((base_y + max_height - usage_height))
|
||||
local status_line=""
|
||||
status_line+="^c$grey^^r$base_x,${base_y},${bar_width},${max_height}^"
|
||||
status_line+="^c$white^^r${base_x},${usage_y},${bar_width},${usage_height}^"
|
||||
status_line+="^d^^f5^"
|
||||
status_line+="${p_swap}%"
|
||||
echo "{Swap:$status_line}|"
|
||||
}
|
||||
|
||||
disk() {
|
||||
local usage_p2=$(df -h | grep '/dev/nvme0n1p2' | awk '{print $5}' | tr -d '%')
|
||||
local usage_p4=$(df -h | grep '/dev/nvme0n1p4' | awk '{print $5}' | tr -d '%')
|
||||
if [[ ! "$usage_p2" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then
|
||||
usage_p2=0
|
||||
fi
|
||||
if [[ ! "$usage_p4" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then
|
||||
usage_p4=0
|
||||
fi
|
||||
local status_line=""
|
||||
local -A usages=(
|
||||
[p2]=$usage_p2
|
||||
[p4]=$usage_p4
|
||||
)
|
||||
for partition in p2 p4; do
|
||||
local percentage=${usages[$partition]}
|
||||
local usage_height=$(($percentage * $max_height / 100))
|
||||
local usage_y=$((base_y + max_height - usage_height))
|
||||
status_line+="^c$grey^^r${base_x},${base_y},${bar_width},${max_height}^"
|
||||
status_line+="^c$white^^r${base_x},${usage_y},${bar_width},${usage_height}^"
|
||||
base_x=$((base_x + bar_width +2))
|
||||
done
|
||||
status_line+="^d^^f15^"
|
||||
echo "{Disk:${status_line}R:${usage_p2}%|U:${usage_p4}%}"
|
||||
}
|
||||
|
||||
cpu_temperature(){
|
||||
local temp=$(sensors | awk '/Package id 0/ {gsub(/[^0-9.]/, "", $4); print int($4)}')
|
||||
local max_temp=70
|
||||
local color=$white
|
||||
if [ "$temp" -gt "$max_temp" ]; then
|
||||
color=$red
|
||||
elif [ "$temp" -lt "$max_temp" ]; then
|
||||
color=$green
|
||||
fi
|
||||
local adj_y=5
|
||||
local usage_height=$(($temp * 10 / $max_temp))
|
||||
local usage_y=$((adj_y + 10 - usage_height))
|
||||
local temp_icon="^c$black^"
|
||||
temp_icon+="^r7,${base_y},5,15^" #Bar behind the green
|
||||
temp_icon+="^c$color^"
|
||||
temp_icon+="^r8,${usage_y},3,${usage_height}^" # Fill Bar
|
||||
temp_icon+="^c$black^"
|
||||
temp_icon+="^r4,17,11,5^"
|
||||
temp_icon+="^r5,19,9,6^"
|
||||
temp_icon+="^d^^f15^"
|
||||
echo "^c$white^{^d^$temp_icon $temp°C^c$white^}^d^"
|
||||
}
|
||||
|
||||
battery() {
|
||||
local status=$(cat /sys/class/power_supply/BAT0/status)
|
||||
local capacity=$(cat /sys/class/power_supply/BAT0/capacity)
|
||||
local color=$white
|
||||
if [[ "$capacity" -le 15 ]]; then
|
||||
color=$red
|
||||
elif [[ "$capacity" -le 25 ]]; then
|
||||
color=$yellow
|
||||
else
|
||||
color=$green
|
||||
fi
|
||||
local adj_y=7
|
||||
local fill_width=$(($capacity * 20 / 100))
|
||||
local battery_icon="^c$black^"
|
||||
battery_icon+="^r2,10,24,12^"
|
||||
battery_icon+="^c$grey^"
|
||||
battery_icon+="^r4,12,20,8^"
|
||||
battery_icon+="^c$color^"
|
||||
battery_icon+="^r4,12,$fill_width,8^"
|
||||
battery_icon+="^c$black^"
|
||||
battery_icon+="^r26,13,4,6^"
|
||||
battery_icon+="^d^^f35^"
|
||||
local color_status=$white
|
||||
if [[ "$status" == "Full" ]]; then
|
||||
color_status=$green
|
||||
elif [[ "$status" == "Charging" ]]; then
|
||||
color_status=$green
|
||||
elif [[ "$status" == "Discharging" ]]; then
|
||||
color_status=$grey
|
||||
elif [[ "$status" == "Not charging" ]]; then
|
||||
color_status=$white
|
||||
else
|
||||
status="NA"
|
||||
fi
|
||||
local volt=$(sensors | awk '/BAT0-acpi-0/ {getline; getline; print $2}')
|
||||
echo "{${battery_icon}^c${color_status}^${capacity}^d^% ${volt}V}"
|
||||
}
|
||||
|
||||
wifi() {
|
||||
local ssid=$(nmcli -t -f active,ssid dev wifi | grep '^yes' | cut -d':' -f2)
|
||||
ssid="${ssid:-No WiFi}"
|
||||
ssid="${ssid:0:15}"
|
||||
local dwm=$(grep wlp0s20f3 /proc/net/wireless | awk '{ print int($4) }')
|
||||
local signal_normalized=$(( (dwm + 90) * 100 / 60 ))
|
||||
local signal
|
||||
if [ $signal_normalized -gt 100 ]; then
|
||||
signal=100
|
||||
elif [ $signal_normalized -lt 0 ]; then
|
||||
signal=0
|
||||
else
|
||||
signal=$signal_normalized
|
||||
fi
|
||||
|
||||
local color=$white
|
||||
if [ $signal -ge 66 ]; then
|
||||
color=$green
|
||||
elif [ $signal -le 33 ]; then
|
||||
color=$red
|
||||
elif [ $signal -gt 33 ] && [ $signal -lt 66 ]; then
|
||||
color=$yellow
|
||||
fi
|
||||
|
||||
local max_bars=5
|
||||
local bars_filled=$((signal / 20))
|
||||
|
||||
local wifi_icon="^c$color^"
|
||||
for i in 1 2 3 4 5; do
|
||||
local width=$((3 * i + 1))
|
||||
local height=$((3 * i + 1))
|
||||
local adj_y=$((max_height - height))
|
||||
if [ $i -le $bars_filled ]; then
|
||||
wifi_icon+="^c$color^"
|
||||
else
|
||||
wifi_icon+="^c$grey^"
|
||||
fi
|
||||
wifi_icon+="^r$((base_x + 4 * (i - 2))),$adj_y,$width,$height^"
|
||||
done
|
||||
wifi_icon+="^d^^f17^"
|
||||
|
||||
echo "{ $wifi_icon$ssid : $signal% }"
|
||||
}
|
||||
|
||||
status(){
|
||||
echo "$(cpu)|$(ram)|$(swap)$(disk)|$(cpu_temperature)|$(battery)|$(wifi)"
|
||||
}
|
||||
while true; do
|
||||
xsetroot -name "$(status)"
|
||||
done
|
||||
|
||||
|
||||
51
customstatusbar/systrays/brightnesssystray2.sh
Executable file
51
customstatusbar/systrays/brightnesssystray2.sh
Executable file
@@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
|
||||
icon_name="/usr/share/icons/Adwaita/16x16/status/display-brightness-symbolic.symbolic.png"
|
||||
|
||||
# Persistent loop to handle the system tray icon
|
||||
while true
|
||||
do
|
||||
# Command to keep the icon in the systray and open the dialog on click
|
||||
yad --notification --image="$icon_name" \
|
||||
--command="bash -c '\
|
||||
while : ; do \
|
||||
current_brightness=\$(brightnessctl get 2>/dev/null); \
|
||||
max_brightness=\$(brightnessctl max 2>/dev/null); \
|
||||
brightness_percent=\$((current_brightness * 100 / max_brightness)); \
|
||||
command_output=\$(yad --title \"Brightness Control\" --width=300 --height=150 --posx=810 --posy=575 \
|
||||
--form --separator=\",\" --field=\"Set Brightness (0-100):NUM\" \"\$brightness_percent\"!0..100!1 \
|
||||
--scale --value=\$brightness_percent --min-value=0 --max-value=100 --step=1 \
|
||||
--button=\"Increase Brightness\":1 --button=\"Decrease Brightness\":2 --button=gtk-ok:0 --button=gtk-cancel:3 \
|
||||
--fixed --undecorated --on-top --skip-taskbar --skip-pager 2>/dev/null); \
|
||||
ret=\$?; \
|
||||
case \$ret in \
|
||||
0) \
|
||||
new_brightness=\$(echo \$command_output | cut -d ',' -f 1); \
|
||||
brightnessctl set \$new_brightness% > /dev/null 2>&1; \
|
||||
break;; \
|
||||
1) \
|
||||
current_brightness=\$(brightnessctl get 2>/dev/null); \
|
||||
max_brightness=\$(brightnessctl max 2>/dev/null); \
|
||||
brightness_percent=\$((current_brightness * 100 / max_brightness)); \
|
||||
new_brightness=\$((brightness_percent + 10)); \
|
||||
[ \$new_brightness -gt 100 ] && new_brightness=100; \
|
||||
brightnessctl set \$new_brightness% > /dev/null 2>&1; \
|
||||
continue;; \
|
||||
2) \
|
||||
current_brightness=\$(brightnessctl get 2>/dev/null); \
|
||||
max_brightness=\$(brightnessctl max 2>/dev/null); \
|
||||
brightness_percent=\$((current_brightness * 100 / max_brightness)); \
|
||||
new_brightness=\$((brightness_percent - 10)); \
|
||||
[ \$new_brightness -lt 0 ] && new_brightness=0; \
|
||||
brightnessctl set \$new_brightness% > /dev/null 2>&1; \
|
||||
continue;; \
|
||||
3) \
|
||||
break;; \
|
||||
*) \
|
||||
break;; \
|
||||
esac; \
|
||||
done'"
|
||||
|
||||
# Sleep to ensure it doesn't respawn too quickly if closed
|
||||
sleep 0.5
|
||||
done
|
||||
37
customstatusbar/systrays/brightnesssystray2.sh.bak
Executable file
37
customstatusbar/systrays/brightnesssystray2.sh.bak
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
icon_name="/usr/share/icons/Adwaita/16x16/status/display-brightness-symbolic.symbolic.png"
|
||||
|
||||
# Persistent loop to handle the system tray icon
|
||||
while true
|
||||
do
|
||||
# Command to keep the icon in the systray and open the dialog on click
|
||||
yad --notification --image="$icon_name" \
|
||||
--command="bash -c '\
|
||||
while : ; do \
|
||||
current_brightness=\$(brightnessctl get 2>/dev/null); \
|
||||
max_brightness=\$(brightnessctl max 2>/dev/null); \
|
||||
brightness_percent=\$((current_brightness * 100 / max_brightness)); \
|
||||
command_output=\$(yad --title \"Brightness Control\" --width=300 --height=50 --posx=810 --posy=575 \
|
||||
--form --separator=\",\" --field=\"Set Brightness (0-100):NUM\" \"\$brightness_percent\"!0..100!1 \
|
||||
--button=\"Apply\":0 --button=\"Increase Brightness:1\" --button=\"Decrease Brightness:2\" --button=gtk-cancel:3 \
|
||||
--fixed --undecorated --on-top --skip-taskbar --skip-pager 2>/dev/null); \
|
||||
ret=\$?; \
|
||||
case \$ret in \
|
||||
0) \
|
||||
new_brightness=\$(echo \$command_output | cut -d ',' -f 1); \
|
||||
brightnessctl set \$new_brightness% > /dev/null 2>&1;; \
|
||||
1) \
|
||||
brightnessctl set +10% > /dev/null 2>&1;; \
|
||||
2) \
|
||||
brightnessctl set 10%- > /dev/null 2>&1;; \
|
||||
3) \
|
||||
break;; \
|
||||
*) \
|
||||
break;; \
|
||||
esac; \
|
||||
done'"
|
||||
|
||||
# Sleep to ensure it doesn't respawn too quickly if closed
|
||||
sleep 0.5
|
||||
done
|
||||
17
customstatusbar/systrays/expansivesystray.sh
Executable file
17
customstatusbar/systrays/expansivesystray.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Icon path
|
||||
icon_path="/usr/share/icons/Adwaita/16x16/devices/display-symbolic.symbolic.png"
|
||||
|
||||
# Persistent loop to handle the system tray icon
|
||||
while true; do
|
||||
yad --notification --image="$icon_path" \
|
||||
--command="bash -c 'if pgrep -x conky > /dev/null; then killall conky; else conky & disown; fi'" &
|
||||
|
||||
# Wait for the tray icon to be closed
|
||||
wait $!
|
||||
|
||||
# Sleep to ensure it doesn't respawn too quickly if closed
|
||||
sleep 2
|
||||
done
|
||||
|
||||
43
customstatusbar/systrays/screenshotsystray.sh
Executable file
43
customstatusbar/systrays/screenshotsystray.sh
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Icon path
|
||||
icon_path="/usr/share/icons/Adwaita/16x16/devices/camera-photo-symbolic.symbolic.png"
|
||||
|
||||
# Directory to save screenshots
|
||||
screenshot_dir="/home/klein/Pictures/screenshots"
|
||||
export screenshot_dir # Export the directory path
|
||||
|
||||
# Ensure directory exists
|
||||
mkdir -p "$screenshot_dir"
|
||||
|
||||
# Persistent loop to handle the system tray icon
|
||||
while true; do
|
||||
yad --notification --image="$icon_path" \
|
||||
--command="bash -c '\
|
||||
while :; do \
|
||||
yad --title \"Screenshot Tool\" --width=300 --height=50 \
|
||||
--button=\"Full Screen:0\" --button=\"Select Window:1\" --button=\"Cancel:2\" \
|
||||
--center; \
|
||||
ret=\$?; \
|
||||
counter=1; \
|
||||
while true; do \
|
||||
file_path=\"\$screenshot_dir/Screenshot_\${counter}.png\"; \
|
||||
if [[ ! -f \"\$file_path\" ]]; then \
|
||||
break; \
|
||||
fi; \
|
||||
((counter++)); \
|
||||
done; \
|
||||
case \$ret in \
|
||||
0) \
|
||||
scrot \"\$file_path\"; \
|
||||
break; ;; \
|
||||
1) \
|
||||
scrot -s \"\$file_path\"; \
|
||||
break; ;; \
|
||||
2|*) \
|
||||
break; ;; \
|
||||
esac; \
|
||||
done'" \
|
||||
# Sleep to ensure it doesn't respawn too quickly if closed
|
||||
sleep 2
|
||||
done
|
||||
4
customstatusbar/systrays/startupscript.sh
Executable file
4
customstatusbar/systrays/startupscript.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
/home/klein/KleinWindowManagement/customstatusbar/systrays/screenshotsystray.sh &
|
||||
/home/klein/KleinWindowManagement/customstatusbar/systrays/brightnesssystray2.sh &
|
||||
30
dmenu/LICENSE
Normal file
30
dmenu/LICENSE
Normal file
@@ -0,0 +1,30 @@
|
||||
MIT/X Consortium License
|
||||
|
||||
© 2006-2019 Anselm R Garbe <anselm@garbe.ca>
|
||||
© 2006-2008 Sander van Dijk <a.h.vandijk@gmail.com>
|
||||
© 2006-2007 Michał Janeczek <janeczek@gmail.com>
|
||||
© 2007 Kris Maglione <jg@suckless.org>
|
||||
© 2009 Gottox <gottox@s01.de>
|
||||
© 2009 Markus Schnalke <meillo@marmaro.de>
|
||||
© 2009 Evan Gates <evan.gates@gmail.com>
|
||||
© 2010-2012 Connor Lane Smith <cls@lubutu.com>
|
||||
© 2014-2022 Hiltjo Posthuma <hiltjo@codemadness.org>
|
||||
© 2015-2019 Quentin Rameau <quinq@fifth.space>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
58
dmenu/Makefile
Normal file
58
dmenu/Makefile
Normal file
@@ -0,0 +1,58 @@
|
||||
# dmenu - dynamic menu
|
||||
# See LICENSE file for copyright and license details.
|
||||
|
||||
include config.mk
|
||||
|
||||
SRC = drw.c dmenu.c stest.c util.c
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
||||
all: dmenu stest
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
|
||||
config.h:
|
||||
cp config.def.h $@
|
||||
|
||||
$(OBJ): arg.h config.h config.mk drw.h
|
||||
|
||||
dmenu: dmenu.o drw.o util.o
|
||||
$(CC) -o $@ dmenu.o drw.o util.o $(LDFLAGS)
|
||||
|
||||
stest: stest.o
|
||||
$(CC) -o $@ stest.o $(LDFLAGS)
|
||||
|
||||
clean:
|
||||
rm -f dmenu stest $(OBJ) dmenu-$(VERSION).tar.gz
|
||||
|
||||
dist: clean
|
||||
mkdir -p dmenu-$(VERSION)
|
||||
cp LICENSE Makefile README arg.h config.def.h config.mk dmenu.1\
|
||||
drw.h util.h dmenu_path dmenu_run stest.1 $(SRC)\
|
||||
dmenu-$(VERSION)
|
||||
tar -cf dmenu-$(VERSION).tar dmenu-$(VERSION)
|
||||
gzip dmenu-$(VERSION).tar
|
||||
rm -rf dmenu-$(VERSION)
|
||||
|
||||
install: all
|
||||
mkdir -p $(DESTDIR)$(PREFIX)/bin
|
||||
cp -f dmenu dmenu_path dmenu_run stest $(DESTDIR)$(PREFIX)/bin
|
||||
chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu
|
||||
chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_path
|
||||
chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_run
|
||||
chmod 755 $(DESTDIR)$(PREFIX)/bin/stest
|
||||
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
|
||||
sed "s/VERSION/$(VERSION)/g" < dmenu.1 > $(DESTDIR)$(MANPREFIX)/man1/dmenu.1
|
||||
sed "s/VERSION/$(VERSION)/g" < stest.1 > $(DESTDIR)$(MANPREFIX)/man1/stest.1
|
||||
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/dmenu.1
|
||||
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/stest.1
|
||||
|
||||
uninstall:
|
||||
rm -f $(DESTDIR)$(PREFIX)/bin/dmenu\
|
||||
$(DESTDIR)$(PREFIX)/bin/dmenu_path\
|
||||
$(DESTDIR)$(PREFIX)/bin/dmenu_run\
|
||||
$(DESTDIR)$(PREFIX)/bin/stest\
|
||||
$(DESTDIR)$(MANPREFIX)/man1/dmenu.1\
|
||||
$(DESTDIR)$(MANPREFIX)/man1/stest.1
|
||||
|
||||
.PHONY: all clean dist install uninstall
|
||||
24
dmenu/README
Normal file
24
dmenu/README
Normal file
@@ -0,0 +1,24 @@
|
||||
dmenu - dynamic menu
|
||||
====================
|
||||
dmenu is an efficient dynamic menu for X.
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
In order to build dmenu you need the Xlib header files.
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
Edit config.mk to match your local setup (dmenu is installed into
|
||||
the /usr/local namespace by default).
|
||||
|
||||
Afterwards enter the following command to build and install dmenu
|
||||
(if necessary as root):
|
||||
|
||||
make clean install
|
||||
|
||||
|
||||
Running dmenu
|
||||
-------------
|
||||
See the man page for details.
|
||||
49
dmenu/arg.h
Normal file
49
dmenu/arg.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copy me if you can.
|
||||
* by 20h
|
||||
*/
|
||||
|
||||
#ifndef ARG_H__
|
||||
#define ARG_H__
|
||||
|
||||
extern char *argv0;
|
||||
|
||||
/* use main(int argc, char *argv[]) */
|
||||
#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\
|
||||
argv[0] && argv[0][0] == '-'\
|
||||
&& argv[0][1];\
|
||||
argc--, argv++) {\
|
||||
char argc_;\
|
||||
char **argv_;\
|
||||
int brk_;\
|
||||
if (argv[0][1] == '-' && argv[0][2] == '\0') {\
|
||||
argv++;\
|
||||
argc--;\
|
||||
break;\
|
||||
}\
|
||||
for (brk_ = 0, argv[0]++, argv_ = argv;\
|
||||
argv[0][0] && !brk_;\
|
||||
argv[0]++) {\
|
||||
if (argv_ != argv)\
|
||||
break;\
|
||||
argc_ = argv[0][0];\
|
||||
switch (argc_)
|
||||
|
||||
#define ARGEND }\
|
||||
}
|
||||
|
||||
#define ARGC() argc_
|
||||
|
||||
#define EARGF(x) ((argv[0][1] == '\0' && argv[1] == NULL)?\
|
||||
((x), abort(), (char *)0) :\
|
||||
(brk_ = 1, (argv[0][1] != '\0')?\
|
||||
(&argv[0][1]) :\
|
||||
(argc--, argv++, argv[0])))
|
||||
|
||||
#define ARGF() ((argv[0][1] == '\0' && argv[1] == NULL)?\
|
||||
(char *)0 :\
|
||||
(brk_ = 1, (argv[0][1] != '\0')?\
|
||||
(&argv[0][1]) :\
|
||||
(argc--, argv++, argv[0])))
|
||||
|
||||
#endif
|
||||
28
dmenu/config.def.h
Normal file
28
dmenu/config.def.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
/* Default settings; can be overriden by command line. */
|
||||
|
||||
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
|
||||
/* -fn option overrides fonts[0]; default X11 font or font set */
|
||||
static const char *fonts[] = {
|
||||
"monospace:size=10"
|
||||
};
|
||||
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
|
||||
static const char *colors[SchemeLast][2] = {
|
||||
/* fg bg */
|
||||
[SchemeNorm] = { "#bbbbbb", "#222222" },
|
||||
[SchemeSel] = { "#eeeeee", "#005577" },
|
||||
[SchemeOut] = { "#000000", "#00ffff" },
|
||||
[SchemeBorder] = { "#282a2e", NULL },
|
||||
};
|
||||
/* -l and -g options; controls number of lines and columns in grid if > 0 */
|
||||
static unsigned int lines = 6;
|
||||
static unsigned int columns = 4;
|
||||
|
||||
/*
|
||||
* Characters not considered part of a word while deleting words
|
||||
* for example: " /?\"&[]"
|
||||
*/
|
||||
static const char worddelimiters[] = " ";
|
||||
|
||||
/* Size of the window border */
|
||||
static unsigned int border_width = 3;
|
||||
27
dmenu/config.def.h.orig
Normal file
27
dmenu/config.def.h.orig
Normal file
@@ -0,0 +1,27 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
/* Default settings; can be overriden by command line. */
|
||||
|
||||
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
|
||||
/* -fn option overrides fonts[0]; default X11 font or font set */
|
||||
static const char *fonts[] = {
|
||||
"monospace:size=10"
|
||||
};
|
||||
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
|
||||
static const char *colors[SchemeLast][2] = {
|
||||
/* fg bg */
|
||||
[SchemeNorm] = { "#bbbbbb", "#222222" },
|
||||
[SchemeSel] = { "#eeeeee", "#005577" },
|
||||
[SchemeOut] = { "#000000", "#00ffff" },
|
||||
};
|
||||
/* -l and -g options; controls number of lines and columns in grid if > 0 */
|
||||
static unsigned int lines = 6;
|
||||
static unsigned int columns = 4;
|
||||
|
||||
/*
|
||||
* Characters not considered part of a word while deleting words
|
||||
* for example: " /?\"&[]"
|
||||
*/
|
||||
static const char worddelimiters[] = " ";
|
||||
|
||||
/* Size of the window border */
|
||||
static unsigned int border_width = 3;
|
||||
10
dmenu/config.def.h.rej
Normal file
10
dmenu/config.def.h.rej
Normal file
@@ -0,0 +1,10 @@
|
||||
--- config.def.h
|
||||
+++ config.def.h
|
||||
@@ -22,3 +23,7 @@ static unsigned int lines = 0;
|
||||
* for example: " /?\"&[]"
|
||||
*/
|
||||
static const char worddelimiters[] = " ";
|
||||
+
|
||||
+/* Size of the window border */
|
||||
+static unsigned int border_width = 0;
|
||||
+
|
||||
27
dmenu/config.h
Normal file
27
dmenu/config.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
/* Default settings; can be overriden by command line. */
|
||||
|
||||
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
|
||||
/* -fn option overrides fonts[0]; default X11 font or font set */
|
||||
static const char *fonts[] = {
|
||||
"monospace:size=10"
|
||||
};
|
||||
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
|
||||
static const char *colors[SchemeLast][2] = {
|
||||
/* Scheme fg bg */
|
||||
[SchemeNorm] = { "#bbbbbb", "#222222" },
|
||||
[SchemeSel] = { "#eeeeee", "#005577" },
|
||||
[SchemeOut] = { "#000000", "#00ffff" },
|
||||
};
|
||||
/* -l and -g options; controls number of lines and columns in grid if > 0 */
|
||||
static unsigned int lines = 6;
|
||||
static unsigned int columns = 4;
|
||||
|
||||
/*
|
||||
* Characters not considered part of a word while deleting words
|
||||
* for example: " /?\"&[]"
|
||||
*/
|
||||
static const char worddelimiters[] = " ";
|
||||
|
||||
/* Size of the window border */
|
||||
static unsigned int border_width = 3;
|
||||
32
dmenu/config.mk
Normal file
32
dmenu/config.mk
Normal file
@@ -0,0 +1,32 @@
|
||||
# dmenu version
|
||||
VERSION = 5.3
|
||||
|
||||
# paths
|
||||
PREFIX = /usr/local
|
||||
MANPREFIX = $(PREFIX)/share/man
|
||||
|
||||
X11INC = /usr/X11R6/include
|
||||
X11LIB = /usr/X11R6/lib
|
||||
|
||||
# Xinerama, comment if you don't want it
|
||||
XINERAMALIBS = -lXinerama
|
||||
XINERAMAFLAGS = -DXINERAMA
|
||||
|
||||
# freetype
|
||||
FREETYPELIBS = -lfontconfig -lXft
|
||||
FREETYPEINC = /usr/include/freetype2
|
||||
# OpenBSD (uncomment)
|
||||
#FREETYPEINC = $(X11INC)/freetype2
|
||||
#MANPREFIX = ${PREFIX}/man
|
||||
|
||||
# includes and libs
|
||||
INCS = -I$(X11INC) -I$(FREETYPEINC)
|
||||
LIBS = -L$(X11LIB) -lX11 $(XINERAMALIBS) $(FREETYPELIBS)
|
||||
|
||||
# flags
|
||||
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" $(XINERAMAFLAGS)
|
||||
CFLAGS = -std=c99 -pedantic -Wall -Os $(INCS) $(CPPFLAGS)
|
||||
LDFLAGS = $(LIBS)
|
||||
|
||||
# compiler and linker
|
||||
CC = cc
|
||||
BIN
dmenu/dmenu
Executable file
BIN
dmenu/dmenu
Executable file
Binary file not shown.
199
dmenu/dmenu.1
Normal file
199
dmenu/dmenu.1
Normal file
@@ -0,0 +1,199 @@
|
||||
.TH DMENU 1 dmenu\-VERSION
|
||||
.SH NAME
|
||||
dmenu \- dynamic menu
|
||||
.SH SYNOPSIS
|
||||
.B dmenu
|
||||
.RB [ \-bfiv ]
|
||||
.RB [ \-g
|
||||
.IR columns ]
|
||||
.RB [ \-l
|
||||
.IR lines ]
|
||||
.RB [ \-m
|
||||
.IR monitor ]
|
||||
.RB [ \-p
|
||||
.IR prompt ]
|
||||
.RB [ \-fn
|
||||
.IR font ]
|
||||
.RB [ \-nb
|
||||
.IR color ]
|
||||
.RB [ \-nf
|
||||
.IR color ]
|
||||
.RB [ \-sb
|
||||
.IR color ]
|
||||
.RB [ \-sf
|
||||
.IR color ]
|
||||
.RB [ \-w
|
||||
.IR windowid ]
|
||||
.P
|
||||
.BR dmenu_run " ..."
|
||||
.SH DESCRIPTION
|
||||
.B dmenu
|
||||
is a dynamic menu for X, which reads a list of newline\-separated items from
|
||||
stdin. When the user selects an item and presses Return, their choice is printed
|
||||
to stdout and dmenu terminates. Entering text will narrow the items to those
|
||||
matching the tokens in the input.
|
||||
.P
|
||||
.B dmenu_run
|
||||
is a script used by
|
||||
.IR dwm (1)
|
||||
which lists programs in the user's $PATH and runs the result in their $SHELL.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-b
|
||||
dmenu appears at the bottom of the screen.
|
||||
.TP
|
||||
.B \-f
|
||||
dmenu grabs the keyboard before reading stdin if not reading from a tty. This
|
||||
is faster, but will lock up X until stdin reaches end\-of\-file.
|
||||
.TP
|
||||
.B \-i
|
||||
dmenu matches menu items case insensitively.
|
||||
.TP
|
||||
.BI \-g " columns"
|
||||
dmenu lists items in a grid with the given number of columns.
|
||||
.TP
|
||||
.BI \-l " lines"
|
||||
dmenu lists items in a grid with the given number of lines.
|
||||
.TP
|
||||
.BI \-m " monitor"
|
||||
dmenu is displayed on the monitor number supplied. Monitor numbers are starting
|
||||
from 0.
|
||||
.TP
|
||||
.BI \-p " prompt"
|
||||
defines the prompt to be displayed to the left of the input field.
|
||||
.TP
|
||||
.BI \-fn " font"
|
||||
defines the font or font set used.
|
||||
.TP
|
||||
.BI \-nb " color"
|
||||
defines the normal background color.
|
||||
.IR #RGB ,
|
||||
.IR #RRGGBB ,
|
||||
and X color names are supported.
|
||||
.TP
|
||||
.BI \-nf " color"
|
||||
defines the normal foreground color.
|
||||
.TP
|
||||
.BI \-sb " color"
|
||||
defines the selected background color.
|
||||
.TP
|
||||
.BI \-sf " color"
|
||||
defines the selected foreground color.
|
||||
.TP
|
||||
.B \-v
|
||||
prints version information to stdout, then exits.
|
||||
.TP
|
||||
.BI \-w " windowid"
|
||||
embed into windowid.
|
||||
.SH USAGE
|
||||
dmenu is completely controlled by the keyboard. Items are selected using the
|
||||
arrow keys, page up, page down, home, and end.
|
||||
.TP
|
||||
.B Tab
|
||||
Copy the selected item to the input field.
|
||||
.TP
|
||||
.B Return
|
||||
Confirm selection. Prints the selected item to stdout and exits, returning
|
||||
success.
|
||||
.TP
|
||||
.B Ctrl-Return
|
||||
Confirm selection. Prints the selected item to stdout and continues.
|
||||
.TP
|
||||
.B Shift\-Return
|
||||
Confirm input. Prints the input text to stdout and exits, returning success.
|
||||
.TP
|
||||
.B Escape
|
||||
Exit without selecting an item, returning failure.
|
||||
.TP
|
||||
.B Ctrl-Left
|
||||
Move cursor to the start of the current word
|
||||
.TP
|
||||
.B Ctrl-Right
|
||||
Move cursor to the end of the current word
|
||||
.TP
|
||||
.B C\-a
|
||||
Home
|
||||
.TP
|
||||
.B C\-b
|
||||
Left
|
||||
.TP
|
||||
.B C\-c
|
||||
Escape
|
||||
.TP
|
||||
.B C\-d
|
||||
Delete
|
||||
.TP
|
||||
.B C\-e
|
||||
End
|
||||
.TP
|
||||
.B C\-f
|
||||
Right
|
||||
.TP
|
||||
.B C\-g
|
||||
Escape
|
||||
.TP
|
||||
.B C\-h
|
||||
Backspace
|
||||
.TP
|
||||
.B C\-i
|
||||
Tab
|
||||
.TP
|
||||
.B C\-j
|
||||
Return
|
||||
.TP
|
||||
.B C\-J
|
||||
Shift-Return
|
||||
.TP
|
||||
.B C\-k
|
||||
Delete line right
|
||||
.TP
|
||||
.B C\-m
|
||||
Return
|
||||
.TP
|
||||
.B C\-M
|
||||
Shift-Return
|
||||
.TP
|
||||
.B C\-n
|
||||
Down
|
||||
.TP
|
||||
.B C\-p
|
||||
Up
|
||||
.TP
|
||||
.B C\-u
|
||||
Delete line left
|
||||
.TP
|
||||
.B C\-w
|
||||
Delete word left
|
||||
.TP
|
||||
.B C\-y
|
||||
Paste from primary X selection
|
||||
.TP
|
||||
.B C\-Y
|
||||
Paste from X clipboard
|
||||
.TP
|
||||
.B M\-b
|
||||
Move cursor to the start of the current word
|
||||
.TP
|
||||
.B M\-f
|
||||
Move cursor to the end of the current word
|
||||
.TP
|
||||
.B M\-g
|
||||
Home
|
||||
.TP
|
||||
.B M\-G
|
||||
End
|
||||
.TP
|
||||
.B M\-h
|
||||
Up
|
||||
.TP
|
||||
.B M\-j
|
||||
Page down
|
||||
.TP
|
||||
.B M\-k
|
||||
Page up
|
||||
.TP
|
||||
.B M\-l
|
||||
Down
|
||||
.SH SEE ALSO
|
||||
.IR dwm (1),
|
||||
.IR stest (1)
|
||||
838
dmenu/dmenu.c
Normal file
838
dmenu/dmenu.c
Normal file
@@ -0,0 +1,838 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#include <ctype.h>
|
||||
#include <locale.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xutil.h>
|
||||
#ifdef XINERAMA
|
||||
#include <X11/extensions/Xinerama.h>
|
||||
#endif
|
||||
#include <X11/Xft/Xft.h>
|
||||
|
||||
#include "drw.h"
|
||||
#include "util.h"
|
||||
|
||||
/* macros */
|
||||
#define INTERSECT(x,y,w,h,r) (MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \
|
||||
* MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org)))
|
||||
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||
|
||||
/* enums */
|
||||
enum { SchemeNorm, SchemeSel, SchemeOut, SchemeBorder, SchemeLast }; /* color schemes */
|
||||
|
||||
struct item {
|
||||
char *text;
|
||||
struct item *left, *right;
|
||||
int out;
|
||||
};
|
||||
|
||||
static char text[BUFSIZ] = "";
|
||||
static char *embed;
|
||||
static int bh, mw, mh;
|
||||
static int inputw = 0, promptw;
|
||||
static int lrpad; /* sum of left and right padding */
|
||||
static size_t cursor;
|
||||
static struct item *items = NULL;
|
||||
static struct item *matches, *matchend;
|
||||
static struct item *prev, *curr, *next, *sel;
|
||||
static int mon = -1, screen;
|
||||
|
||||
static Atom clip, utf8;
|
||||
static Display *dpy;
|
||||
static Window root, parentwin, win;
|
||||
static XIC xic;
|
||||
|
||||
static Drw *drw;
|
||||
static Clr *scheme[SchemeLast];
|
||||
|
||||
#include "config.h"
|
||||
|
||||
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
|
||||
static char *(*fstrstr)(const char *, const char *) = strstr;
|
||||
|
||||
static unsigned int
|
||||
textw_clamp(const char *str, unsigned int n)
|
||||
{
|
||||
unsigned int w = drw_fontset_getwidth_clamp(drw, str, n) + lrpad;
|
||||
return MIN(w, n);
|
||||
}
|
||||
|
||||
static void
|
||||
appenditem(struct item *item, struct item **list, struct item **last)
|
||||
{
|
||||
if (*last)
|
||||
(*last)->right = item;
|
||||
else
|
||||
*list = item;
|
||||
|
||||
item->left = *last;
|
||||
item->right = NULL;
|
||||
*last = item;
|
||||
}
|
||||
|
||||
static void
|
||||
calcoffsets(void)
|
||||
{
|
||||
int i, n;
|
||||
|
||||
if (lines > 0)
|
||||
n = (lines * columns * bh) - 1;
|
||||
else
|
||||
n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">"));
|
||||
/* calculate which items will begin the next page and previous page */
|
||||
for (i = 0, next = curr; next; next = next->right)
|
||||
if ((i += (lines > 0) ? bh : textw_clamp(next->text, n)) > n)
|
||||
break;
|
||||
for (i = 0, prev = curr; prev && prev->left; prev = prev->left)
|
||||
if ((i += (lines > 0) ? bh : textw_clamp(prev->left->text, n)) > n)
|
||||
break;
|
||||
}
|
||||
|
||||
static int
|
||||
max_textw(void)
|
||||
{
|
||||
int len = 0;
|
||||
for (struct item *item = items; item && item->text; item++)
|
||||
len = MAX(TEXTW(item->text), len);
|
||||
return len;
|
||||
}
|
||||
|
||||
static void
|
||||
cleanup(void)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
XUngrabKey(dpy, AnyKey, AnyModifier, root);
|
||||
for (i = 0; i < SchemeLast; i++)
|
||||
free(scheme[i]);
|
||||
for (i = 0; items && items[i].text; ++i)
|
||||
free(items[i].text);
|
||||
free(items);
|
||||
drw_free(drw);
|
||||
XSync(dpy, False);
|
||||
XCloseDisplay(dpy);
|
||||
}
|
||||
|
||||
static char *
|
||||
cistrstr(const char *h, const char *n)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (!n[0])
|
||||
return (char *)h;
|
||||
|
||||
for (; *h; ++h) {
|
||||
for (i = 0; n[i] && tolower((unsigned char)n[i]) ==
|
||||
tolower((unsigned char)h[i]); ++i)
|
||||
;
|
||||
if (n[i] == '\0')
|
||||
return (char *)h;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
drawitem(struct item *item, int x, int y, int w)
|
||||
{
|
||||
if (item == sel)
|
||||
drw_setscheme(drw, scheme[SchemeSel]);
|
||||
else if (item->out)
|
||||
drw_setscheme(drw, scheme[SchemeOut]);
|
||||
else
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
|
||||
return drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
drawdate(int x, int y, int w)
|
||||
{
|
||||
char date[128];
|
||||
time_t t = time(NULL);
|
||||
struct tm *tm = localtime(&t);
|
||||
|
||||
/* Hour:Minute DayOfTheWeek DayOfTheMonth Month Year */
|
||||
strftime(date, sizeof(date), "%H:%M %A %d %B %Y", tm);
|
||||
|
||||
drw_setscheme(drw, scheme[SchemeSel]);
|
||||
|
||||
int r = drw_text(drw, x, y, w, bh, lrpad / 2, date, 0);
|
||||
return r;
|
||||
}
|
||||
|
||||
static void
|
||||
drawmenu(void)
|
||||
{
|
||||
unsigned int curpos;
|
||||
struct item *item;
|
||||
int x = 0, y = 0, w;
|
||||
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
drw_rect(drw, 0, 0, mw, mh, 1, 1);
|
||||
|
||||
if (prompt && *prompt) {
|
||||
drw_setscheme(drw, scheme[SchemeSel]);
|
||||
x = drw_text(drw, x, 0, promptw, bh, lrpad / 2, prompt, 0);
|
||||
}
|
||||
/* draw input field */
|
||||
w = (lines > 0 || !matches) ? mw - x : inputw;
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0);
|
||||
|
||||
curpos = TEXTW(text) - TEXTW(&text[cursor]);
|
||||
if ((curpos += lrpad / 2 - 1) < w) {
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0);
|
||||
}
|
||||
|
||||
if (lines > 0) {
|
||||
/* draw grid */
|
||||
int i = 0;
|
||||
for (item = curr; item != next; item = item->right, i++)
|
||||
drawitem(
|
||||
item,
|
||||
x + ((i / lines) * ((mw - x) / columns)),
|
||||
y + (((i % lines) + 1) * bh),
|
||||
(mw - x) / columns
|
||||
);
|
||||
} else if (matches) {
|
||||
/* draw horizontal list */
|
||||
x += inputw;
|
||||
w = TEXTW("<");
|
||||
if (curr->left) {
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
drw_text(drw, x, 0, w, bh, lrpad / 2, "<", 0);
|
||||
}
|
||||
x += w;
|
||||
for (item = curr; item != next; item = item->right)
|
||||
x = drawitem(item, x, 0, textw_clamp(item->text, mw - x - TEXTW(">")));
|
||||
|
||||
drawdate(x, lines * bh, w);
|
||||
if (next) {
|
||||
w = TEXTW(">");
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
drw_text(drw, mw - w, 0, w, bh, lrpad / 2, ">", 0);
|
||||
}
|
||||
}
|
||||
drw_map(drw, win, 0, 0, mw, mh);
|
||||
}
|
||||
|
||||
static void
|
||||
grabfocus(void)
|
||||
{
|
||||
struct timespec ts = { .tv_sec = 0, .tv_nsec = 10000000 };
|
||||
Window focuswin;
|
||||
int i, revertwin;
|
||||
|
||||
for (i = 0; i < 100; ++i) {
|
||||
XGetInputFocus(dpy, &focuswin, &revertwin);
|
||||
if (focuswin == win)
|
||||
return;
|
||||
XSetInputFocus(dpy, win, RevertToParent, CurrentTime);
|
||||
nanosleep(&ts, NULL);
|
||||
}
|
||||
die("cannot grab focus");
|
||||
}
|
||||
|
||||
static void
|
||||
grabkeyboard(void)
|
||||
{
|
||||
struct timespec ts = { .tv_sec = 0, .tv_nsec = 1000000 };
|
||||
int i;
|
||||
|
||||
if (embed)
|
||||
return;
|
||||
/* try to grab keyboard, we may have to wait for another process to ungrab */
|
||||
for (i = 0; i < 1000; i++) {
|
||||
if (XGrabKeyboard(dpy, DefaultRootWindow(dpy), True, GrabModeAsync,
|
||||
GrabModeAsync, CurrentTime) == GrabSuccess)
|
||||
return;
|
||||
nanosleep(&ts, NULL);
|
||||
}
|
||||
die("cannot grab keyboard");
|
||||
}
|
||||
|
||||
static void
|
||||
match(void)
|
||||
{
|
||||
static char **tokv = NULL;
|
||||
static int tokn = 0;
|
||||
|
||||
char buf[sizeof text], *s;
|
||||
int i, tokc = 0;
|
||||
size_t len, textsize;
|
||||
struct item *item, *lprefix, *lsubstr, *prefixend, *substrend;
|
||||
|
||||
strcpy(buf, text);
|
||||
/* separate input text into tokens to be matched individually */
|
||||
for (s = strtok(buf, " "); s; tokv[tokc - 1] = s, s = strtok(NULL, " "))
|
||||
if (++tokc > tokn && !(tokv = realloc(tokv, ++tokn * sizeof *tokv)))
|
||||
die("cannot realloc %zu bytes:", tokn * sizeof *tokv);
|
||||
len = tokc ? strlen(tokv[0]) : 0;
|
||||
|
||||
matches = lprefix = lsubstr = matchend = prefixend = substrend = NULL;
|
||||
textsize = strlen(text) + 1;
|
||||
for (item = items; item && item->text; item++) {
|
||||
for (i = 0; i < tokc; i++)
|
||||
if (!fstrstr(item->text, tokv[i]))
|
||||
break;
|
||||
if (i != tokc) /* not all tokens match */
|
||||
continue;
|
||||
/* exact matches go first, then prefixes, then substrings */
|
||||
if (!tokc || !fstrncmp(text, item->text, textsize))
|
||||
appenditem(item, &matches, &matchend);
|
||||
else if (!fstrncmp(tokv[0], item->text, len))
|
||||
appenditem(item, &lprefix, &prefixend);
|
||||
else
|
||||
appenditem(item, &lsubstr, &substrend);
|
||||
}
|
||||
if (lprefix) {
|
||||
if (matches) {
|
||||
matchend->right = lprefix;
|
||||
lprefix->left = matchend;
|
||||
} else
|
||||
matches = lprefix;
|
||||
matchend = prefixend;
|
||||
}
|
||||
if (lsubstr) {
|
||||
if (matches) {
|
||||
matchend->right = lsubstr;
|
||||
lsubstr->left = matchend;
|
||||
} else
|
||||
matches = lsubstr;
|
||||
matchend = substrend;
|
||||
}
|
||||
curr = sel = matches;
|
||||
calcoffsets();
|
||||
}
|
||||
|
||||
static void
|
||||
insert(const char *str, ssize_t n)
|
||||
{
|
||||
if (strlen(text) + n > sizeof text - 1)
|
||||
return;
|
||||
/* move existing text out of the way, insert new text, and update cursor */
|
||||
memmove(&text[cursor + n], &text[cursor], sizeof text - cursor - MAX(n, 0));
|
||||
if (n > 0)
|
||||
memcpy(&text[cursor], str, n);
|
||||
cursor += n;
|
||||
match();
|
||||
}
|
||||
|
||||
static size_t
|
||||
nextrune(int inc)
|
||||
{
|
||||
ssize_t n;
|
||||
|
||||
/* return location of next utf8 rune in the given direction (+1 or -1) */
|
||||
for (n = cursor + inc; n + inc >= 0 && (text[n] & 0xc0) == 0x80; n += inc)
|
||||
;
|
||||
return n;
|
||||
}
|
||||
|
||||
static void
|
||||
movewordedge(int dir)
|
||||
{
|
||||
if (dir < 0) { /* move cursor to the start of the word*/
|
||||
while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)]))
|
||||
cursor = nextrune(-1);
|
||||
while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)]))
|
||||
cursor = nextrune(-1);
|
||||
} else { /* move cursor to the end of the word */
|
||||
while (text[cursor] && strchr(worddelimiters, text[cursor]))
|
||||
cursor = nextrune(+1);
|
||||
while (text[cursor] && !strchr(worddelimiters, text[cursor]))
|
||||
cursor = nextrune(+1);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
keypress(XKeyEvent *ev)
|
||||
{
|
||||
char buf[64];
|
||||
int len;
|
||||
KeySym ksym = NoSymbol;
|
||||
Status status;
|
||||
|
||||
len = XmbLookupString(xic, ev, buf, sizeof buf, &ksym, &status);
|
||||
switch (status) {
|
||||
default: /* XLookupNone, XBufferOverflow */
|
||||
return;
|
||||
case XLookupChars: /* composed string from input method */
|
||||
goto insert;
|
||||
case XLookupKeySym:
|
||||
case XLookupBoth: /* a KeySym and a string are returned: use keysym */
|
||||
break;
|
||||
}
|
||||
|
||||
if (ev->state & ControlMask) {
|
||||
switch(ksym) {
|
||||
case XK_a: ksym = XK_Home; break;
|
||||
case XK_b: ksym = XK_Left; break;
|
||||
case XK_c: ksym = XK_Escape; break;
|
||||
case XK_d: ksym = XK_Delete; break;
|
||||
case XK_e: ksym = XK_End; break;
|
||||
case XK_f: ksym = XK_Right; break;
|
||||
case XK_g: ksym = XK_Escape; break;
|
||||
case XK_h: ksym = XK_BackSpace; break;
|
||||
case XK_i: ksym = XK_Tab; break;
|
||||
case XK_j: /* fallthrough */
|
||||
case XK_J: /* fallthrough */
|
||||
case XK_m: /* fallthrough */
|
||||
case XK_M: ksym = XK_Return; ev->state &= ~ControlMask; break;
|
||||
case XK_n: ksym = XK_Down; break;
|
||||
case XK_p: ksym = XK_Up; break;
|
||||
|
||||
case XK_k: /* delete right */
|
||||
text[cursor] = '\0';
|
||||
match();
|
||||
break;
|
||||
case XK_u: /* delete left */
|
||||
insert(NULL, 0 - cursor);
|
||||
break;
|
||||
case XK_w: /* delete word */
|
||||
while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)]))
|
||||
insert(NULL, nextrune(-1) - cursor);
|
||||
while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)]))
|
||||
insert(NULL, nextrune(-1) - cursor);
|
||||
break;
|
||||
case XK_y: /* paste selection */
|
||||
case XK_Y:
|
||||
XConvertSelection(dpy, (ev->state & ShiftMask) ? clip : XA_PRIMARY,
|
||||
utf8, utf8, win, CurrentTime);
|
||||
return;
|
||||
case XK_Left:
|
||||
case XK_KP_Left:
|
||||
movewordedge(-1);
|
||||
goto draw;
|
||||
case XK_Right:
|
||||
case XK_KP_Right:
|
||||
movewordedge(+1);
|
||||
goto draw;
|
||||
case XK_Return:
|
||||
case XK_KP_Enter:
|
||||
break;
|
||||
case XK_bracketleft:
|
||||
cleanup();
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
} else if (ev->state & Mod1Mask) {
|
||||
switch(ksym) {
|
||||
case XK_b:
|
||||
movewordedge(-1);
|
||||
goto draw;
|
||||
case XK_f:
|
||||
movewordedge(+1);
|
||||
goto draw;
|
||||
case XK_g: ksym = XK_Home; break;
|
||||
case XK_G: ksym = XK_End; break;
|
||||
case XK_h: ksym = XK_Up; break;
|
||||
case XK_j: ksym = XK_Next; break;
|
||||
case XK_k: ksym = XK_Prior; break;
|
||||
case XK_l: ksym = XK_Down; break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch(ksym) {
|
||||
default:
|
||||
insert:
|
||||
if (!iscntrl((unsigned char)*buf))
|
||||
insert(buf, len);
|
||||
break;
|
||||
case XK_Delete:
|
||||
case XK_KP_Delete:
|
||||
if (text[cursor] == '\0')
|
||||
return;
|
||||
cursor = nextrune(+1);
|
||||
/* fallthrough */
|
||||
case XK_BackSpace:
|
||||
if (cursor == 0)
|
||||
return;
|
||||
insert(NULL, nextrune(-1) - cursor);
|
||||
break;
|
||||
case XK_End:
|
||||
case XK_KP_End:
|
||||
if (text[cursor] != '\0') {
|
||||
cursor = strlen(text);
|
||||
break;
|
||||
}
|
||||
if (next) {
|
||||
/* jump to end of list and position items in reverse */
|
||||
curr = matchend;
|
||||
calcoffsets();
|
||||
curr = prev;
|
||||
calcoffsets();
|
||||
while (next && (curr = curr->right))
|
||||
calcoffsets();
|
||||
}
|
||||
sel = matchend;
|
||||
break;
|
||||
case XK_Escape:
|
||||
cleanup();
|
||||
exit(1);
|
||||
case XK_Home:
|
||||
case XK_KP_Home:
|
||||
if (sel == matches) {
|
||||
cursor = 0;
|
||||
break;
|
||||
}
|
||||
sel = curr = matches;
|
||||
calcoffsets();
|
||||
break;
|
||||
case XK_Left:
|
||||
case XK_KP_Left:
|
||||
if (cursor > 0 && (!sel || !sel->left || lines > 0)) {
|
||||
cursor = nextrune(-1);
|
||||
break;
|
||||
}
|
||||
if (lines > 0)
|
||||
return;
|
||||
/* fallthrough */
|
||||
case XK_Up:
|
||||
case XK_KP_Up:
|
||||
if (sel && sel->left && (sel = sel->left)->right == curr) {
|
||||
curr = prev;
|
||||
calcoffsets();
|
||||
}
|
||||
break;
|
||||
case XK_Next:
|
||||
case XK_KP_Next:
|
||||
if (!next)
|
||||
return;
|
||||
sel = curr = next;
|
||||
calcoffsets();
|
||||
break;
|
||||
case XK_Prior:
|
||||
case XK_KP_Prior:
|
||||
if (!prev)
|
||||
return;
|
||||
sel = curr = prev;
|
||||
calcoffsets();
|
||||
break;
|
||||
case XK_Return:
|
||||
case XK_KP_Enter:
|
||||
puts((sel && !(ev->state & ShiftMask)) ? sel->text : text);
|
||||
if (!(ev->state & ControlMask)) {
|
||||
cleanup();
|
||||
exit(0);
|
||||
}
|
||||
if (sel)
|
||||
sel->out = 1;
|
||||
break;
|
||||
case XK_Right:
|
||||
case XK_KP_Right:
|
||||
if (text[cursor] != '\0') {
|
||||
cursor = nextrune(+1);
|
||||
break;
|
||||
}
|
||||
if (lines > 0)
|
||||
return;
|
||||
/* fallthrough */
|
||||
case XK_Down:
|
||||
case XK_KP_Down:
|
||||
if (sel && sel->right && (sel = sel->right) == next) {
|
||||
curr = next;
|
||||
calcoffsets();
|
||||
}
|
||||
break;
|
||||
case XK_Tab:
|
||||
if (!sel)
|
||||
return;
|
||||
cursor = strnlen(sel->text, sizeof text - 1);
|
||||
memcpy(text, sel->text, cursor);
|
||||
text[cursor] = '\0';
|
||||
match();
|
||||
break;
|
||||
}
|
||||
|
||||
draw:
|
||||
drawmenu();
|
||||
}
|
||||
|
||||
static void
|
||||
paste(void)
|
||||
{
|
||||
char *p, *q;
|
||||
int di;
|
||||
unsigned long dl;
|
||||
Atom da;
|
||||
|
||||
/* we have been given the current selection, now insert it into input */
|
||||
if (XGetWindowProperty(dpy, win, utf8, 0, (sizeof text / 4) + 1, False,
|
||||
utf8, &da, &di, &dl, &dl, (unsigned char **)&p)
|
||||
== Success && p) {
|
||||
insert(p, (q = strchr(p, '\n')) ? q - p : (ssize_t)strlen(p));
|
||||
XFree(p);
|
||||
}
|
||||
drawmenu();
|
||||
}
|
||||
|
||||
static void
|
||||
readstdin(void)
|
||||
{
|
||||
char *line = NULL;
|
||||
size_t i, itemsiz = 0, linesiz = 0;
|
||||
ssize_t len;
|
||||
|
||||
/* read each line from stdin and add it to the item list */
|
||||
for (i = 0; (len = getline(&line, &linesiz, stdin)) != -1; i++) {
|
||||
if (i + 1 >= itemsiz) {
|
||||
itemsiz += 256;
|
||||
if (!(items = realloc(items, itemsiz * sizeof(*items))))
|
||||
die("cannot realloc %zu bytes:", itemsiz * sizeof(*items));
|
||||
}
|
||||
if (line[len - 1] == '\n')
|
||||
line[len - 1] = '\0';
|
||||
if (!(items[i].text = strdup(line)))
|
||||
die("strdup:");
|
||||
|
||||
items[i].out = 0;
|
||||
}
|
||||
free(line);
|
||||
if (items)
|
||||
items[i].text = NULL;
|
||||
lines = MIN(lines, i);
|
||||
}
|
||||
|
||||
static void
|
||||
run(void)
|
||||
{
|
||||
XEvent ev;
|
||||
|
||||
while (!XNextEvent(dpy, &ev)) {
|
||||
if (XFilterEvent(&ev, win))
|
||||
continue;
|
||||
switch(ev.type) {
|
||||
case DestroyNotify:
|
||||
if (ev.xdestroywindow.window != win)
|
||||
break;
|
||||
cleanup();
|
||||
exit(1);
|
||||
case Expose:
|
||||
if (ev.xexpose.count == 0)
|
||||
drw_map(drw, win, 0, 0, mw, mh);
|
||||
break;
|
||||
case FocusIn:
|
||||
/* regrab focus from parent window */
|
||||
if (ev.xfocus.window != win)
|
||||
grabfocus();
|
||||
break;
|
||||
case KeyPress:
|
||||
keypress(&ev.xkey);
|
||||
break;
|
||||
case SelectionNotify:
|
||||
if (ev.xselection.property == utf8)
|
||||
paste();
|
||||
break;
|
||||
case VisibilityNotify:
|
||||
if (ev.xvisibility.state != VisibilityUnobscured)
|
||||
XRaiseWindow(dpy, win);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
setup(void)
|
||||
{
|
||||
int x, y, i, j;
|
||||
unsigned int du;
|
||||
XSetWindowAttributes swa;
|
||||
XIM xim;
|
||||
Window w, dw, *dws;
|
||||
XWindowAttributes wa;
|
||||
XClassHint ch = {"dmenu", "dmenu"};
|
||||
#ifdef XINERAMA
|
||||
XineramaScreenInfo *info;
|
||||
Window pw;
|
||||
int a, di, n, area = 0;
|
||||
#endif
|
||||
/* init appearance */
|
||||
for (j = 0; j < SchemeLast; j++)
|
||||
scheme[j] = drw_scm_create(drw, colors[j], 2);
|
||||
|
||||
clip = XInternAtom(dpy, "CLIPBOARD", False);
|
||||
utf8 = XInternAtom(dpy, "UTF8_STRING", False);
|
||||
|
||||
/* calculate menu geometry */
|
||||
bh = drw->fonts->h + 2;
|
||||
lines = MAX(lines, 0);
|
||||
mh = (lines + 1) * bh;
|
||||
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
|
||||
#ifdef XINERAMA
|
||||
i = 0;
|
||||
if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) {
|
||||
XGetInputFocus(dpy, &w, &di);
|
||||
if (mon >= 0 && mon < n)
|
||||
i = mon;
|
||||
else if (w != root && w != PointerRoot && w != None) {
|
||||
/* find top-level window containing current input focus */
|
||||
do {
|
||||
if (XQueryTree(dpy, (pw = w), &dw, &w, &dws, &du) && dws)
|
||||
XFree(dws);
|
||||
} while (w != root && w != pw);
|
||||
/* find xinerama screen with which the window intersects most */
|
||||
if (XGetWindowAttributes(dpy, pw, &wa))
|
||||
for (j = 0; j < n; j++)
|
||||
if ((a = INTERSECT(wa.x, wa.y, wa.width, wa.height, info[j])) > area) {
|
||||
area = a;
|
||||
i = j;
|
||||
}
|
||||
}
|
||||
/* no focused window is on screen, so use pointer location instead */
|
||||
if (mon < 0 && !area && XQueryPointer(dpy, root, &dw, &dw, &x, &y, &di, &di, &du))
|
||||
for (i = 0; i < n; i++)
|
||||
if (INTERSECT(x, y, 1, 1, info[i]) != 0)
|
||||
break;
|
||||
|
||||
mw = MIN(MAX(max_textw() + promptw, 100), info[i].width);
|
||||
x = info[i].x_org + ((info[i].width - mw) / 2);
|
||||
y = info[i].y_org + ((info[i].height - mh) / 2);
|
||||
XFree(info);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if (!XGetWindowAttributes(dpy, parentwin, &wa))
|
||||
die("could not get embedding window attributes: 0x%lx",
|
||||
parentwin);
|
||||
mw = MIN(MAX(max_textw() + promptw, 100), wa.width);
|
||||
x = (wa.width - mw) / 2;
|
||||
y = (wa.height - mh) / 2;
|
||||
}
|
||||
inputw = mw / 3; /* input width: ~33% of monitor width */
|
||||
match();
|
||||
|
||||
/* create menu window */
|
||||
swa.override_redirect = True;
|
||||
swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
|
||||
win = XCreateWindow(dpy, parentwin, x, y, mw, mh, border_width,
|
||||
CopyFromParent, CopyFromParent, CopyFromParent,
|
||||
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
|
||||
if (border_width)
|
||||
XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel);
|
||||
XSetClassHint(dpy, win, &ch);
|
||||
|
||||
|
||||
/* input methods */
|
||||
if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL)
|
||||
die("XOpenIM failed: could not open input device");
|
||||
|
||||
xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
|
||||
XNClientWindow, win, XNFocusWindow, win, NULL);
|
||||
|
||||
XMapRaised(dpy, win);
|
||||
if (embed) {
|
||||
XReparentWindow(dpy, win, parentwin, x, y);
|
||||
XSelectInput(dpy, parentwin, FocusChangeMask | SubstructureNotifyMask);
|
||||
if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) {
|
||||
for (i = 0; i < du && dws[i] != win; ++i)
|
||||
XSelectInput(dpy, dws[i], FocusChangeMask);
|
||||
XFree(dws);
|
||||
}
|
||||
grabfocus();
|
||||
}
|
||||
drw_resize(drw, mw, mh);
|
||||
drawmenu();
|
||||
}
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
die("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
|
||||
" [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]");
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
XWindowAttributes wa;
|
||||
int i, fast = 0;
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
/* these options take no arguments */
|
||||
if (!strcmp(argv[i], "-v")) { /* prints version information */
|
||||
puts("dmenu-"VERSION);
|
||||
exit(0);
|
||||
} else if (!strcmp(argv[i], "-b")) /* appears at the bottom of the screen */
|
||||
topbar = 0;
|
||||
else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
|
||||
fast = 1;
|
||||
else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
|
||||
fstrncmp = strncasecmp;
|
||||
fstrstr = cistrstr;
|
||||
} else if (i + 1 == argc)
|
||||
usage();
|
||||
/* these options take one argument */
|
||||
else if (!strcmp(argv[i], "-g")) { /* number of columns in grid */
|
||||
columns = atoi(argv[++i]);
|
||||
if (lines == 0) lines = 1;
|
||||
} else if (!strcmp(argv[i], "-l")) { /* number of lines in grid */
|
||||
lines = atoi(argv[++i]);
|
||||
if (columns == 0) columns = 1;
|
||||
} else if (!strcmp(argv[i], "-m"))
|
||||
mon = atoi(argv[++i]);
|
||||
else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
|
||||
prompt = argv[++i];
|
||||
else if (!strcmp(argv[i], "-fn")) /* font or font set */
|
||||
fonts[0] = argv[++i];
|
||||
else if (!strcmp(argv[i], "-nb")) /* normal background color */
|
||||
colors[SchemeNorm][ColBg] = argv[++i];
|
||||
else if (!strcmp(argv[i], "-nf")) /* normal foreground color */
|
||||
colors[SchemeNorm][ColFg] = argv[++i];
|
||||
else if (!strcmp(argv[i], "-sb")) /* selected background color */
|
||||
colors[SchemeSel][ColBg] = argv[++i];
|
||||
else if (!strcmp(argv[i], "-sf")) /* selected foreground color */
|
||||
colors[SchemeSel][ColFg] = argv[++i];
|
||||
else if (!strcmp(argv[i], "-w")) /* embedding window id */
|
||||
embed = argv[++i];
|
||||
else if (!strcmp(argv[i], "-bw"))
|
||||
border_width = atoi(argv[++i]); /* border width */
|
||||
else
|
||||
usage();
|
||||
|
||||
if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())
|
||||
fputs("warning: no locale support\n", stderr);
|
||||
if (!(dpy = XOpenDisplay(NULL)))
|
||||
die("cannot open display");
|
||||
screen = DefaultScreen(dpy);
|
||||
root = RootWindow(dpy, screen);
|
||||
if (!embed || !(parentwin = strtol(embed, NULL, 0)))
|
||||
parentwin = root;
|
||||
if (!XGetWindowAttributes(dpy, parentwin, &wa))
|
||||
die("could not get embedding window attributes: 0x%lx",
|
||||
parentwin);
|
||||
drw = drw_create(dpy, screen, root, wa.width, wa.height);
|
||||
if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
|
||||
die("no fonts could be loaded.");
|
||||
lrpad = drw->fonts->h;
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
if (pledge("stdio rpath", NULL) == -1)
|
||||
die("pledge");
|
||||
#endif
|
||||
|
||||
if (fast && !isatty(0)) {
|
||||
grabkeyboard();
|
||||
readstdin();
|
||||
} else {
|
||||
readstdin();
|
||||
grabkeyboard();
|
||||
}
|
||||
setup();
|
||||
run();
|
||||
|
||||
return 1; /* unreachable */
|
||||
}
|
||||
|
||||
820
dmenu/dmenu.c.orig
Normal file
820
dmenu/dmenu.c.orig
Normal file
@@ -0,0 +1,820 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#include <ctype.h>
|
||||
#include <locale.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xutil.h>
|
||||
#ifdef XINERAMA
|
||||
#include <X11/extensions/Xinerama.h>
|
||||
#endif
|
||||
#include <X11/Xft/Xft.h>
|
||||
|
||||
#include "drw.h"
|
||||
#include "util.h"
|
||||
|
||||
/* macros */
|
||||
#define INTERSECT(x,y,w,h,r) (MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \
|
||||
* MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org)))
|
||||
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||
|
||||
/* enums */
|
||||
enum { SchemeNorm, SchemeSel, SchemeOut, SchemeBorder, SchemeLast }; /* color schemes */
|
||||
|
||||
struct item {
|
||||
char *text;
|
||||
struct item *left, *right;
|
||||
int out;
|
||||
};
|
||||
|
||||
static char text[BUFSIZ] = "";
|
||||
static char *embed;
|
||||
static int bh, mw, mh;
|
||||
static int inputw = 0, promptw;
|
||||
static int lrpad; /* sum of left and right padding */
|
||||
static size_t cursor;
|
||||
static struct item *items = NULL;
|
||||
static struct item *matches, *matchend;
|
||||
static struct item *prev, *curr, *next, *sel;
|
||||
static int mon = -1, screen;
|
||||
|
||||
static Atom clip, utf8;
|
||||
static Display *dpy;
|
||||
static Window root, parentwin, win;
|
||||
static XIC xic;
|
||||
|
||||
static Drw *drw;
|
||||
static Clr *scheme[SchemeLast];
|
||||
|
||||
#include "config.h"
|
||||
|
||||
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
|
||||
static char *(*fstrstr)(const char *, const char *) = strstr;
|
||||
|
||||
static unsigned int
|
||||
textw_clamp(const char *str, unsigned int n)
|
||||
{
|
||||
unsigned int w = drw_fontset_getwidth_clamp(drw, str, n) + lrpad;
|
||||
return MIN(w, n);
|
||||
}
|
||||
|
||||
static void
|
||||
appenditem(struct item *item, struct item **list, struct item **last)
|
||||
{
|
||||
if (*last)
|
||||
(*last)->right = item;
|
||||
else
|
||||
*list = item;
|
||||
|
||||
item->left = *last;
|
||||
item->right = NULL;
|
||||
*last = item;
|
||||
}
|
||||
|
||||
static void
|
||||
calcoffsets(void)
|
||||
{
|
||||
int i, n;
|
||||
|
||||
if (lines > 0)
|
||||
n = lines * columns * bh;
|
||||
else
|
||||
n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">"));
|
||||
/* calculate which items will begin the next page and previous page */
|
||||
for (i = 0, next = curr; next; next = next->right)
|
||||
if ((i += (lines > 0) ? bh : textw_clamp(next->text, n)) > n)
|
||||
break;
|
||||
for (i = 0, prev = curr; prev && prev->left; prev = prev->left)
|
||||
if ((i += (lines > 0) ? bh : textw_clamp(prev->left->text, n)) > n)
|
||||
break;
|
||||
}
|
||||
|
||||
static int
|
||||
max_textw(void)
|
||||
{
|
||||
int len = 0;
|
||||
for (struct item *item = items; item && item->text; item++)
|
||||
len = MAX(TEXTW(item->text), len);
|
||||
return len;
|
||||
}
|
||||
|
||||
static void
|
||||
cleanup(void)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
XUngrabKey(dpy, AnyKey, AnyModifier, root);
|
||||
for (i = 0; i < SchemeLast; i++)
|
||||
free(scheme[i]);
|
||||
for (i = 0; items && items[i].text; ++i)
|
||||
free(items[i].text);
|
||||
free(items);
|
||||
drw_free(drw);
|
||||
XSync(dpy, False);
|
||||
XCloseDisplay(dpy);
|
||||
}
|
||||
|
||||
static char *
|
||||
cistrstr(const char *h, const char *n)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (!n[0])
|
||||
return (char *)h;
|
||||
|
||||
for (; *h; ++h) {
|
||||
for (i = 0; n[i] && tolower((unsigned char)n[i]) ==
|
||||
tolower((unsigned char)h[i]); ++i)
|
||||
;
|
||||
if (n[i] == '\0')
|
||||
return (char *)h;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
drawitem(struct item *item, int x, int y, int w)
|
||||
{
|
||||
if (item == sel)
|
||||
drw_setscheme(drw, scheme[SchemeSel]);
|
||||
else if (item->out)
|
||||
drw_setscheme(drw, scheme[SchemeOut]);
|
||||
else
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
|
||||
return drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
drawmenu(void)
|
||||
{
|
||||
unsigned int curpos;
|
||||
struct item *item;
|
||||
int x = 0, y = 0, w;
|
||||
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
drw_rect(drw, 0, 0, mw, mh, 1, 1);
|
||||
|
||||
if (prompt && *prompt) {
|
||||
drw_setscheme(drw, scheme[SchemeSel]);
|
||||
x = drw_text(drw, x, 0, promptw, bh, lrpad / 2, prompt, 0);
|
||||
}
|
||||
/* draw input field */
|
||||
w = (lines > 0 || !matches) ? mw - x : inputw;
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0);
|
||||
|
||||
curpos = TEXTW(text) - TEXTW(&text[cursor]);
|
||||
if ((curpos += lrpad / 2 - 1) < w) {
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0);
|
||||
}
|
||||
|
||||
if (lines > 0) {
|
||||
/* draw grid */
|
||||
int i = 0;
|
||||
for (item = curr; item != next; item = item->right, i++)
|
||||
drawitem(
|
||||
item,
|
||||
x + ((i / lines) * ((mw - x) / columns)),
|
||||
y + (((i % lines) + 1) * bh),
|
||||
(mw - x) / columns
|
||||
);
|
||||
} else if (matches) {
|
||||
/* draw horizontal list */
|
||||
x += inputw;
|
||||
w = TEXTW("<");
|
||||
if (curr->left) {
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
drw_text(drw, x, 0, w, bh, lrpad / 2, "<", 0);
|
||||
}
|
||||
x += w;
|
||||
for (item = curr; item != next; item = item->right)
|
||||
x = drawitem(item, x, 0, textw_clamp(item->text, mw - x - TEXTW(">")));
|
||||
if (next) {
|
||||
w = TEXTW(">");
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
drw_text(drw, mw - w, 0, w, bh, lrpad / 2, ">", 0);
|
||||
}
|
||||
}
|
||||
drw_map(drw, win, 0, 0, mw, mh);
|
||||
}
|
||||
|
||||
static void
|
||||
grabfocus(void)
|
||||
{
|
||||
struct timespec ts = { .tv_sec = 0, .tv_nsec = 10000000 };
|
||||
Window focuswin;
|
||||
int i, revertwin;
|
||||
|
||||
for (i = 0; i < 100; ++i) {
|
||||
XGetInputFocus(dpy, &focuswin, &revertwin);
|
||||
if (focuswin == win)
|
||||
return;
|
||||
XSetInputFocus(dpy, win, RevertToParent, CurrentTime);
|
||||
nanosleep(&ts, NULL);
|
||||
}
|
||||
die("cannot grab focus");
|
||||
}
|
||||
|
||||
static void
|
||||
grabkeyboard(void)
|
||||
{
|
||||
struct timespec ts = { .tv_sec = 0, .tv_nsec = 1000000 };
|
||||
int i;
|
||||
|
||||
if (embed)
|
||||
return;
|
||||
/* try to grab keyboard, we may have to wait for another process to ungrab */
|
||||
for (i = 0; i < 1000; i++) {
|
||||
if (XGrabKeyboard(dpy, DefaultRootWindow(dpy), True, GrabModeAsync,
|
||||
GrabModeAsync, CurrentTime) == GrabSuccess)
|
||||
return;
|
||||
nanosleep(&ts, NULL);
|
||||
}
|
||||
die("cannot grab keyboard");
|
||||
}
|
||||
|
||||
static void
|
||||
match(void)
|
||||
{
|
||||
static char **tokv = NULL;
|
||||
static int tokn = 0;
|
||||
|
||||
char buf[sizeof text], *s;
|
||||
int i, tokc = 0;
|
||||
size_t len, textsize;
|
||||
struct item *item, *lprefix, *lsubstr, *prefixend, *substrend;
|
||||
|
||||
strcpy(buf, text);
|
||||
/* separate input text into tokens to be matched individually */
|
||||
for (s = strtok(buf, " "); s; tokv[tokc - 1] = s, s = strtok(NULL, " "))
|
||||
if (++tokc > tokn && !(tokv = realloc(tokv, ++tokn * sizeof *tokv)))
|
||||
die("cannot realloc %zu bytes:", tokn * sizeof *tokv);
|
||||
len = tokc ? strlen(tokv[0]) : 0;
|
||||
|
||||
matches = lprefix = lsubstr = matchend = prefixend = substrend = NULL;
|
||||
textsize = strlen(text) + 1;
|
||||
for (item = items; item && item->text; item++) {
|
||||
for (i = 0; i < tokc; i++)
|
||||
if (!fstrstr(item->text, tokv[i]))
|
||||
break;
|
||||
if (i != tokc) /* not all tokens match */
|
||||
continue;
|
||||
/* exact matches go first, then prefixes, then substrings */
|
||||
if (!tokc || !fstrncmp(text, item->text, textsize))
|
||||
appenditem(item, &matches, &matchend);
|
||||
else if (!fstrncmp(tokv[0], item->text, len))
|
||||
appenditem(item, &lprefix, &prefixend);
|
||||
else
|
||||
appenditem(item, &lsubstr, &substrend);
|
||||
}
|
||||
if (lprefix) {
|
||||
if (matches) {
|
||||
matchend->right = lprefix;
|
||||
lprefix->left = matchend;
|
||||
} else
|
||||
matches = lprefix;
|
||||
matchend = prefixend;
|
||||
}
|
||||
if (lsubstr) {
|
||||
if (matches) {
|
||||
matchend->right = lsubstr;
|
||||
lsubstr->left = matchend;
|
||||
} else
|
||||
matches = lsubstr;
|
||||
matchend = substrend;
|
||||
}
|
||||
curr = sel = matches;
|
||||
calcoffsets();
|
||||
}
|
||||
|
||||
static void
|
||||
insert(const char *str, ssize_t n)
|
||||
{
|
||||
if (strlen(text) + n > sizeof text - 1)
|
||||
return;
|
||||
/* move existing text out of the way, insert new text, and update cursor */
|
||||
memmove(&text[cursor + n], &text[cursor], sizeof text - cursor - MAX(n, 0));
|
||||
if (n > 0)
|
||||
memcpy(&text[cursor], str, n);
|
||||
cursor += n;
|
||||
match();
|
||||
}
|
||||
|
||||
static size_t
|
||||
nextrune(int inc)
|
||||
{
|
||||
ssize_t n;
|
||||
|
||||
/* return location of next utf8 rune in the given direction (+1 or -1) */
|
||||
for (n = cursor + inc; n + inc >= 0 && (text[n] & 0xc0) == 0x80; n += inc)
|
||||
;
|
||||
return n;
|
||||
}
|
||||
|
||||
static void
|
||||
movewordedge(int dir)
|
||||
{
|
||||
if (dir < 0) { /* move cursor to the start of the word*/
|
||||
while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)]))
|
||||
cursor = nextrune(-1);
|
||||
while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)]))
|
||||
cursor = nextrune(-1);
|
||||
} else { /* move cursor to the end of the word */
|
||||
while (text[cursor] && strchr(worddelimiters, text[cursor]))
|
||||
cursor = nextrune(+1);
|
||||
while (text[cursor] && !strchr(worddelimiters, text[cursor]))
|
||||
cursor = nextrune(+1);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
keypress(XKeyEvent *ev)
|
||||
{
|
||||
char buf[64];
|
||||
int len;
|
||||
KeySym ksym = NoSymbol;
|
||||
Status status;
|
||||
|
||||
len = XmbLookupString(xic, ev, buf, sizeof buf, &ksym, &status);
|
||||
switch (status) {
|
||||
default: /* XLookupNone, XBufferOverflow */
|
||||
return;
|
||||
case XLookupChars: /* composed string from input method */
|
||||
goto insert;
|
||||
case XLookupKeySym:
|
||||
case XLookupBoth: /* a KeySym and a string are returned: use keysym */
|
||||
break;
|
||||
}
|
||||
|
||||
if (ev->state & ControlMask) {
|
||||
switch(ksym) {
|
||||
case XK_a: ksym = XK_Home; break;
|
||||
case XK_b: ksym = XK_Left; break;
|
||||
case XK_c: ksym = XK_Escape; break;
|
||||
case XK_d: ksym = XK_Delete; break;
|
||||
case XK_e: ksym = XK_End; break;
|
||||
case XK_f: ksym = XK_Right; break;
|
||||
case XK_g: ksym = XK_Escape; break;
|
||||
case XK_h: ksym = XK_BackSpace; break;
|
||||
case XK_i: ksym = XK_Tab; break;
|
||||
case XK_j: /* fallthrough */
|
||||
case XK_J: /* fallthrough */
|
||||
case XK_m: /* fallthrough */
|
||||
case XK_M: ksym = XK_Return; ev->state &= ~ControlMask; break;
|
||||
case XK_n: ksym = XK_Down; break;
|
||||
case XK_p: ksym = XK_Up; break;
|
||||
|
||||
case XK_k: /* delete right */
|
||||
text[cursor] = '\0';
|
||||
match();
|
||||
break;
|
||||
case XK_u: /* delete left */
|
||||
insert(NULL, 0 - cursor);
|
||||
break;
|
||||
case XK_w: /* delete word */
|
||||
while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)]))
|
||||
insert(NULL, nextrune(-1) - cursor);
|
||||
while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)]))
|
||||
insert(NULL, nextrune(-1) - cursor);
|
||||
break;
|
||||
case XK_y: /* paste selection */
|
||||
case XK_Y:
|
||||
XConvertSelection(dpy, (ev->state & ShiftMask) ? clip : XA_PRIMARY,
|
||||
utf8, utf8, win, CurrentTime);
|
||||
return;
|
||||
case XK_Left:
|
||||
case XK_KP_Left:
|
||||
movewordedge(-1);
|
||||
goto draw;
|
||||
case XK_Right:
|
||||
case XK_KP_Right:
|
||||
movewordedge(+1);
|
||||
goto draw;
|
||||
case XK_Return:
|
||||
case XK_KP_Enter:
|
||||
break;
|
||||
case XK_bracketleft:
|
||||
cleanup();
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
} else if (ev->state & Mod1Mask) {
|
||||
switch(ksym) {
|
||||
case XK_b:
|
||||
movewordedge(-1);
|
||||
goto draw;
|
||||
case XK_f:
|
||||
movewordedge(+1);
|
||||
goto draw;
|
||||
case XK_g: ksym = XK_Home; break;
|
||||
case XK_G: ksym = XK_End; break;
|
||||
case XK_h: ksym = XK_Up; break;
|
||||
case XK_j: ksym = XK_Next; break;
|
||||
case XK_k: ksym = XK_Prior; break;
|
||||
case XK_l: ksym = XK_Down; break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch(ksym) {
|
||||
default:
|
||||
insert:
|
||||
if (!iscntrl((unsigned char)*buf))
|
||||
insert(buf, len);
|
||||
break;
|
||||
case XK_Delete:
|
||||
case XK_KP_Delete:
|
||||
if (text[cursor] == '\0')
|
||||
return;
|
||||
cursor = nextrune(+1);
|
||||
/* fallthrough */
|
||||
case XK_BackSpace:
|
||||
if (cursor == 0)
|
||||
return;
|
||||
insert(NULL, nextrune(-1) - cursor);
|
||||
break;
|
||||
case XK_End:
|
||||
case XK_KP_End:
|
||||
if (text[cursor] != '\0') {
|
||||
cursor = strlen(text);
|
||||
break;
|
||||
}
|
||||
if (next) {
|
||||
/* jump to end of list and position items in reverse */
|
||||
curr = matchend;
|
||||
calcoffsets();
|
||||
curr = prev;
|
||||
calcoffsets();
|
||||
while (next && (curr = curr->right))
|
||||
calcoffsets();
|
||||
}
|
||||
sel = matchend;
|
||||
break;
|
||||
case XK_Escape:
|
||||
cleanup();
|
||||
exit(1);
|
||||
case XK_Home:
|
||||
case XK_KP_Home:
|
||||
if (sel == matches) {
|
||||
cursor = 0;
|
||||
break;
|
||||
}
|
||||
sel = curr = matches;
|
||||
calcoffsets();
|
||||
break;
|
||||
case XK_Left:
|
||||
case XK_KP_Left:
|
||||
if (cursor > 0 && (!sel || !sel->left || lines > 0)) {
|
||||
cursor = nextrune(-1);
|
||||
break;
|
||||
}
|
||||
if (lines > 0)
|
||||
return;
|
||||
/* fallthrough */
|
||||
case XK_Up:
|
||||
case XK_KP_Up:
|
||||
if (sel && sel->left && (sel = sel->left)->right == curr) {
|
||||
curr = prev;
|
||||
calcoffsets();
|
||||
}
|
||||
break;
|
||||
case XK_Next:
|
||||
case XK_KP_Next:
|
||||
if (!next)
|
||||
return;
|
||||
sel = curr = next;
|
||||
calcoffsets();
|
||||
break;
|
||||
case XK_Prior:
|
||||
case XK_KP_Prior:
|
||||
if (!prev)
|
||||
return;
|
||||
sel = curr = prev;
|
||||
calcoffsets();
|
||||
break;
|
||||
case XK_Return:
|
||||
case XK_KP_Enter:
|
||||
puts((sel && !(ev->state & ShiftMask)) ? sel->text : text);
|
||||
if (!(ev->state & ControlMask)) {
|
||||
cleanup();
|
||||
exit(0);
|
||||
}
|
||||
if (sel)
|
||||
sel->out = 1;
|
||||
break;
|
||||
case XK_Right:
|
||||
case XK_KP_Right:
|
||||
if (text[cursor] != '\0') {
|
||||
cursor = nextrune(+1);
|
||||
break;
|
||||
}
|
||||
if (lines > 0)
|
||||
return;
|
||||
/* fallthrough */
|
||||
case XK_Down:
|
||||
case XK_KP_Down:
|
||||
if (sel && sel->right && (sel = sel->right) == next) {
|
||||
curr = next;
|
||||
calcoffsets();
|
||||
}
|
||||
break;
|
||||
case XK_Tab:
|
||||
if (!sel)
|
||||
return;
|
||||
cursor = strnlen(sel->text, sizeof text - 1);
|
||||
memcpy(text, sel->text, cursor);
|
||||
text[cursor] = '\0';
|
||||
match();
|
||||
break;
|
||||
}
|
||||
|
||||
draw:
|
||||
drawmenu();
|
||||
}
|
||||
|
||||
static void
|
||||
paste(void)
|
||||
{
|
||||
char *p, *q;
|
||||
int di;
|
||||
unsigned long dl;
|
||||
Atom da;
|
||||
|
||||
/* we have been given the current selection, now insert it into input */
|
||||
if (XGetWindowProperty(dpy, win, utf8, 0, (sizeof text / 4) + 1, False,
|
||||
utf8, &da, &di, &dl, &dl, (unsigned char **)&p)
|
||||
== Success && p) {
|
||||
insert(p, (q = strchr(p, '\n')) ? q - p : (ssize_t)strlen(p));
|
||||
XFree(p);
|
||||
}
|
||||
drawmenu();
|
||||
}
|
||||
|
||||
static void
|
||||
readstdin(void)
|
||||
{
|
||||
char *line = NULL;
|
||||
size_t i, itemsiz = 0, linesiz = 0;
|
||||
ssize_t len;
|
||||
|
||||
/* read each line from stdin and add it to the item list */
|
||||
for (i = 0; (len = getline(&line, &linesiz, stdin)) != -1; i++) {
|
||||
if (i + 1 >= itemsiz) {
|
||||
itemsiz += 256;
|
||||
if (!(items = realloc(items, itemsiz * sizeof(*items))))
|
||||
die("cannot realloc %zu bytes:", itemsiz * sizeof(*items));
|
||||
}
|
||||
if (line[len - 1] == '\n')
|
||||
line[len - 1] = '\0';
|
||||
if (!(items[i].text = strdup(line)))
|
||||
die("strdup:");
|
||||
|
||||
items[i].out = 0;
|
||||
}
|
||||
free(line);
|
||||
if (items)
|
||||
items[i].text = NULL;
|
||||
lines = MIN(lines, i);
|
||||
}
|
||||
|
||||
static void
|
||||
run(void)
|
||||
{
|
||||
XEvent ev;
|
||||
|
||||
while (!XNextEvent(dpy, &ev)) {
|
||||
if (XFilterEvent(&ev, win))
|
||||
continue;
|
||||
switch(ev.type) {
|
||||
case DestroyNotify:
|
||||
if (ev.xdestroywindow.window != win)
|
||||
break;
|
||||
cleanup();
|
||||
exit(1);
|
||||
case Expose:
|
||||
if (ev.xexpose.count == 0)
|
||||
drw_map(drw, win, 0, 0, mw, mh);
|
||||
break;
|
||||
case FocusIn:
|
||||
/* regrab focus from parent window */
|
||||
if (ev.xfocus.window != win)
|
||||
grabfocus();
|
||||
break;
|
||||
case KeyPress:
|
||||
keypress(&ev.xkey);
|
||||
break;
|
||||
case SelectionNotify:
|
||||
if (ev.xselection.property == utf8)
|
||||
paste();
|
||||
break;
|
||||
case VisibilityNotify:
|
||||
if (ev.xvisibility.state != VisibilityUnobscured)
|
||||
XRaiseWindow(dpy, win);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
setup(void)
|
||||
{
|
||||
int x, y, i, j;
|
||||
unsigned int du;
|
||||
XSetWindowAttributes swa;
|
||||
XIM xim;
|
||||
Window w, dw, *dws;
|
||||
XWindowAttributes wa;
|
||||
XClassHint ch = {"dmenu", "dmenu"};
|
||||
#ifdef XINERAMA
|
||||
XineramaScreenInfo *info;
|
||||
Window pw;
|
||||
int a, di, n, area = 0;
|
||||
#endif
|
||||
/* init appearance */
|
||||
for (j = 0; j < SchemeLast; j++)
|
||||
scheme[j] = drw_scm_create(drw, colors[j], 2);
|
||||
|
||||
clip = XInternAtom(dpy, "CLIPBOARD", False);
|
||||
utf8 = XInternAtom(dpy, "UTF8_STRING", False);
|
||||
|
||||
/* calculate menu geometry */
|
||||
bh = drw->fonts->h + 2;
|
||||
lines = MAX(lines, 0);
|
||||
mh = (lines + 1) * bh;
|
||||
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
|
||||
#ifdef XINERAMA
|
||||
i = 0;
|
||||
if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) {
|
||||
XGetInputFocus(dpy, &w, &di);
|
||||
if (mon >= 0 && mon < n)
|
||||
i = mon;
|
||||
else if (w != root && w != PointerRoot && w != None) {
|
||||
/* find top-level window containing current input focus */
|
||||
do {
|
||||
if (XQueryTree(dpy, (pw = w), &dw, &w, &dws, &du) && dws)
|
||||
XFree(dws);
|
||||
} while (w != root && w != pw);
|
||||
/* find xinerama screen with which the window intersects most */
|
||||
if (XGetWindowAttributes(dpy, pw, &wa))
|
||||
for (j = 0; j < n; j++)
|
||||
if ((a = INTERSECT(wa.x, wa.y, wa.width, wa.height, info[j])) > area) {
|
||||
area = a;
|
||||
i = j;
|
||||
}
|
||||
}
|
||||
/* no focused window is on screen, so use pointer location instead */
|
||||
if (mon < 0 && !area && XQueryPointer(dpy, root, &dw, &dw, &x, &y, &di, &di, &du))
|
||||
for (i = 0; i < n; i++)
|
||||
if (INTERSECT(x, y, 1, 1, info[i]) != 0)
|
||||
break;
|
||||
|
||||
mw = MIN(MAX(max_textw() + promptw, 100), info[i].width);
|
||||
x = info[i].x_org + ((info[i].width - mw) / 2);
|
||||
y = info[i].y_org + ((info[i].height - mh) / 2);
|
||||
XFree(info);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if (!XGetWindowAttributes(dpy, parentwin, &wa))
|
||||
die("could not get embedding window attributes: 0x%lx",
|
||||
parentwin);
|
||||
mw = MIN(MAX(max_textw() + promptw, 100), wa.width);
|
||||
x = (wa.width - mw) / 2;
|
||||
y = (wa.height - mh) / 2;
|
||||
}
|
||||
inputw = mw / 3; /* input width: ~33% of monitor width */
|
||||
match();
|
||||
|
||||
/* create menu window */
|
||||
swa.override_redirect = True;
|
||||
swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
|
||||
win = XCreateWindow(dpy, parentwin, x, y, mw, mh, border_width,
|
||||
CopyFromParent, CopyFromParent, CopyFromParent,
|
||||
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
|
||||
if (border_width)
|
||||
XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel);
|
||||
XSetClassHint(dpy, win, &ch);
|
||||
|
||||
|
||||
/* input methods */
|
||||
if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL)
|
||||
die("XOpenIM failed: could not open input device");
|
||||
|
||||
xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
|
||||
XNClientWindow, win, XNFocusWindow, win, NULL);
|
||||
|
||||
XMapRaised(dpy, win);
|
||||
if (embed) {
|
||||
XReparentWindow(dpy, win, parentwin, x, y);
|
||||
XSelectInput(dpy, parentwin, FocusChangeMask | SubstructureNotifyMask);
|
||||
if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) {
|
||||
for (i = 0; i < du && dws[i] != win; ++i)
|
||||
XSelectInput(dpy, dws[i], FocusChangeMask);
|
||||
XFree(dws);
|
||||
}
|
||||
grabfocus();
|
||||
}
|
||||
drw_resize(drw, mw, mh);
|
||||
drawmenu();
|
||||
}
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
die("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
|
||||
" [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]");
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
XWindowAttributes wa;
|
||||
int i, fast = 0;
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
/* these options take no arguments */
|
||||
if (!strcmp(argv[i], "-v")) { /* prints version information */
|
||||
puts("dmenu-"VERSION);
|
||||
exit(0);
|
||||
} else if (!strcmp(argv[i], "-b")) /* appears at the bottom of the screen */
|
||||
topbar = 0;
|
||||
else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
|
||||
fast = 1;
|
||||
else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
|
||||
fstrncmp = strncasecmp;
|
||||
fstrstr = cistrstr;
|
||||
} else if (i + 1 == argc)
|
||||
usage();
|
||||
/* these options take one argument */
|
||||
else if (!strcmp(argv[i], "-g")) { /* number of columns in grid */
|
||||
columns = atoi(argv[++i]);
|
||||
if (lines == 0) lines = 1;
|
||||
} else if (!strcmp(argv[i], "-l")) { /* number of lines in grid */
|
||||
lines = atoi(argv[++i]);
|
||||
if (columns == 0) columns = 1;
|
||||
} else if (!strcmp(argv[i], "-m"))
|
||||
mon = atoi(argv[++i]);
|
||||
else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
|
||||
prompt = argv[++i];
|
||||
else if (!strcmp(argv[i], "-fn")) /* font or font set */
|
||||
fonts[0] = argv[++i];
|
||||
else if (!strcmp(argv[i], "-nb")) /* normal background color */
|
||||
colors[SchemeNorm][ColBg] = argv[++i];
|
||||
else if (!strcmp(argv[i], "-nf")) /* normal foreground color */
|
||||
colors[SchemeNorm][ColFg] = argv[++i];
|
||||
else if (!strcmp(argv[i], "-sb")) /* selected background color */
|
||||
colors[SchemeSel][ColBg] = argv[++i];
|
||||
else if (!strcmp(argv[i], "-sf")) /* selected foreground color */
|
||||
colors[SchemeSel][ColFg] = argv[++i];
|
||||
else if (!strcmp(argv[i], "-w")) /* embedding window id */
|
||||
embed = argv[++i];
|
||||
else if (!strcmp(argv[i], "-bw"))
|
||||
border_width = atoi(argv[++i]); /* border width */
|
||||
else
|
||||
usage();
|
||||
|
||||
if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())
|
||||
fputs("warning: no locale support\n", stderr);
|
||||
if (!(dpy = XOpenDisplay(NULL)))
|
||||
die("cannot open display");
|
||||
screen = DefaultScreen(dpy);
|
||||
root = RootWindow(dpy, screen);
|
||||
if (!embed || !(parentwin = strtol(embed, NULL, 0)))
|
||||
parentwin = root;
|
||||
if (!XGetWindowAttributes(dpy, parentwin, &wa))
|
||||
die("could not get embedding window attributes: 0x%lx",
|
||||
parentwin);
|
||||
drw = drw_create(dpy, screen, root, wa.width, wa.height);
|
||||
if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
|
||||
die("no fonts could be loaded.");
|
||||
lrpad = drw->fonts->h;
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
if (pledge("stdio rpath", NULL) == -1)
|
||||
die("pledge");
|
||||
#endif
|
||||
|
||||
if (fast && !isatty(0)) {
|
||||
grabkeyboard();
|
||||
readstdin();
|
||||
} else {
|
||||
readstdin();
|
||||
grabkeyboard();
|
||||
}
|
||||
setup();
|
||||
run();
|
||||
|
||||
return 1; /* unreachable */
|
||||
}
|
||||
|
||||
20
dmenu/dmenu.c.rej
Normal file
20
dmenu/dmenu.c.rej
Normal file
@@ -0,0 +1,20 @@
|
||||
--- dmenu.c
|
||||
+++ dmenu.c
|
||||
@@ -84,7 +84,7 @@ calcoffsets(void)
|
||||
int i, n;
|
||||
|
||||
if (lines > 0)
|
||||
- n = lines * bh;
|
||||
+ n = (lines * bh) - 1;
|
||||
else
|
||||
n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">"));
|
||||
/* calculate which items will begin the next page and previous page */
|
||||
@@ -188,6 +204,8 @@ drawmenu(void)
|
||||
/* draw vertical list */
|
||||
for (item = curr; item != next; item = item->right)
|
||||
drawitem(item, x, y += bh, mw - x);
|
||||
+
|
||||
+ drawdate(x, lines * bh, w);
|
||||
} else if (matches) {
|
||||
/* draw horizontal list */
|
||||
x += inputw;
|
||||
BIN
dmenu/dmenu.o
Normal file
BIN
dmenu/dmenu.o
Normal file
Binary file not shown.
13
dmenu/dmenu_path
Executable file
13
dmenu/dmenu_path
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
cachedir="${XDG_CACHE_HOME:-"$HOME/.cache"}"
|
||||
cache="$cachedir/dmenu_run"
|
||||
|
||||
[ ! -e "$cachedir" ] && mkdir -p "$cachedir"
|
||||
|
||||
IFS=:
|
||||
if stest -dqr -n "$cache" $PATH; then
|
||||
stest -flx $PATH | sort -u | tee "$cache"
|
||||
else
|
||||
cat "$cache"
|
||||
fi
|
||||
2
dmenu/dmenu_run
Executable file
2
dmenu/dmenu_run
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
dmenu_path | dmenu "$@" | ${SHELL:-"/bin/sh"} &
|
||||
451
dmenu/drw.c
Normal file
451
dmenu/drw.c
Normal file
@@ -0,0 +1,451 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xft/Xft.h>
|
||||
|
||||
#include "drw.h"
|
||||
#include "util.h"
|
||||
|
||||
#define UTF_INVALID 0xFFFD
|
||||
#define UTF_SIZ 4
|
||||
|
||||
static const unsigned char utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
|
||||
static const unsigned char utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
|
||||
static const long utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
|
||||
static const long utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
|
||||
|
||||
static long
|
||||
utf8decodebyte(const char c, size_t *i)
|
||||
{
|
||||
for (*i = 0; *i < (UTF_SIZ + 1); ++(*i))
|
||||
if (((unsigned char)c & utfmask[*i]) == utfbyte[*i])
|
||||
return (unsigned char)c & ~utfmask[*i];
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t
|
||||
utf8validate(long *u, size_t i)
|
||||
{
|
||||
if (!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF))
|
||||
*u = UTF_INVALID;
|
||||
for (i = 1; *u > utfmax[i]; ++i)
|
||||
;
|
||||
return i;
|
||||
}
|
||||
|
||||
static size_t
|
||||
utf8decode(const char *c, long *u, size_t clen)
|
||||
{
|
||||
size_t i, j, len, type;
|
||||
long udecoded;
|
||||
|
||||
*u = UTF_INVALID;
|
||||
if (!clen)
|
||||
return 0;
|
||||
udecoded = utf8decodebyte(c[0], &len);
|
||||
if (!BETWEEN(len, 1, UTF_SIZ))
|
||||
return 1;
|
||||
for (i = 1, j = 1; i < clen && j < len; ++i, ++j) {
|
||||
udecoded = (udecoded << 6) | utf8decodebyte(c[i], &type);
|
||||
if (type)
|
||||
return j;
|
||||
}
|
||||
if (j < len)
|
||||
return 0;
|
||||
*u = udecoded;
|
||||
utf8validate(u, len);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
Drw *
|
||||
drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h)
|
||||
{
|
||||
Drw *drw = ecalloc(1, sizeof(Drw));
|
||||
|
||||
drw->dpy = dpy;
|
||||
drw->screen = screen;
|
||||
drw->root = root;
|
||||
drw->w = w;
|
||||
drw->h = h;
|
||||
drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen));
|
||||
drw->gc = XCreateGC(dpy, root, 0, NULL);
|
||||
XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter);
|
||||
|
||||
return drw;
|
||||
}
|
||||
|
||||
void
|
||||
drw_resize(Drw *drw, unsigned int w, unsigned int h)
|
||||
{
|
||||
if (!drw)
|
||||
return;
|
||||
|
||||
drw->w = w;
|
||||
drw->h = h;
|
||||
if (drw->drawable)
|
||||
XFreePixmap(drw->dpy, drw->drawable);
|
||||
drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen));
|
||||
}
|
||||
|
||||
void
|
||||
drw_free(Drw *drw)
|
||||
{
|
||||
XFreePixmap(drw->dpy, drw->drawable);
|
||||
XFreeGC(drw->dpy, drw->gc);
|
||||
drw_fontset_free(drw->fonts);
|
||||
free(drw);
|
||||
}
|
||||
|
||||
/* This function is an implementation detail. Library users should use
|
||||
* drw_fontset_create instead.
|
||||
*/
|
||||
static Fnt *
|
||||
xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
|
||||
{
|
||||
Fnt *font;
|
||||
XftFont *xfont = NULL;
|
||||
FcPattern *pattern = NULL;
|
||||
|
||||
if (fontname) {
|
||||
/* Using the pattern found at font->xfont->pattern does not yield the
|
||||
* same substitution results as using the pattern returned by
|
||||
* FcNameParse; using the latter results in the desired fallback
|
||||
* behaviour whereas the former just results in missing-character
|
||||
* rectangles being drawn, at least with some fonts. */
|
||||
if (!(xfont = XftFontOpenName(drw->dpy, drw->screen, fontname))) {
|
||||
fprintf(stderr, "error, cannot load font from name: '%s'\n", fontname);
|
||||
return NULL;
|
||||
}
|
||||
if (!(pattern = FcNameParse((FcChar8 *) fontname))) {
|
||||
fprintf(stderr, "error, cannot parse font name to pattern: '%s'\n", fontname);
|
||||
XftFontClose(drw->dpy, xfont);
|
||||
return NULL;
|
||||
}
|
||||
} else if (fontpattern) {
|
||||
if (!(xfont = XftFontOpenPattern(drw->dpy, fontpattern))) {
|
||||
fprintf(stderr, "error, cannot load font from pattern.\n");
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
die("no font specified.");
|
||||
}
|
||||
|
||||
font = ecalloc(1, sizeof(Fnt));
|
||||
font->xfont = xfont;
|
||||
font->pattern = pattern;
|
||||
font->h = xfont->ascent + xfont->descent;
|
||||
font->dpy = drw->dpy;
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
static void
|
||||
xfont_free(Fnt *font)
|
||||
{
|
||||
if (!font)
|
||||
return;
|
||||
if (font->pattern)
|
||||
FcPatternDestroy(font->pattern);
|
||||
XftFontClose(font->dpy, font->xfont);
|
||||
free(font);
|
||||
}
|
||||
|
||||
Fnt*
|
||||
drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount)
|
||||
{
|
||||
Fnt *cur, *ret = NULL;
|
||||
size_t i;
|
||||
|
||||
if (!drw || !fonts)
|
||||
return NULL;
|
||||
|
||||
for (i = 1; i <= fontcount; i++) {
|
||||
if ((cur = xfont_create(drw, fonts[fontcount - i], NULL))) {
|
||||
cur->next = ret;
|
||||
ret = cur;
|
||||
}
|
||||
}
|
||||
return (drw->fonts = ret);
|
||||
}
|
||||
|
||||
void
|
||||
drw_fontset_free(Fnt *font)
|
||||
{
|
||||
if (font) {
|
||||
drw_fontset_free(font->next);
|
||||
xfont_free(font);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
|
||||
{
|
||||
if (!drw || !dest || !clrname)
|
||||
return;
|
||||
|
||||
if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
|
||||
DefaultColormap(drw->dpy, drw->screen),
|
||||
clrname, dest))
|
||||
die("error, cannot allocate color '%s'", clrname);
|
||||
}
|
||||
|
||||
/* Wrapper to create color schemes. The caller has to call free(3) on the
|
||||
* returned color scheme when done using it. */
|
||||
Clr *
|
||||
drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
||||
{
|
||||
size_t i;
|
||||
Clr *ret;
|
||||
|
||||
/* need at least two colors for a scheme */
|
||||
if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(XftColor))))
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < clrcount; i++)
|
||||
drw_clr_create(drw, &ret[i], clrnames[i]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
drw_setfontset(Drw *drw, Fnt *set)
|
||||
{
|
||||
if (drw)
|
||||
drw->fonts = set;
|
||||
}
|
||||
|
||||
void
|
||||
drw_setscheme(Drw *drw, Clr *scm)
|
||||
{
|
||||
if (drw)
|
||||
drw->scheme = scm;
|
||||
}
|
||||
|
||||
void
|
||||
drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert)
|
||||
{
|
||||
if (!drw || !drw->scheme)
|
||||
return;
|
||||
XSetForeground(drw->dpy, drw->gc, invert ? drw->scheme[ColBg].pixel : drw->scheme[ColFg].pixel);
|
||||
if (filled)
|
||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||
else
|
||||
XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w - 1, h - 1);
|
||||
}
|
||||
|
||||
int
|
||||
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert)
|
||||
{
|
||||
int ty, ellipsis_x = 0;
|
||||
unsigned int tmpw, ew, ellipsis_w = 0, ellipsis_len, hash, h0, h1;
|
||||
XftDraw *d = NULL;
|
||||
Fnt *usedfont, *curfont, *nextfont;
|
||||
int utf8strlen, utf8charlen, render = x || y || w || h;
|
||||
long utf8codepoint = 0;
|
||||
const char *utf8str;
|
||||
FcCharSet *fccharset;
|
||||
FcPattern *fcpattern;
|
||||
FcPattern *match;
|
||||
XftResult result;
|
||||
int charexists = 0, overflow = 0;
|
||||
/* keep track of a couple codepoints for which we have no match. */
|
||||
static unsigned int nomatches[128], ellipsis_width;
|
||||
|
||||
if (!drw || (render && (!drw->scheme || !w)) || !text || !drw->fonts)
|
||||
return 0;
|
||||
|
||||
if (!render) {
|
||||
w = invert ? invert : ~invert;
|
||||
} else {
|
||||
XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
|
||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||
d = XftDrawCreate(drw->dpy, drw->drawable,
|
||||
DefaultVisual(drw->dpy, drw->screen),
|
||||
DefaultColormap(drw->dpy, drw->screen));
|
||||
x += lpad;
|
||||
w -= lpad;
|
||||
}
|
||||
|
||||
usedfont = drw->fonts;
|
||||
if (!ellipsis_width && render)
|
||||
ellipsis_width = drw_fontset_getwidth(drw, "...");
|
||||
while (1) {
|
||||
ew = ellipsis_len = utf8strlen = 0;
|
||||
utf8str = text;
|
||||
nextfont = NULL;
|
||||
while (*text) {
|
||||
utf8charlen = utf8decode(text, &utf8codepoint, UTF_SIZ);
|
||||
for (curfont = drw->fonts; curfont; curfont = curfont->next) {
|
||||
charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint);
|
||||
if (charexists) {
|
||||
drw_font_getexts(curfont, text, utf8charlen, &tmpw, NULL);
|
||||
if (ew + ellipsis_width <= w) {
|
||||
/* keep track where the ellipsis still fits */
|
||||
ellipsis_x = x + ew;
|
||||
ellipsis_w = w - ew;
|
||||
ellipsis_len = utf8strlen;
|
||||
}
|
||||
|
||||
if (ew + tmpw > w) {
|
||||
overflow = 1;
|
||||
/* called from drw_fontset_getwidth_clamp():
|
||||
* it wants the width AFTER the overflow
|
||||
*/
|
||||
if (!render)
|
||||
x += tmpw;
|
||||
else
|
||||
utf8strlen = ellipsis_len;
|
||||
} else if (curfont == usedfont) {
|
||||
utf8strlen += utf8charlen;
|
||||
text += utf8charlen;
|
||||
ew += tmpw;
|
||||
} else {
|
||||
nextfont = curfont;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (overflow || !charexists || nextfont)
|
||||
break;
|
||||
else
|
||||
charexists = 0;
|
||||
}
|
||||
|
||||
if (utf8strlen) {
|
||||
if (render) {
|
||||
ty = y + (h - usedfont->h) / 2 + usedfont->xfont->ascent;
|
||||
XftDrawStringUtf8(d, &drw->scheme[invert ? ColBg : ColFg],
|
||||
usedfont->xfont, x, ty, (XftChar8 *)utf8str, utf8strlen);
|
||||
}
|
||||
x += ew;
|
||||
w -= ew;
|
||||
}
|
||||
if (render && overflow)
|
||||
drw_text(drw, ellipsis_x, y, ellipsis_w, h, 0, "...", invert);
|
||||
|
||||
if (!*text || overflow) {
|
||||
break;
|
||||
} else if (nextfont) {
|
||||
charexists = 0;
|
||||
usedfont = nextfont;
|
||||
} else {
|
||||
/* Regardless of whether or not a fallback font is found, the
|
||||
* character must be drawn. */
|
||||
charexists = 1;
|
||||
|
||||
hash = (unsigned int)utf8codepoint;
|
||||
hash = ((hash >> 16) ^ hash) * 0x21F0AAAD;
|
||||
hash = ((hash >> 15) ^ hash) * 0xD35A2D97;
|
||||
h0 = ((hash >> 15) ^ hash) % LENGTH(nomatches);
|
||||
h1 = (hash >> 17) % LENGTH(nomatches);
|
||||
/* avoid expensive XftFontMatch call when we know we won't find a match */
|
||||
if (nomatches[h0] == utf8codepoint || nomatches[h1] == utf8codepoint)
|
||||
goto no_match;
|
||||
|
||||
fccharset = FcCharSetCreate();
|
||||
FcCharSetAddChar(fccharset, utf8codepoint);
|
||||
|
||||
if (!drw->fonts->pattern) {
|
||||
/* Refer to the comment in xfont_create for more information. */
|
||||
die("the first font in the cache must be loaded from a font string.");
|
||||
}
|
||||
|
||||
fcpattern = FcPatternDuplicate(drw->fonts->pattern);
|
||||
FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset);
|
||||
FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue);
|
||||
|
||||
FcConfigSubstitute(NULL, fcpattern, FcMatchPattern);
|
||||
FcDefaultSubstitute(fcpattern);
|
||||
match = XftFontMatch(drw->dpy, drw->screen, fcpattern, &result);
|
||||
|
||||
FcCharSetDestroy(fccharset);
|
||||
FcPatternDestroy(fcpattern);
|
||||
|
||||
if (match) {
|
||||
usedfont = xfont_create(drw, NULL, match);
|
||||
if (usedfont && XftCharExists(drw->dpy, usedfont->xfont, utf8codepoint)) {
|
||||
for (curfont = drw->fonts; curfont->next; curfont = curfont->next)
|
||||
; /* NOP */
|
||||
curfont->next = usedfont;
|
||||
} else {
|
||||
xfont_free(usedfont);
|
||||
nomatches[nomatches[h0] ? h1 : h0] = utf8codepoint;
|
||||
no_match:
|
||||
usedfont = drw->fonts;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (d)
|
||||
XftDrawDestroy(d);
|
||||
|
||||
return x + (render ? w : 0);
|
||||
}
|
||||
|
||||
void
|
||||
drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h)
|
||||
{
|
||||
if (!drw)
|
||||
return;
|
||||
|
||||
XCopyArea(drw->dpy, drw->drawable, win, drw->gc, x, y, w, h, x, y);
|
||||
XSync(drw->dpy, False);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
drw_fontset_getwidth(Drw *drw, const char *text)
|
||||
{
|
||||
if (!drw || !drw->fonts || !text)
|
||||
return 0;
|
||||
return drw_text(drw, 0, 0, 0, 0, 0, text, 0);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n)
|
||||
{
|
||||
unsigned int tmp = 0;
|
||||
if (drw && drw->fonts && text && n)
|
||||
tmp = drw_text(drw, 0, 0, 0, 0, 0, text, n);
|
||||
return MIN(n, tmp);
|
||||
}
|
||||
|
||||
void
|
||||
drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h)
|
||||
{
|
||||
XGlyphInfo ext;
|
||||
|
||||
if (!font || !text)
|
||||
return;
|
||||
|
||||
XftTextExtentsUtf8(font->dpy, font->xfont, (XftChar8 *)text, len, &ext);
|
||||
if (w)
|
||||
*w = ext.xOff;
|
||||
if (h)
|
||||
*h = font->h;
|
||||
}
|
||||
|
||||
Cur *
|
||||
drw_cur_create(Drw *drw, int shape)
|
||||
{
|
||||
Cur *cur;
|
||||
|
||||
if (!drw || !(cur = ecalloc(1, sizeof(Cur))))
|
||||
return NULL;
|
||||
|
||||
cur->cursor = XCreateFontCursor(drw->dpy, shape);
|
||||
|
||||
return cur;
|
||||
}
|
||||
|
||||
void
|
||||
drw_cur_free(Drw *drw, Cur *cursor)
|
||||
{
|
||||
if (!cursor)
|
||||
return;
|
||||
|
||||
XFreeCursor(drw->dpy, cursor->cursor);
|
||||
free(cursor);
|
||||
}
|
||||
58
dmenu/drw.h
Normal file
58
dmenu/drw.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
typedef struct {
|
||||
Cursor cursor;
|
||||
} Cur;
|
||||
|
||||
typedef struct Fnt {
|
||||
Display *dpy;
|
||||
unsigned int h;
|
||||
XftFont *xfont;
|
||||
FcPattern *pattern;
|
||||
struct Fnt *next;
|
||||
} Fnt;
|
||||
|
||||
enum { ColFg, ColBg }; /* Clr scheme index */
|
||||
typedef XftColor Clr;
|
||||
|
||||
typedef struct {
|
||||
unsigned int w, h;
|
||||
Display *dpy;
|
||||
int screen;
|
||||
Window root;
|
||||
Drawable drawable;
|
||||
GC gc;
|
||||
Clr *scheme;
|
||||
Fnt *fonts;
|
||||
} Drw;
|
||||
|
||||
/* Drawable abstraction */
|
||||
Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
|
||||
void drw_resize(Drw *drw, unsigned int w, unsigned int h);
|
||||
void drw_free(Drw *drw);
|
||||
|
||||
/* Fnt abstraction */
|
||||
Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount);
|
||||
void drw_fontset_free(Fnt* set);
|
||||
unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
|
||||
unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n);
|
||||
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
|
||||
|
||||
/* Colorscheme abstraction */
|
||||
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
|
||||
Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
|
||||
|
||||
/* Cursor abstraction */
|
||||
Cur *drw_cur_create(Drw *drw, int shape);
|
||||
void drw_cur_free(Drw *drw, Cur *cursor);
|
||||
|
||||
/* Drawing context manipulation */
|
||||
void drw_setfontset(Drw *drw, Fnt *set);
|
||||
void drw_setscheme(Drw *drw, Clr *scm);
|
||||
|
||||
/* Drawing functions */
|
||||
void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert);
|
||||
int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert);
|
||||
|
||||
/* Map functions */
|
||||
void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);
|
||||
BIN
dmenu/drw.o
Normal file
BIN
dmenu/drw.o
Normal file
Binary file not shown.
37
dmenu/patches/dmenu-border-5.2.diff
Normal file
37
dmenu/patches/dmenu-border-5.2.diff
Normal file
@@ -0,0 +1,37 @@
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 1edb647..dd3eb31 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -21,3 +21,6 @@ static unsigned int lines = 0;
|
||||
* for example: " /?\"&[]"
|
||||
*/
|
||||
static const char worddelimiters[] = " ";
|
||||
+
|
||||
+/* Size of the window border */
|
||||
+static unsigned int border_width = 0;
|
||||
diff --git a/dmenu.c b/dmenu.c
|
||||
index 27b7a30..7c130fc 100644
|
||||
--- a/dmenu.c
|
||||
+++ b/dmenu.c
|
||||
@@ -684,9 +684,11 @@ setup(void)
|
||||
swa.override_redirect = True;
|
||||
swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
|
||||
- win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
|
||||
+ win = XCreateWindow(dpy, parentwin, x, y, mw, mh, border_width,
|
||||
CopyFromParent, CopyFromParent, CopyFromParent,
|
||||
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
|
||||
+ if (border_width)
|
||||
+ XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel);
|
||||
XSetClassHint(dpy, win, &ch);
|
||||
|
||||
|
||||
@@ -757,6 +759,8 @@ main(int argc, char *argv[])
|
||||
colors[SchemeSel][ColFg] = argv[++i];
|
||||
else if (!strcmp(argv[i], "-w")) /* embedding window id */
|
||||
embed = argv[++i];
|
||||
+ else if (!strcmp(argv[i], "-bw"))
|
||||
+ border_width = atoi(argv[++i]); /* border width */
|
||||
else
|
||||
usage();
|
||||
|
||||
71
dmenu/patches/dmenu-bordercolor-20230512-0fe460d.diff
Normal file
71
dmenu/patches/dmenu-bordercolor-20230512-0fe460d.diff
Normal file
@@ -0,0 +1,71 @@
|
||||
From 8dbea77ad7b320d9c7e07990274ea74835785084 Mon Sep 17 00:00:00 2001
|
||||
From: Markus Hanetzok <markus@hanetzok.net>
|
||||
Date: Sun, 14 May 2023 01:04:09 +0200
|
||||
Subject: [PATCH] Makes border colors independent from SelBg
|
||||
---
|
||||
config.def.h | 5 +++++
|
||||
dmenu.c | 9 +++++++--
|
||||
2 files changed, 12 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 1edb647..ae41b06 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -12,6 +12,7 @@ static const char *colors[SchemeLast][2] = {
|
||||
[SchemeNorm] = { "#bbbbbb", "#222222" },
|
||||
[SchemeSel] = { "#eeeeee", "#005577" },
|
||||
[SchemeOut] = { "#000000", "#00ffff" },
|
||||
+ [SchemeBorder] = { "#cccccc", NULL },
|
||||
};
|
||||
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
|
||||
static unsigned int lines = 0;
|
||||
@@ -21,3 +22,7 @@ static unsigned int lines = 0;
|
||||
* for example: " /?\"&[]"
|
||||
*/
|
||||
static const char worddelimiters[] = " ";
|
||||
+
|
||||
+/* Size of the window border */
|
||||
+static unsigned int border_width = 0;
|
||||
+
|
||||
diff --git a/dmenu.c b/dmenu.c
|
||||
index 62f1089..7f063b6 100644
|
||||
--- a/dmenu.c
|
||||
+++ b/dmenu.c
|
||||
@@ -26,7 +26,7 @@
|
||||
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||
|
||||
/* enums */
|
||||
-enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
|
||||
+enum { SchemeNorm, SchemeSel, SchemeOut, SchemeBorder, SchemeLast }; /* color schemes */
|
||||
|
||||
struct item {
|
||||
char *text;
|
||||
@@ -685,9 +685,11 @@ setup(void)
|
||||
swa.override_redirect = True;
|
||||
swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
|
||||
- win = XCreateWindow(dpy, root, x, y, mw, mh, 0,
|
||||
+ win = XCreateWindow(dpy, root, x, y, mw, mh, border_width,
|
||||
CopyFromParent, CopyFromParent, CopyFromParent,
|
||||
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
|
||||
+ if (border_width)
|
||||
+ XSetWindowBorder(dpy, win, scheme[SchemeBorder][ColFg].pixel);
|
||||
XSetClassHint(dpy, win, &ch);
|
||||
|
||||
|
||||
@@ -759,6 +761,8 @@ main(int argc, char *argv[])
|
||||
colors[SchemeSel][ColFg] = argv[++i];
|
||||
else if (!strcmp(argv[i], "-w")) /* embedding window id */
|
||||
embed = argv[++i];
|
||||
+ else if (!strcmp(argv[i], "-bw"))
|
||||
+ border_width = atoi(argv[++i]); /* border width */
|
||||
else
|
||||
usage();
|
||||
|
||||
@@ -795,3 +799,4 @@ main(int argc, char *argv[])
|
||||
|
||||
return 1; /* unreachable */
|
||||
}
|
||||
+
|
||||
--
|
||||
2.40.1
|
||||
56
dmenu/patches/dmenu-center-4.8.diff
Normal file
56
dmenu/patches/dmenu-center-4.8.diff
Normal file
@@ -0,0 +1,56 @@
|
||||
diff --git a/dmenu.c b/dmenu.c
|
||||
index 5e9c367..2268ea9 100644
|
||||
--- a/dmenu.c
|
||||
+++ b/dmenu.c
|
||||
@@ -88,6 +88,15 @@ calcoffsets(void)
|
||||
break;
|
||||
}
|
||||
|
||||
+static int
|
||||
+max_textw(void)
|
||||
+{
|
||||
+ int len = 0;
|
||||
+ for (struct item *item = items; item && item->text; item++)
|
||||
+ len = MAX(TEXTW(item->text), len);
|
||||
+ return len;
|
||||
+}
|
||||
+
|
||||
static void
|
||||
cleanup(void)
|
||||
{
|
||||
@@ -598,6 +607,7 @@ setup(void)
|
||||
bh = drw->fonts->h + 2;
|
||||
lines = MAX(lines, 0);
|
||||
mh = (lines + 1) * bh;
|
||||
+ promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
|
||||
#ifdef XINERAMA
|
||||
i = 0;
|
||||
if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) {
|
||||
@@ -624,9 +634,9 @@ setup(void)
|
||||
if (INTERSECT(x, y, 1, 1, info[i]))
|
||||
break;
|
||||
|
||||
- x = info[i].x_org;
|
||||
- y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
|
||||
- mw = info[i].width;
|
||||
+ mw = MIN(MAX(max_textw() + promptw, 100), info[i].width);
|
||||
+ x = info[i].x_org + ((info[i].width - mw) / 2);
|
||||
+ y = info[i].y_org + ((info[i].height - mh) / 2);
|
||||
XFree(info);
|
||||
} else
|
||||
#endif
|
||||
@@ -634,11 +644,10 @@ setup(void)
|
||||
if (!XGetWindowAttributes(dpy, parentwin, &wa))
|
||||
die("could not get embedding window attributes: 0x%lx",
|
||||
parentwin);
|
||||
- x = 0;
|
||||
- y = topbar ? 0 : wa.height - mh;
|
||||
- mw = wa.width;
|
||||
+ mw = MIN(MAX(max_textw() + promptw, 100), wa.width);
|
||||
+ x = (wa.width - mw) / 2;
|
||||
+ y = (wa.height - mh) / 2;
|
||||
}
|
||||
- promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
|
||||
inputw = MIN(inputw, mw/3);
|
||||
match();
|
||||
|
||||
57
dmenu/patches/dmenu-date-5.2.diff
Normal file
57
dmenu/patches/dmenu-date-5.2.diff
Normal file
@@ -0,0 +1,57 @@
|
||||
From 64fb38e3778addc0272eb8793deb909e639e5746 Mon Sep 17 00:00:00 2001
|
||||
From: piotr-marendowski <piotr-marendowski@tutanota.com>
|
||||
Date: Thu, 6 Jul 2023 10:03:03 +0000
|
||||
Subject: [PATCH] Displays date and time at the bottom of the vertical layout.
|
||||
|
||||
---
|
||||
dmenu.c | 20 +++++++++++++++++++-
|
||||
1 file changed, 19 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/dmenu.c b/dmenu.c
|
||||
index 7cf253b..5428f67 100644
|
||||
--- a/dmenu.c
|
||||
+++ b/dmenu.c
|
||||
@@ -84,7 +84,7 @@ calcoffsets(void)
|
||||
int i, n;
|
||||
|
||||
if (lines > 0)
|
||||
- n = lines * bh;
|
||||
+ n = (lines * bh) - 1;
|
||||
else
|
||||
n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">"));
|
||||
/* calculate which items will begin the next page and previous page */
|
||||
@@ -143,6 +143,22 @@ drawitem(struct item *item, int x, int y, int w)
|
||||
return drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
|
||||
}
|
||||
|
||||
+static int
|
||||
+drawdate(int x, int y, int w)
|
||||
+{
|
||||
+ char date[128];
|
||||
+ time_t t = time(NULL);
|
||||
+ struct tm *tm = localtime(&t);
|
||||
+
|
||||
+ /* Hour:Minute DayOfTheWeek DayOfTheMonth Month Year */
|
||||
+ strftime(date, sizeof(date), "%H:%M %A %d %B %Y", tm);
|
||||
+
|
||||
+ drw_setscheme(drw, scheme[SchemeSel]);
|
||||
+
|
||||
+ int r = drw_text(drw, x, y, w, bh, lrpad / 2, date, 0);
|
||||
+ return r;
|
||||
+}
|
||||
+
|
||||
static void
|
||||
drawmenu(void)
|
||||
{
|
||||
@@ -172,6 +188,8 @@ drawmenu(void)
|
||||
/* draw vertical list */
|
||||
for (item = curr; item != next; item = item->right)
|
||||
drawitem(item, x, y += bh, mw - x);
|
||||
+
|
||||
+ drawdate(x, lines * bh, w);
|
||||
} else if (matches) {
|
||||
/* draw horizontal list */
|
||||
x += inputw;
|
||||
--
|
||||
2.41.0
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user