changes to codebase so i can maintain it easier

This commit is contained in:
speedie 2022-10-20 15:29:43 +02:00
parent daf433d9aa
commit 5569f969b0
18 changed files with 247 additions and 564 deletions

View file

@ -6,7 +6,7 @@ include options.mk
include host.mk include host.mk
include toggle.mk include toggle.mk
SRC = drw.c speedwm.c util.c SRC = draw.c speedwm.c main.c
OBJ = ${SRC:.c=.o} OBJ = ${SRC:.c=.o}
ifdef USEIPC ifdef USEIPC
@ -36,7 +36,7 @@ speedwm-msg: toggle/ipc-speedwm-msg.o
endif endif
clean: clean:
rm -f speedwm ${OBJ} speedwm-${VERSION}.tar.gz rm -f speedwm *.o speedwm-${VERSION}.tar.gz
rm -f speedwm-msg rm -f speedwm-msg
echo "Cleaned!" echo "Cleaned!"
@ -49,7 +49,7 @@ dist: clean
rm -rf speedwm-${VERSION} speedwm-msg rm -rf speedwm-${VERSION} speedwm-msg
install: all install: all
@echo speedwm build options: @echo speedwm ${VERSION} build options:
@echo "CFLAGS = [${CFLAGS}]" @echo "CFLAGS = [${CFLAGS}]"
@echo "LDFLAGS = [${LDFLAGS}]" @echo "LDFLAGS = [${LDFLAGS}]"
@echo "CC = [${CC}]" @echo "CC = [${CC}]"
@ -86,6 +86,8 @@ install: all
./scripts/speedwm-compatcheck ./scripts/speedwm-compatcheck
make modules_install make modules_install
[ -f ${DESTDIR}${PREFIX}/bin/speedwm ] && rm -f drw.o speedwm.o util.o speedwm speedwm-msg || : [ -f ${DESTDIR}${PREFIX}/bin/speedwm ] && rm -f drw.o speedwm.o util.o speedwm speedwm-msg || :
echo ${VERSION} > ${DESTDIR}${PREFIX}/share/speedwm/speedwm-version
rm -f *.o
modules_install: modules_install:
cp -f modules/module_* ${DESTDIR}${PREFIX}/bin cp -f modules/module_* ${DESTDIR}${PREFIX}/bin

408
README.md
View file

@ -1,408 +0,0 @@
speedwm is a window manager forked from suckless.org's dwm or dynamic window manager. It manages the user's open windows and tiles them according to a set layout (dynamic).
Just like dwm, speedwm also tries to be minimal but also has functionality and aesthetics as a goal. It is also much more minimal than other window managers like i3-gaps while offering many more features.
Tiling window managers (unlike floating window managers that you may be used to) tile windows based on a set layout making them easy to get productive on.
They also encourage the user to use their keyboard instead of the mouse so that the user doesn't have to move their hands much but there are mouse keybinds and more can be added.
## Installation
In order to install this build of speedwm, all dependencies must be installed.
You can see (Dependencies) for a list of all dependencies required to use this fork.
- git clone https://codeberg.org/speedie/speedwm
- cd speedwm
- make clean install
- If any warnings show up, fix it by installing the missing dependency.
- If a .xinitrc is used, add 'speedwm_run' to the end.
- NOTE: Your .xinitrc should ONLY contain 'speedwm_run'. speedwm will automatically start everything else. If not, edit autostart.h and 'make clean install'. If a .xinitrc is not used then you don't need to worry. A .desktop file is automatically created when you run 'make clean install'.
## Layouts
speedwm comes with the following layouts:
- Tile
- Monocle
- Grid
- Deck
- Centered Master
- Centered Floating Master
- Spiral
- Dwindle
- Bottom Stack
- Horizontal Bottom Stack
- Horizonal Grid
- Dynamic Grid
- Custom
They can be switched between using a little menu (See Keybinds for more information) or by right clicking the Layout indicator.
The more commonly used layouts can be switched between using a quick keybind.
Do note that these may be disabled through the toggle.h header.
## Keybinds
This is a full list of keybinds.
Please let me know if any keybinds are missing as these have been manually added.
### Applications
Keybinds for regular applications
- Super+Shift+Enter | Opens a terminal
- Super+Shift+Colon | Opens a dmenu prompt
- Super+Shift+s | Opens 'maim' to take a screenshot and copies it to the clipboard using 'xclip'
- Super+Shift+f | Opens the defined file manager
- Super+Shift+w | Opens the defined web browser
- Super+Shift+o | Opens the bundled dfmpeg dmenu script to record your screen.
- Super+Shift+t | Opens the defined editor in your terminal
- Super+Shift+m | Kills the defined music player
- Super+Shift+a | Opens the defined mixer in your terminal
- Super+Shift+m | Opens the defined music player
- Super+Shift+x | Opens the defined system process viewer in your terminal
- Super+Shift+c | Opens the defined chat client
- Super+Shift+i | Open a dmenu prompt and open the file the user picks in Zathura
- Super+Shift+p | Open a dmenu prompt and open the file the user picks in Vim
- Super+Shift+d | Opens iron in the terminal if it is installed.
- Super+Shift+u | Opens the defined RSS reader
- Super+Shift+r | Opens the defined email client
### Navigation
These keybinds are for navigating speedwm
- Super+t | Reorganize tags and move windows
- Super+f | Full-screen the selected window
- Super+b | Show/hide the speedwm bar
- Super+s | Show/hide the systray
- Super+j/k | Move focus between visible windows
- Super+m | Moves focus to the Master window (or back if Master is already focused)
- Super+Control+z/x | Increase/decrease gaps between windows by 5
- Super+Control+j/k | Move focus between hidden windows (Can then 'Show')
- Super+a/d | Increase/decrease size of each window
- Super+o | Hide a window
- Super+Control+o | Show a hidden focused window
- Super+Control+Shift+o | Show all hidden windows
- Super+Control+Shift+p | Hide all windows
- Super+Control+a/d | Move to the next/previous tag
- Super+Control+Shift+z/c | Move to the next/previous tag skipping any without windows open
- Super+Minus | Show the scratchpad
- Super+Equal | Remove the scratchpad
- Super+Enter | Switch order of windows
- Super+Shift+q | Close the current window
- Super+Colon | Open a list of desktop entries in dmenu
- Super+0 | Reset mfact
- Super+r | Reset number of masters
- Super+t | Disable inactive fade
- Super+Shift+Equal | Toggle scratchpads
- Super+Shift+Minus | Hide the scratchpad
- Super+Shift+Space | Unfloat floating windows
- Super+Shift+Arrow | Resizes a window in floating mode
- Super+1 | Move to tag 1
- Super+2 | Move to tag 2
- Super+3 | Move to tag 3
- Super+4 | Move to tag 4
- Super+5 | Move to tag 5
- Super+6 | Move to tag 6
- Super+7 | Move to tag 7
- Super+8 | Move to tag 8
- Super+9 | Move to tag 9
- Super+Shift+1 | Preview tag 1
- Super+Shift+2 | Preview tag 2
- Super+Shift+3 | Preview tag 3
- Super+Shift+4 | Preview tag 4
- Super+Shift+5 | Preview tag 5
- Super+Shift+6 | Preview tag 6
- Super+Shift+7 | Preview tag 7
- Super+Shift+8 | Preview tag 8
- Super+Shift+9 | Preview tag 9
- Super+Shift+h/j/k/l | Rotates a stack.
- Super+Shift+Escape | Ask the user if they want to shutdown or reboot or nothing
- Super+Control+1 | Combine the current tag with tag 1
- Super+Control+2 | Combine the current tag with tag 2
- Super+Control+3 | Combine the current tag with tag 3
- Super+Control+4 | Combine the current tag with tag 4
- Super+Control+5 | Combine the current tag with tag 5
- Super+Control+6 | Combine the current tag with tag 6
- Super+Control+7 | Combine the current tag with tag 7
- Super+Control+8 | Combine the current tag with tag 8
- Super+Control+9 | Combine the current tag with tag 9
- Super+Control+Shift+Colon | Open a list of extra software in dmenu
- Super+Control+q | Mutes your audio
- Super+Control+w | Increases your volume
- Super+Control+e | Decreases your volume
- Super+Control+0 | Tag all tags at once.
- Super+Control+Arrow | Moves a window to any corner of your screen (Arrow key)
- Super+Control+Tab | Open a dmenu prompt asking the user what layout to switch to
- Super+Control+h | Open a list of all keybinds in your terminal using less
- Super+Control+Shift+a/d | Move between available layouts
- Super+Control+Shift+1 | Move the focused window to tag 1
- Super+Control+Shift+2 | Move the focused window to tag 2
- Super+Control+Shift+3 | Move the focused window to tag 3
- Super+Control+Shift+4 | Move the focused window to tag 4
- Super+Control+Shift+5 | Move the focused window to tag 5
- Super+Control+Shift+6 | Move the focused window to tag 6
- Super+Control+Shift+7 | Move the focused window to tag 7
- Super+Control+Shift+8 | Move the focused window to tag 8
- Super+Control+Shift+9 | Move the focused window to tag 9
- Super+Control+Shift+Esc | Open speedwm-utils
- Super+Control+Shift+Arrow | Resize the window to the screen size.
- Super+Control+Shift+s | Set a wallpaper
- Super+Control+Shift+n | Connect to WLAN (Using iwd)
- Super+Control+Shift+b | Connect to a Bluetooth device (Using bluez)
- Super+Control+Shift+f | Open up a list of speedwm config files in dmenu that you can edit.
- Super+Control+Shift+q | Pauses your music
- Super+Control+Shift+w | Decreases your music volume
- Super+Control+Shift+e | Increase your music volume
- Super+Control+Shift+r | Restart speedwm
- Super+w/e | Resize the window keeping the aspect ratio of it.
- Super+Tab | Switch between windows on the same tag. (Like Windows Alt+Tab)
- Super+Shift+Tab | Switch between windows and tags in detail.
- Super+Control+Shift+j/k | Change window size vertically (cfact)
### Chained keybinds
- Super+c & w | Get the weather (Using wttr.in)
- Super+c & n | Switch to the next track
- Super+c & p | Switch to the previous track
- Super+g & t | Toggle gaps
- Super+g & 0 | Reset gaps
- Super+g & i | Increase inner gaps by 1
- Super+g & o | Increase outer gaps by 1
- Super+g & j/k | Increase/decrease gaps between windows by 1
- Super+Shift+g & i | Decrease inner gaps by 1
- Super+Shift+g & o | Decrease outer gaps by 1
- Super+r & s | Run screenkey if it is installed
- Super+r & d | Kill screenkey
- Super+Shift+e & a | Open the virtual keyboard
- Super+Shift+e & e | Open a list of all emojis and copy the selection
- Super+Shift+k & o | Kill every window except the focused
- Super+t & s | Make the current selected window sticky
- Super+w & r | Randomize wallpaper
- Super+w & p | Set wallpaper to the previous
### Extras
These will only work if your keyboard has special multimedia buttons.
- Mute button | Mutes your audio
- Up Volume button | Increases your volume
- Next/Previous song button | Switch to the next/previous track
- Down Volume button | Decreases your volume
- Pause button | Pauses the current track
- Stop button | Stops your defined music player
- Browser button | Opens your defined web browser
- Power button | Ask if you wanna shut down, restart or lock your computer.
- Email button | Open your defined email client
- System button | Open your defined status viewer in a terminal
- Music button | Open your defined music player
- WLAN button | Disconnect from WLAN
### Mouse
These binds can be activated using your mouse
- Tag <num> (Left click) | Switch to tag <num>
- Tag (Scrolling up/down) | Switch to the next/previous tag
- Layout indicator (Left click) | Switch to the next layout
- Layout indicator (Middle click) | Switch to the next layout
- Layout indicator (Right click) | Open a dmenu list of all layouts
- Window title (Left click) | Hide/Show the window
- Window title (Right click) | Open speedwm-utils
- Focused window (Super+Alt+Left click) | Move the focused window around
- Focused window (Super+Alt+Middle click) | Make the focused window floating
- Focused window title (Middle click) | Rotate stack
- Dragging (Super+Right click) | Increase/decrease size of each window (mfact)
- Dragging (SuperControl+Right click) | Increase/decrease cfact
- Root window (Right click) | List .desktop entries and open them
There are also keybinds for statuscmd, but you must implement it into your own status bar.
See mouse.h for more information.
## Dependencies
These are absolutely necessary, speedwm will NOT compile without them
- libxft
- libXinerama
- Can be disabled through editing toggle.mk if you're not interested in multiple monitors.
- imlib2
- Tag previews, Window icons. Can be disabled through editing toggle.mk and toggle.h if you don't want these features.
- yajl
- Required for the IPC patch. If the IPC patch is disabled, you do not need this.
- tcc
- Very minimal C compiler that speedwm uses to speed up compile times. If you don't want this dependency, edit host.mk and set CC to 'cc' (or what you prefer).
## Features
These are necessary for certain features. By default speedwm will prevent an installation without them but you can bypass these if you want.
If you want to use an alternative, change it in options.h.
- dmenu
- NOTE: dmenu is required for most scripts included with this build of speedwm. My build is required for proper Pywal support.
- If you do not have the password, grid and center patches, you must disable them in ~/.config/speedwm-de/global/config by setting two variables to false.
- picom
- Optional but speedwm looks sort of ugly without it.
- xclip (Required for clipboard support by a few scripts, will start automatically)
- xwallpaper (Required to set wallpapers)
- xmodmap
- Required if you want the Alt+Tab to have proper keybinds.
- xrdb (Install if you want .Xresources support)
- pywal (Install if you want pywal support. Requires swal aka the default way to set wallpapers)
- wmctrl (Needed for proper window management)
- slock (Required for screen locking)
- If you want to display a message, you need the text patch.
- If you have the background image patch, you can set the image to ~/.config/speedwm-de/swal/CurrentWallpaper. It is a symlink to the current wallpaper.
- maim (Required for built in 'speedwm-screenshotutil' script)
- j4-dmenu-desktop
- Required for dmenu desktop entries. speedwm will not prevent installation without this because it doesn't provide much functionality.
## Software
This build of speedwm comes with binds for software.
These must be installed by default but you can change what software is required by editing 'options.h' and running 'make clean install'.
You can also remove keybinds by editing 'keybinds.h' and running 'make clean install'.
- st (Terminal)
- GNU IceCat (Web browser)
- htop (Status monitor)
- newsboat (RSS reader)
- zathura (PDF reader)
- alsa-utils (Required for audio controls)
- cmus (Default music player)
- neovim (Text editor)
- aerc (Email client)
- maim (Screenshot tool, automatically copies to clipboard using xclip)
- vifm (File manager)
- slock (Lock screen)
And everything under 'Features'.
## Important
If you're used to dwm, speedwm might be a little unfamiliar to you at first. This is because speedwm doesn't use config.h (or config.def.h).
Instead, config.h is split into different parts to make it easier to edit. Instead of editing config.h you'll want to edit:
- autostart.h for starting stuff right before speedwm (For example xclip, pywal, etc.)
- options.h for changing colors and applications to use with keybinds.
- signal.h for adding fake signals
- colors.h for changing alpha options and color options, most users won't need to edit it.
- xresources.h for adding/removing .Xresources options
- rules.h for adding/removing rules
- keybinds.h for adding/removing keybinds.
- mouse.h for adding/removing mouse binds.
- statusbar.h for adding/removing statuscmd clicks.
- ipc.h for adding/removing IPC commands. (If support is compiled in)
- toggle.h for adding/removing features from getting compiled in.
- actions.h for changing classes/defines used by keybinds and rules.
After you've edited one of the files, you need to run 'make clean install' to reinstall speedwm.
Remember that you can change colors through your .Xresources file (see .Xresources and Pywal) meaning you do not need to recompile speedwm.
Another important detail you must keep in mind is that this build comes with a status bar simply named 'status'.
It can be found in the speedwm source code directory. It is just a shell script which adds stuff to your status bar. It will automatically be started when speedwm starts.
You can edit the status bar simply by editing 'status' and running 'make clean install'.
You can also configure it by editing '~/.config/speedwm-de/status/config'.
If you want to change status bar, edit options.h and set 'static char status' to your status bar binary (must be in $PATH).
Alternatively, you can also set "speedwm.status: <statusbar>" in .Xresources (See .Xresources and Pywal).
## .Xresources and Pywal
This fork of speedwm has .Xresources support thanks to the .Xresources patch. It also has pywal support (tool which grabs colors based on your wallpaper).
Colors can be reloaded on-the-fly using the built in wallpaper utility. In order to implement speedwm reloading support to your own wallpaper utility, run shell command (/bin/sh) 'speedwm_run -r' to reload colors automatically.
Note that the 'xrdb' dependency is required for both pywal and .Xresources support.
Below is a list of all .Xresources values you can define. The .Xresources file should be placed in ~ or ~/.config by the user.
If it is not or you want it somewhere else, you can edit 'autostart.h' and 'make clean install'.
## Signals
Thanks to the 'fsignal' patch available on suckless.org's website, we can easily write shell scripts to interact with dwm and therefore speedwm.
I made some changes to this patch, because it has some.. questionable behaviour in my opinion.
To use signals, simply use the speedwm-utils script. Syntax is speedwm-utils -exec <signum>
Below is a list of all signums and what they do.
- 1 | Switch to the Tiling layout
- 2 | Switch to the Floating layout
- 3 | Switch to the Monocle layout
- 4 | Switch to the Grid layout
- 5 | Switch to the Deck layout
- 6 | Switch to the Centered Master layout
- 7 | Switch to the Centered Floating Master layout
- 8 | Switch to the Fibonacci Spiral layout
- 9 | Switch to the Fibonacci Dwindle layout
- 10 | Switch to the Bottom Stack Vertical layout
- 11 | Switch to the Bottom Stack Horizontal layout
- 12 | Switch to the Horizontal Grid layout
- 13 | Switch to the Dynamic Grid layout
- 14 | Switch to the Custom layout
- 15 | Custom layout options
- 16 | Switch to the next layout
- 17 | Switch to the previous layout
- 18 | Increase mfact by 0.05
- 19 | Decrease mfact by 0.05
- 20 | Toggle sticky
- 21 | Toggle the bar
- 22 | Toggle fullscreen
- 23 | Toggle floating
- 24 | Swap the current window with the next
- 25 | Reorganize tags (Reorder them)
- 26 | Shutdown speedwm
- 27 | Restart speedwm
- 28 | Show the focused window
- 29 | Hide the focused window
- 30 | Kill the focused window
- 31 | Rotate the stack up
- 32 | Rotate the stack down
- 33 | Increase number of clients in the master stack
- 34 | Decrease number of clients in the master stack
- 35 | Focus the Master client
- 36 | Switch focus between windows +1
- 37 | Switch focus between windows -1
- 38 | Switch focus between hidden windows +1
- 39 | Switch focus between hidden windows -1
- 40 | Toggle opacity for windows
- 41 | Increase cfact by 0.05
- 42 | Decrease cfact by 0.05
- 43 | Switch to the previous tag
- 44 | Switch to the next tag
- 45 | Reset gaps to the default size
- 46 | Toggle gaps
- 47 | Increase gaps by 1
- 48 | Decrease gaps by 1
- 49 | Increase inner gaps by 1
- 50 | Decrease inner gaps by 1
- 51 | Increase outer gaps by 1
- 52 | Decrease outer gaps by 1
- 53 | Kill all clients except focused
- 54 | Focus the next monitor
- 55 | Focus the previous monitor
- 56 | Show the scratchpad
- 57 | Hide the scratchpad
- 58 | Remove the scratchpad
- 59 | Reset layout/mfact
- 60 | Reset mastercount
- 61 | Show/Hide systray
- 62 | Hide all windows
- 63 | Show all windows
- 64 | Reset mfact
- 65 | Reload .Xresources on the fly
- 66 | Switch to the previous tag, skipping empty tags
- 67 | Switch to the next tag, skipping empty tags
## Switching run launcher
Some users may prefer to use a different run launcher than dmenu.
Previously all scripts bundled would only run dmenu from $PATH but you can now switch run launcher very easily.
- Edit options.h and change RUN to your run launcher
- Add "export RUNLAUNCHER=<runlauncher>" to your .<shell>rc
Run launchers must support dmenu arguments because otherwise scripts are going to be incompatible.
It must also support the additional '-g' argument that the dmenu grid patch provides unless you modify the scripts bundled.
Keep in mind that if you use a different run launcher, it may not support Pywal/.Xresources.
## Maintaining settings easily
speedwm is a personal fork of dwm and will therefore likely have keybinds and other options you may not like. Because of this, I recommend that you use the patching system to manage your "custom" settings
speedwm has a patching system. It allows you to create a patch with your changes to options.h, options.mk, toggle.h and toggle.mk. To create a patch, simply make clean install once and then the docs folder will contain backups of your source code. If you perform changes to any of these four files, run make patch to create patches against the backups in docs and your modified files. Then once you're updating, do make patch_remove, git pull, make patch_install, and make clean install and all your settings will be there.
The only (obvious) problem with doing this is that eventually the backup files patches are being created against will be pretty old causing patches to no longer apply correctly. If this is the case you will need to create new patches and backups.
If this seems like more effort than it is worth, maintaining your own fork is always an option. This allows you to perform any options you want yourself. This however doesn't allow you to grab any updates so this should be your second choice.
## Additional note on autostart
If you wish to add autostart entries without recompiling, consider using $HOME/.config/speedwm-de/autostart.sh. This is a path added to autostart.h and you can fill it with anything you want.
Do note that it will NOT just run once. It will run every time you restart and start speedwm (signum 30 and 31 count as well).
To get around this, you may wrap stuff in a function in the script and have some way of checking if it has ran before. If it hasn't, call the function.
An alternative is to use the $HOME/.config/speedwm-de/autostart_once.sh path. This one is autostarted by speedwm_run and is therefore not hardcoded and not affected by speedwm restarting. Just like the previous autostart script, it does not exist so you need to create it.

View file

@ -18,7 +18,7 @@ static char *colors[][3] = {
[SchemeTitleSel] = { col_textsel, col_titlesel, NULL }, [SchemeTitleSel] = { col_textsel, col_titlesel, NULL },
[SchemeTitleHidden] = { col_titlesel, col_background, NULL }, [SchemeTitleHidden] = { col_titlesel, col_background, NULL },
[SchemeLayout] = { col_layouttext, col_layout, NULL }, [SchemeLayout] = { col_layouttext, col_layout, NULL },
[SchemeSystray] = { col_systray, col_systray, NULL }, [SchemeSystray] = { col_systray, col_systray, NULL },
/* text background window border /* text background window border
*/ */
}; };
@ -55,6 +55,8 @@ static unsigned int alphas[][3] = {
[SchemeLayout] = { OPAQUE, layoutopacity, layoutopacity }, [SchemeLayout] = { OPAQUE, layoutopacity, layoutopacity },
[SchemeStatus] = { OPAQUE, statusopacity, statusopacity }, [SchemeStatus] = { OPAQUE, statusopacity, statusopacity },
[SchemeBorderNorm] = { OPAQUE, normborderopacity, selborderopacity }, [SchemeBorderNorm] = { OPAQUE, normborderopacity, selborderopacity },
[SchemeBorderSel] = { OPAQUE, normborderopacity, selborderopacity },
[SchemeBorderUrg] = { OPAQUE, normborderopacity, selborderopacity },
[SchemeTagsNorm] = { tagselopacity, tagselopacity, tagnormopacity }, [SchemeTagsNorm] = { tagselopacity, tagselopacity, tagnormopacity },
[SchemeTagsSel] = { tagselopacity, tagselopacity, tagnormopacity }, [SchemeTagsSel] = { tagselopacity, tagselopacity, tagnormopacity },
[SchemeTagsUrg] = { tagselopacity, tagselopacity, tagnormopacity }, [SchemeTagsUrg] = { tagselopacity, tagselopacity, tagnormopacity },
@ -73,7 +75,7 @@ static char *tagsel[][2] = {
{ col_tag7_text, col_tag7 }, { col_tag7_text, col_tag7 },
{ col_tag8_text, col_tag8 }, { col_tag8_text, col_tag8 },
{ col_tag9_text, col_tag9 }, { col_tag9_text, col_tag9 },
/* Text Background */ /* Text Background */
}; };
/* Alpha for tags /* Alpha for tags

View file

@ -142,7 +142,9 @@
!! Deck layout !! Deck layout
- speedwm.layout.deck.count: 0 !! Enable deck count in the deck layout (0/1) - speedwm.layout.deck.count: 0 !! Enable deck count in the deck layout (0/1)
- speedwm.layout.deck.format: [%d] !! Format of the deck count where %d is the deck count (string)
!! Format of the deck count where %d is the deck count (string)
- speedwm.layout.deck.format: [%d] !
!! Dynamic Grid layout !! Dynamic Grid layout
@ -152,7 +154,9 @@
- speedwm.layout.monocle.clientcount: 0 !! Enable client count in the monocle layout (0/1) - speedwm.layout.monocle.clientcount: 0 !! Enable client count in the monocle layout (0/1)
- speedwm.layout.monocle.count: 0 !! Enable focused client and number of total clients in the monocle layout (0/1) - speedwm.layout.monocle.count: 0 !! Enable focused client and number of total clients in the monocle layout (0/1)
- speedwm.layout.monocle.format: [%d/%d] !! Format of the monocle count where %d is the monocle count (string)
!! Format of the monocle count where %d is the monocle count (string)
- speedwm.layout.monocle.format: [%d/%d]
!! mfact options !! mfact options
@ -180,10 +184,10 @@
!! Status options !! Status options
!! Text to print when no status bar is running !! Text to print when no status bar is running. Empty means nothing.
- speedwm.status.defaultstatus: - speedwm.status.defaultstatus:
!! Status bar script to run !! Status bar script to run
- speedwm.status.status: status - speedwm.status.status: status
- speedwm.status.statusallmons: 1 !! Display status text on all monitors (0/1) - speedwm.status.statusallmons: 1 !! Display status text on all monitors (0/1)

View file

@ -1,13 +1,25 @@
/* See LICENSE file for copyright and license details. */ /* This C file handles functions for drawing text, graphics, setting colorschemes and decoding UTF-8.
*
* draw.c is similar to drw.c in suckless dwm.
* See LICENSE file for copyright and license details. */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
/* include xft for drawing text */
#include <X11/Xft/Xft.h> #include <X11/Xft/Xft.h>
#include "drw.h" /* include draw header */
#include "util.h" #include "draw.h"
/* main functions */
#include "main.h"
/* toggle */
#include "toggle.h" #include "toggle.h"
/* imlib - for rendering window icons */
#if USEWINICON #if USEWINICON
#include <Imlib2.h> #include <Imlib2.h>
#endif #endif
@ -19,9 +31,13 @@ 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 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 utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
static const long utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF}; static const long utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
Clr transcheme[3];
unsigned int ew; unsigned int ew;
/* transition scheme for powerlines */
Clr transcheme[3];
/* decode utf byte */
static long static long
utf8decodebyte(const char c, size_t *i) utf8decodebyte(const char c, size_t *i)
{ {
@ -31,6 +47,7 @@ utf8decodebyte(const char c, size_t *i)
return 0; return 0;
} }
/* validate utf */
static size_t static size_t
utf8validate(long *u, size_t i) utf8validate(long *u, size_t i)
{ {
@ -41,6 +58,7 @@ utf8validate(long *u, size_t i)
return i; return i;
} }
/* decode utf */
static size_t static size_t
utf8decode(const char *c, long *u, size_t clen) utf8decode(const char *c, long *u, size_t clen)
{ {
@ -66,6 +84,7 @@ utf8decode(const char *c, long *u, size_t clen)
return len; return len;
} }
/* setup */
Drw * Drw *
drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap) drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap)
{ {
@ -89,6 +108,7 @@ drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h
return drw; return drw;
} }
/* resize window icon */
void void
drw_resize(Drw *drw, unsigned int w, unsigned int h) drw_resize(Drw *drw, unsigned int w, unsigned int h)
{ {
@ -109,6 +129,7 @@ drw_resize(Drw *drw, unsigned int w, unsigned int h)
#endif #endif
} }
/* drawing powerline arrows */
void void
drw_arrow(Drw *drw, int x, int y, unsigned int w, unsigned int h, int direction, int slash) drw_arrow(Drw *drw, int x, int y, unsigned int w, unsigned int h, int direction, int slash)
{ {
@ -140,6 +161,7 @@ drw_arrow(Drw *drw, int x, int y, unsigned int w, unsigned int h, int direction,
XFillPolygon(drw->dpy, drw->drawable, drw->gc, points, 3, Nonconvex, CoordModeOrigin); XFillPolygon(drw->dpy, drw->drawable, drw->gc, points, 3, Nonconvex, CoordModeOrigin);
} }
/* set transition color scheme for powerlines */
void void
drw_settrans(Drw *drw, Clr *psc, Clr *nsc) drw_settrans(Drw *drw, Clr *psc, Clr *nsc)
{ {
@ -149,6 +171,7 @@ drw_settrans(Drw *drw, Clr *psc, Clr *nsc)
} }
} }
/* free memory */
void void
drw_free(Drw *drw) drw_free(Drw *drw)
{ {
@ -195,6 +218,7 @@ xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
die("no font specified."); die("no font specified.");
} }
/* Workaround for the old libXft crash. */
#if USEXFTWORKAROUND #if USEXFTWORKAROUND
FcBool iscol; FcBool iscol;
if(FcPatternGetBool(xfont->pattern, FC_COLOR, 0, &iscol) == FcResultMatch && iscol) { if(FcPatternGetBool(xfont->pattern, FC_COLOR, 0, &iscol) == FcResultMatch && iscol) {
@ -394,12 +418,12 @@ drw_polygon(Drw *drw, int x, int y, int ow, int oh, int sw, int sh, const XPoint
XDrawLines(drw->dpy, drw->drawable, drw->gc, scaledpoints, npoints, CoordModeOrigin); XDrawLines(drw->dpy, drw->drawable, drw->gc, scaledpoints, npoints, CoordModeOrigin);
} }
/* function for drawing text */
int int
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert) drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert)
{ {
char buf[1024]; char buf[1024];
int ty; int ty;
//unsigned int ew;
XftDraw *d = NULL; XftDraw *d = NULL;
Fnt *usedfont, *curfont, *nextfont; Fnt *usedfont, *curfont, *nextfont;
size_t i, len; size_t i, len;
@ -495,6 +519,8 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
fcpattern = FcPatternDuplicate(drw->fonts->pattern); fcpattern = FcPatternDuplicate(drw->fonts->pattern);
FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset); FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset);
FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue); FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue);
/* add color bool (libxft workaround) */
#if USEXFTWORKAROUND #if USEXFTWORKAROUND
FcPatternAddBool(fcpattern, FC_COLOR, FcFalse); FcPatternAddBool(fcpattern, FC_COLOR, FcFalse);
#endif #endif
@ -525,6 +551,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
return x + (render ? w : 0); return x + (render ? w : 0);
} }
/* draw image */
#if USEWINICON #if USEWINICON
void void
drw_pic(Drw *drw, int x, int y, unsigned int w, unsigned int h, Picture pic) drw_pic(Drw *drw, int x, int y, unsigned int w, unsigned int h, Picture pic)
@ -535,6 +562,7 @@ drw_pic(Drw *drw, int x, int y, unsigned int w, unsigned int h, Picture pic)
} }
#endif #endif
/* map out area */
void void
drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h) drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h)
{ {
@ -568,6 +596,7 @@ drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w,
*h = font->h; *h = font->h;
} }
/* create cursor */
Cur * Cur *
drw_cur_create(Drw *drw, int shape) drw_cur_create(Drw *drw, int shape)
{ {
@ -581,6 +610,7 @@ drw_cur_create(Drw *drw, int shape)
return cur; return cur;
} }
/* free cursor */
void void
drw_cur_free(Drw *drw, Cur *cursor) drw_cur_free(Drw *drw, Cur *cursor)
{ {

View file

View file

@ -36,7 +36,7 @@
{ MODIFIER1|SHIFT|CONTROL, CHAIN, KEY, tag, {.ui = 1 << TAG } }, { MODIFIER1|SHIFT|CONTROL, CHAIN, KEY, tag, {.ui = 1 << TAG } },
/* Keybinds */ /* Keybinds */
static const Key keys[] = { static Key keys[] = {
/* modifier chain key key function argument */ /* modifier chain key key function argument */
/* Run keybinds */ /* Run keybinds */

View file

@ -50,21 +50,17 @@ tile(Monitor *m)
void void
monocle(Monitor *m) monocle(Monitor *m)
{ {
int oh, ov, ih, iv;
Client *c; Client *c;
unsigned int n = 0;
if (monocleclientcount && !monoclecount) { if (monocleclientcount && !monoclecount) {
unsigned int n = 0;
getgaps(m, &oh, &ov, &ih, &iv, &n);
for (c = m->clients; c; c = c->next) for (c = m->clients; c; c = c->next)
if (ISVISIBLE(c)) if (ISVISIBLE(c))
n++; n++;
if (n > 0) /* override layout symbol */ if (n > 0) /* override layout symbol */
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n); snprintf(m->ltsymbol, sizeof m->ltsymbol, monocleformat, n);
} }
for (c = m->stack; c && (!ISVISIBLE(c) || c->isfloating); c = c->snext); for (c = m->stack; c && (!ISVISIBLE(c) || c->isfloating); c = c->snext);
if (c && !c->isfloating) { if (c && !c->isfloating) {
XMoveWindow(dpy, c->win, m->wx, m->wy); XMoveWindow(dpy, c->win, m->wx, m->wy);

View file

@ -1,4 +1,7 @@
/* See LICENSE file for copyright and license details. */ /* This contains the code for ending speedwm, along with memory allocation and IPC support.
*
* See LICENSE file for copyright and license details.
*/
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -9,7 +12,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#endif #endif
#include "util.h" #include "main.h"
void void
die(const char *fmt, ...) die(const char *fmt, ...)
@ -51,23 +54,23 @@ normalizepath(const char *path, char **normal)
size_t newlen = 0; size_t newlen = 0;
while ((match = strchr(walk, '/'))) { while ((match = strchr(walk, '/'))) {
// Copy everything between match and walk /* copy everything between match and walk */
strncpy(*normal + newlen, walk, match - walk); strncpy(*normal + newlen, walk, match - walk);
newlen += match - walk; newlen += match - walk;
walk += match - walk; walk += match - walk;
// Skip all repeating slashes /* skip all repeating slashes */
while (*walk == '/') while (*walk == '/')
walk++; walk++;
// If not last character in path /* if not last character in path */
if (walk != path + len) if (walk != path + len)
(*normal)[newlen++] = '/'; (*normal)[newlen++] = '/';
} }
(*normal)[newlen++] = '\0'; (*normal)[newlen++] = '\0';
// Copy remaining path /* copy remaining path */
strcat(*normal, walk); strcat(*normal, walk);
newlen += strlen(walk); newlen += strlen(walk);
@ -84,19 +87,19 @@ parentdir(const char *path, char **parent)
normalizepath(path, &normal); normalizepath(path, &normal);
// Pointer to last '/' /* Pointer to last '/' */
if (!(walk = strrchr(normal, '/'))) { if (!(walk = strrchr(normal, '/'))) {
free(normal); free(normal);
return -1; return -1;
} }
// Get path up to last '/' /* get path up to last '/' */
size_t len = walk - normal; size_t len = walk - normal;
*parent = (char *)malloc((len + 1) * sizeof(char)); *parent = (char *)malloc((len + 1) * sizeof(char));
// Copy path up to last '/' /* copy path up to last '/' */
strncpy(*parent, normal, len); strncpy(*parent, normal, len);
// Add null char /* add null char */
(*parent)[len] = '\0'; (*parent)[len] = '\0';
free(normal); free(normal);
@ -116,21 +119,21 @@ mkdirp(const char *path)
walk = normal; walk = normal;
while (walk < normal + normallen + 1) { while (walk < normal + normallen + 1) {
// Get length from walk to next / /* get length from walk to next */
size_t n = strcspn(walk, "/"); size_t n = strcspn(walk, "/");
// Skip path / /* skip path */
if (n == 0) { if (n == 0) {
walk++; walk++;
continue; continue;
} }
// Length of current path segment /* length of current path segment */
size_t curpathlen = walk - normal + n; size_t curpathlen = walk - normal + n;
char curpath[curpathlen + 1]; char curpath[curpathlen + 1];
struct stat s; struct stat s;
// Copy path segment to stat /* copy path segment to stat */
strncpy(curpath, normal, curpathlen); strncpy(curpath, normal, curpathlen);
strcpy(curpath + curpathlen, ""); strcpy(curpath + curpathlen, "");
int res = stat(curpath, &s); int res = stat(curpath, &s);
@ -152,7 +155,7 @@ mkdirp(const char *path)
} }
} }
// Continue to next path segment /* continue to next path segment */
walk += n; walk += n;
} }

View file

@ -4,7 +4,7 @@
#define MIN(A, B) ((A) < (B) ? (A) : (B)) #define MIN(A, B) ((A) < (B) ? (A) : (B))
#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B)) #define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B))
#ifdef USEIPC #if USEIPC
#ifdef _DEBUG #ifdef _DEBUG
#define DEBUG(...) fprintf(stderr, __VA_ARGS__) #define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#else #else
@ -14,7 +14,7 @@
void die(const char *fmt, ...); void die(const char *fmt, ...);
void *ecalloc(size_t nmemb, size_t size); void *ecalloc(size_t nmemb, size_t size);
#ifdef USEIPC #if USEIPC
int normalizepath(const char *path, char **normal); int normalizepath(const char *path, char **normal);
int mkdirp(const char *path); int mkdirp(const char *path);
int parentdir(const char *path, char **parent); int parentdir(const char *path, char **parent);

10
mouse.h
View file

@ -5,6 +5,16 @@
* Once you're done with your edits, run 'make clean install'. * Once you're done with your edits, run 'make clean install'.
* *
* To disable all mouse binds, edit toggle.h. * To disable all mouse binds, edit toggle.h.
*
* ClkLtSymbol - Layout icon
* ClkWinTitle - Window title
* ClkStatusText - Status text
* ClkRootWin - Root window (background)
* ClkTagBar - Tags
*
* Button1 - Left click
* Button2 - Middle click
* Button3 - Right click
*/ */
/* Actions when the mouse clicks a part of the screen */ /* Actions when the mouse clicks a part of the screen */

View file

@ -66,8 +66,6 @@
* *
* Do note that settings in speedwmrc will override the settings in all of the headers (as long as the file is valid). * Do note that settings in speedwmrc will override the settings in all of the headers (as long as the file is valid).
* If you do not like this behavior, you may add "rm -f $HOME/.config/speedwm-de/speedwmrc" to autostart.sh which will make sure the speedwmrc options are not used. * If you do not like this behavior, you may add "rm -f $HOME/.config/speedwm-de/speedwmrc" to autostart.sh which will make sure the speedwmrc options are not used.
*
* Software options (#define) must be changed in this file though and recompiled using the 'make clean install' command.
* *
******************************************************/ ******************************************************/

151
speedwm.c
View file

@ -47,8 +47,8 @@
#include <kvm.h> #include <kvm.h>
#endif /* __OpenBSD */ #endif /* __OpenBSD */
#include "drw.h" #include "draw.h"
#include "util.h" #include "main.h"
/* macros */ /* macros */
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
@ -95,8 +95,11 @@
#define MWM_DECOR_BORDER (1 << 1) #define MWM_DECOR_BORDER (1 << 1)
#define MWM_DECOR_TITLE (1 << 3) #define MWM_DECOR_TITLE (1 << 3)
/* for compatibility with lines that use blw */
#define blw TEXTW(m->ltsymbol)
/* enums */ /* enums */
enum { CurNormal, CurResize, CurMove, CurResizeHorzArrow, CurResizeVertArrow, CurLast }; /* cursor */ enum { CurNormal, CurResize, CurMove, CurResizeHorzArrow, CurResizeVertArrow, CurLast }; /* cursor, CurLast must be last */
/* color schemes */ /* color schemes */
enum { SchemeBorderNorm, enum { SchemeBorderNorm,
@ -390,8 +393,8 @@ static Monitor *dirtomon(int dir);
#if USEMOUSE #if USEMOUSE
static void dragmfact(const Arg *arg); static void dragmfact(const Arg *arg);
#endif #endif
static void drawbar(Monitor *m); static void drawbaritems(Monitor *m);
static void drawbars(void); static void drawbar(void);
static int drawarrows(Monitor *m); static int drawarrows(Monitor *m);
#if USEROUNDCORNERS #if USEROUNDCORNERS
static void drawroundedcorners(Client *c); static void drawroundedcorners(Client *c);
@ -414,12 +417,12 @@ static Picture geticonprop(Window w, unsigned int *icw, unsigned int *ich);
#endif #endif
static int getrootptr(int *x, int *y); static int getrootptr(int *x, int *y);
static long getstate(Window w); static long getstate(Window w);
#if USESYSTRAY
static unsigned int getsystraywidth(); static unsigned int getsystraywidth();
static Monitor *systraytomon(Monitor *m);
#if USESYSTRAY
static void removesystrayicon(Client *i); static void removesystrayicon(Client *i);
static void resizebarwin(Monitor *m); static void resizebarwin(Monitor *m);
static void resizerequest(XEvent *e); static void resizerequest(XEvent *e);
static Monitor *systraytomon(Monitor *m);
static void updatesystray(void); static void updatesystray(void);
static void updatesystrayicongeom(Client *i, int w, int h); static void updatesystrayicongeom(Client *i, int w, int h);
static void updatesystrayiconstate(Client *i, XPropertyEvent *ev); static void updatesystrayiconstate(Client *i, XPropertyEvent *ev);
@ -662,7 +665,6 @@ static int screen;
static int tw, sh; /* X display screen geometry width, height */ static int tw, sh; /* X display screen geometry width, height */
static int bh; /* bar geometry */ static int bh; /* bar geometry */
static int plw; /* powerline geometry */ static int plw; /* powerline geometry */
/* implemented https://git.suckless.org/dwm/commit/5799dd1fca6576b662d299e210cd5933b29d502d.html */
static int unmanaged = 0; /* whether the window manager should manage the new window or not */ static int unmanaged = 0; /* whether the window manager should manage the new window or not */
static int lrpad; /* sum of left and right padding for text */ static int lrpad; /* sum of left and right padding for text */
static int vp; /* vertical padding for bar */ static int vp; /* vertical padding for bar */
@ -778,78 +780,10 @@ static int systraypinningfailfirst = 1;
#include "ipc.h" /* Include IPC */ #include "ipc.h" /* Include IPC */
#endif #endif
#include "text.h" /* Include tags and layouts */
static char *fontarray[] = { font1, font2, font3, fonts }; /* All fonts */ static char *fontarray[] = { font1, font2, font3, fonts }; /* All fonts */
/* Text for tags */
static char *tags[] = { text_tag1_empty,
text_tag2_empty, /* Tag 2 text (empty) */
text_tag3_empty, /* Tag 3 text (empty) */
text_tag4_empty, /* Tag 4 text (empty) */
text_tag5_empty, /* Tag 5 text (empty) */
text_tag6_empty, /* Tag 6 text (empty) */
text_tag7_empty, /* Tag 7 text (empty) */
text_tag8_empty, /* Tag 8 text (empty) */
text_tag9_empty, /* Tag 9 text (empty) */
};
/* Text for tags with windows open */
static char *usedtags[] = { text_tag1_used, /* Tag 1 text (used) */
text_tag2_used, /* Tag 2 text (used) */
text_tag3_used, /* Tag 3 text (used) */
text_tag4_used, /* Tag 4 text (used) */
text_tag5_used, /* Tag 5 text (used) */
text_tag6_used, /* Tag 6 text (used) */
text_tag7_used, /* Tag 7 text (used) */
text_tag8_used, /* Tag 8 text (used) */
text_tag9_used, /* Tag 9 text (used) */
};
/* Text for layouts */
static Layout layouts[] = {
#if LAYOUT_TILE
{ text_layout1, tile, },
#endif
/* floating layout (if no layout is available */
{ text_layout2, NULL, },
#if LAYOUT_MONOCLE
{ text_layout3, monocle, },
#endif
#if LAYOUT_GRID
{ text_layout4, grid },
#endif
#if LAYOUT_DECK
{ text_layout5, deck },
#endif
#if LAYOUT_CM
{ text_layout6, centeredmaster },
#endif
#if LAYOUT_CFM
{ text_layout7, centeredfloatingmaster },
#endif
#if LAYOUT_SPIRAL
{ text_layout8, spiral },
#endif
#if LAYOUT_DWINDLE
{ text_layout9, dwindle },
#endif
#if LAYOUT_BSTACK
{ text_layout10, bstack },
#endif
#if LAYOUT_BSTACKH
{ text_layout11, bstackhoriz },
#endif
#if LAYOUT_HGRID
{ text_layout12, horizgrid },
#endif
#if LAYOUT_DGRID
{ text_layout13, dynamicgrid },
#endif
#if LAYOUT_CUSTOM
{ text_layout14, custom },
#endif
{ NULL, NULL },
};
/* Rest of the IPC support */ /* Rest of the IPC support */
#if USEIPC #if USEIPC
#include "toggle/ipc-yajl.c" #include "toggle/ipc-yajl.c"
@ -1045,13 +979,13 @@ arrangemon(Monitor *m)
m->lt[m->sellt]->arrange(m); m->lt[m->sellt]->arrange(m);
} }
#if USEROUNDCORNERS #if USEROUNDCORNERS
if (roundedcorners) { if (roundedcorners) {
Client *c; Client *c;
for (c = nexttiled(m->clients); c; c = nexttiled(c->next)) for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
drawroundedcorners(c); drawroundedcorners(c);
} }
#endif #endif
} }
void void
@ -1284,13 +1218,8 @@ buttonpress(XEvent *e)
} else if (ev->x < x + TEXTW(selmon->ltsymbol) && !layoutposition && !selmon->isreset) /* right layout */ } else if (ev->x < x + TEXTW(selmon->ltsymbol) && !layoutposition && !selmon->isreset) /* right layout */
click = ClkLtSymbol; /* right layout */ click = ClkLtSymbol; /* right layout */
#if USESYSTRAY
else if (ev->x > selmon->ww - statusw + lrpad - 2 - getsystraywidth() && !hidestatus) { else if (ev->x > selmon->ww - statusw + lrpad - 2 - getsystraywidth() && !hidestatus) {
x = selmon->ww - statusw + lrpad - 2 * sp - getsystraywidth() - 2; x = selmon->ww - statusw + lrpad - 2 * sp - getsystraywidth() - 2;
#else
else if (ev->x > selmon->ww - statusw + lrpad - 2 && !hidestatus) {
x = selmon->ww - statusw + lrpad - 2 * sp - 2;
#endif
click = ClkStatusText; click = ClkStatusText;
char *text = rawstext; char *text = rawstext;
int i = -1; int i = -1;
@ -2040,11 +1969,7 @@ drawstatusbar(Monitor *m, int bh, char* stext) {
w += 2; /* 1px padding on both sides */ w += 2; /* 1px padding on both sides */
#if USESYSTRAY
ret = x = m->ww - w - 2 * sp - ((!hidesystray && m == systraytomon(m)) ? getsystraywidth() : 0); ret = x = m->ww - w - 2 * sp - ((!hidesystray && m == systraytomon(m)) ? getsystraywidth() : 0);
#else
ret = x = m->ww - w - 2 * sp;
#endif
drw_setscheme(drw, scheme[LENGTH(colors)]); drw_setscheme(drw, scheme[LENGTH(colors)]);
drw->scheme[ColFg] = scheme[SchemeStatus][ColFg]; drw->scheme[ColFg] = scheme[SchemeStatus][ColFg];
@ -2265,8 +2190,9 @@ dragmfact(const Arg *arg)
} }
#endif #endif
/* draw the bar items (such as status, tags, indicators, etc.) */
void void
drawbar(Monitor *m) drawbaritems(Monitor *m)
{ {
int x = 0, w = 0, tw = 0, scm; int x = 0, w = 0, tw = 0, scm;
int stw = 0; /* systray width */ int stw = 0; /* systray width */
@ -2304,11 +2230,7 @@ if(!hidesystray && m == systraytomon(m) && !systrayposition)
if (m == selmon || 1) { /* status is only drawn on selected monitor */ if (m == selmon || 1) { /* status is only drawn on selected monitor */
char *text, *s, ch; char *text, *s, ch;
if (!hidestatus) { if (!hidestatus) {
#if USESYSTRAY
tw = statusw = m->ww - drawstatusbar(m, bh, stext) - getsystraywidth(); tw = statusw = m->ww - drawstatusbar(m, bh, stext) - getsystraywidth();
#else
tw = statusw = m->ww - drawstatusbar(m, bh, stext);
#endif
} }
#if USESYSTRAY #if USESYSTRAY
resizebarwin(m); resizebarwin(m);
@ -2543,13 +2465,17 @@ resizebarwin(m);
#endif #endif
} }
/* draw the full bar
* arg 'selmon' = selected mon
* arg 'm' = all mons
*/
void void
drawbars(void) drawbar(void)
{ {
Monitor *m; Monitor *m;
for (m = mons; m; m = m->next) for (m = mons; m; m = m->next)
drawbar(m); drawbaritems(m);
} }
void void
@ -2582,7 +2508,7 @@ expose(XEvent *e)
XExposeEvent *ev = &e->xexpose; XExposeEvent *ev = &e->xexpose;
if (ev->count == 0 && (m = wintomon(ev->window))) { if (ev->count == 0 && (m = wintomon(ev->window))) {
drawbar(m); drawbaritems(m);
#if USESYSTRAY #if USESYSTRAY
if (m == selmon) if (m == selmon)
@ -2635,7 +2561,7 @@ focus(Client *c)
if (selmon->lt[selmon->sellt]->arrange == monocle) if (selmon->lt[selmon->sellt]->arrange == monocle)
arrangemon(selmon); arrangemon(selmon);
#endif #endif
drawbars(); drawbar();
} }
/* there are some notitle focus acquiring clients needing extra handling */ /* there are some notitle focus acquiring clients needing extra handling */
@ -2879,17 +2805,22 @@ getstate(Window w)
} }
#if USESYSTRAY
unsigned int unsigned int
getsystraywidth() getsystraywidth()
{ {
/* doing it this way allows us to clean up the code for drawing the bar */
#if USESYSTRAY
unsigned int w = 0; unsigned int w = 0;
Client *i; Client *i;
if(!hidesystray) if(!hidesystray)
for(i = systray->icons; i; w += i->w + systrayspacing, i = i->next) ; for(i = systray->icons; i; w += i->w + systrayspacing, i = i->next) ;
return w ? w + systrayspacing : 1; return w ? w + systrayspacing : 1;
#else
return 0;
#endif
} }
#if USESYSTRAY
void void
togglesystray() togglesystray()
{ {
@ -4429,20 +4360,20 @@ propertynotify(XEvent *e)
break; break;
case XA_WM_HINTS: case XA_WM_HINTS:
updatewmhints(c); updatewmhints(c);
drawbars(); drawbar();
break; break;
} }
if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) { if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
updatetitle(c); updatetitle(c);
updaterules(c); updaterules(c);
if (c == c->mon->sel && !hidetitle) if (c == c->mon->sel && !hidetitle)
drawbar(c->mon); drawbaritems(c->mon);
} }
#if USEWINICON #if USEWINICON
else if (ev->atom == netatom[NetWMIcon]) { else if (ev->atom == netatom[NetWMIcon]) {
updateicon(c); updateicon(c);
if (c == c->mon->sel) if (c == c->mon->sel)
drawbar(c->mon); drawbaritems(c->mon);
} }
#endif #endif
if (ev->atom == netatom[NetWMWindowType]) if (ev->atom == netatom[NetWMWindowType])
@ -4641,7 +4572,7 @@ restack(Monitor *m)
XEvent ev; XEvent ev;
XWindowChanges wc; XWindowChanges wc;
drawbar(m); drawbaritems(m);
if (!m->sel) if (!m->sel)
return; return;
if (m->sel->isfloating || !m->lt[m->sellt]->arrange) if (m->sel->isfloating || !m->lt[m->sellt]->arrange)
@ -5048,7 +4979,7 @@ setlayout(const Arg *arg)
if (selmon->sel) if (selmon->sel)
arrange(selmon); arrange(selmon);
else else
drawbar(selmon); drawbaritems(selmon);
} }
void void
@ -6058,9 +5989,9 @@ updatestatus(void)
} }
if (statusallmons) { if (statusallmons) {
for(m = mons; m; m = m->next) for(m = mons; m; m = m->next)
drawbar(m); drawbaritems(m);
} else { } else {
drawbar(selmon); drawbaritems(selmon);
} }
#if USESYSTRAY #if USESYSTRAY
@ -6541,9 +6472,11 @@ wintosystrayicon(Window w) {
for (i = systray->icons; i && i->win != w; i = i->next) ; for (i = systray->icons; i && i->win != w; i = i->next) ;
return i; return i;
} }
#endif
Monitor * Monitor *
systraytomon(Monitor *m) { systraytomon(Monitor *m) {
#if USESYSTRAY
Monitor *t; Monitor *t;
int i, n; int i, n;
if(!systraypinning) { if(!systraypinning) {
@ -6556,9 +6489,11 @@ systraytomon(Monitor *m) {
if(systraypinningfailfirst && n < systraypinning) if(systraypinningfailfirst && n < systraypinning)
return mons; return mons;
return t; return t;
} #else
return 0;
#endif #endif
/* doing this allows us to only have one instance of drawbar stuff */
}
Client * Client *
wintoclient(Window w) wintoclient(Window w)

41
status
View file

@ -22,6 +22,7 @@ SETMETHOD="speedwm -s" # Method used to set the status bar
SEPARATOR="❰" # Separator to use. Alternative separators: "❰", "<", "|" SEPARATOR="❰" # Separator to use. Alternative separators: "❰", "<", "|"
COLORFG=true # Color foreground (true/false) COLORFG=true # Color foreground (true/false)
COLORBG=false # Color background (true/false) COLORBG=false # Color background (true/false)
CLICKABLE=true # Enable clickability (Requires dwm with statuscmd or speedwm) (true/false)
CHARLIMIT=auto # Limit characters to CHARLIMIT. Enter false to not have a limit. Enter auto to use xdpyinfo. (num/auto/false) CHARLIMIT=auto # Limit characters to CHARLIMIT. Enter false to not have a limit. Enter auto to use xdpyinfo. (num/auto/false)
ITEM_ORDER="@2 @3 @11 @4 @1 @6 @8 @5 @9 @7 @10" # Item order. @1 means item 1, @6 means item 6 and so on. (text) ITEM_ORDER="@2 @3 @11 @4 @1 @6 @8 @5 @9 @7 @10" # Item order. @1 means item 1, @6 means item 6 and so on. (text)
@ -119,10 +120,31 @@ ITEM11_FULL_TEXT="Fully charged" # Text when fully charged (text)
######################################################################### #########################################################################
PRINT() { # set version
$SETMETHOD "$(printf "$ITEMS_TEXT")" if [ -e "/usr/share/speedwm/speedwm-version" ]; then
VER="$(cat /usr/share/speedwm/speedwm-version)"
else
VER="1.0"
fi
# set status
setstatus() {
$SETMETHOD "$@"
return
} }
# set loading status
setloading() {
$SETMETHOD "Loading"
return
}
# print data
PRINT() {
setstatus "$(printf "$ITEMS_TEXT")"
}
# set status2d compatible colors
SETCOLORS_CMD() { SETCOLORS_CMD() {
if [ "$COLORFG" = "true" ]; then if [ "$COLORFG" = "true" ]; then
FSETCOLORCMD1="^C1^" FSETCOLORCMD1="^C1^"
@ -166,6 +188,7 @@ case "$BINDIR" in
"") BINDIR=$(cat /usr/share/speedwm-bindir) ;; "") BINDIR=$(cat /usr/share/speedwm-bindir) ;;
esac esac
# remove old data
rm -f /tmp/itest rm -f /tmp/itest
rm -f /tmp/wstatus rm -f /tmp/wstatus
rm -f /tmp/iscelsius rm -f /tmp/iscelsius
@ -174,7 +197,7 @@ pkill "$(pgrep -x status | sed "s/$$//g")" # Prevent duplicates
mkdir -p $HOME/.config/speedwm-de/status mkdir -p $HOME/.config/speedwm-de/status
printf "Loaded speedwm status 0.3\n---\n" printf "Loaded speedwm status $VER\n---\n"
# Load config and create options if it does not exist # Load config and create options if it does not exist
LOADCONFIG() { LOADCONFIG() {
@ -186,6 +209,7 @@ else
printf "\n# Print options\nREFRESHDELAY=$REFRESHDELAY # How long delay in seconds between each reload (num)" >> $HOME/.config/speedwm-de/status/config printf "\n# Print options\nREFRESHDELAY=$REFRESHDELAY # How long delay in seconds between each reload (num)" >> $HOME/.config/speedwm-de/status/config
printf "\nSEPARATOR='$SEPARATOR' # Separator to use. Example separators: '❰', '<', '|'" >> $HOME/.config/speedwm-de/status/config printf "\nSEPARATOR='$SEPARATOR' # Separator to use. Example separators: '❰', '<', '|'" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM_ORDER='$ITEM_ORDER' # Item order. @1 means item 1, @6 means item 6 and so on. (text)" >> $HOME/.config/speedwm-de/status/config printf "\nITEM_ORDER='$ITEM_ORDER' # Item order. @1 means item 1, @6 means item 6 and so on. (text)" >> $HOME/.config/speedwm-de/status/config
printf "\nCLICKABLE=$CLICKABLE # Enable clickability (Requires dwm with statuscmd or speedwm) (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nCHARLIMIT=$CHARLIMIT # Limit characters to CHARLIMIT. Enter false to not have a limit. Enter auto to use xdpyinfo. (num/auto/false)" >> $HOME/.config/speedwm-de/status/config printf "\nCHARLIMIT=$CHARLIMIT # Limit characters to CHARLIMIT. Enter false to not have a limit. Enter auto to use xdpyinfo. (num/auto/false)" >> $HOME/.config/speedwm-de/status/config
printf "\n\n# Enable/Disable items\nENABLE_ITEM1=$ENABLE_ITEM1 # Enable RAM usage (true/false)" >> $HOME/.config/speedwm-de/status/config printf "\n\n# Enable/Disable items\nENABLE_ITEM1=$ENABLE_ITEM1 # Enable RAM usage (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nENABLE_ITEM2=$ENABLE_ITEM2 # Enable Time (HH:MM) (true/false)" >> $HOME/.config/speedwm-de/status/config printf "\nENABLE_ITEM2=$ENABLE_ITEM2 # Enable Time (HH:MM) (true/false)" >> $HOME/.config/speedwm-de/status/config
@ -270,7 +294,12 @@ PRINT_TEXT() {
ITEMCMD10="$FSETCOLORCMD9$BSETCOLORCMD9$ITEMCMD10" ITEMCMD10="$FSETCOLORCMD9$BSETCOLORCMD9$ITEMCMD10"
ITEMCMD11="$FSETCOLORCMD8$BSETCOLORCMD8$ITEMCMD11" ITEMCMD11="$FSETCOLORCMD8$BSETCOLORCMD8$ITEMCMD11"
ITEMS_TEXT="$(echo "$ITEM_ORDER" | sed "s|@10|\x10$ITEMCMD10|; s|@11|\x11$ITEMCMD11|; s|@1|\x01$ITEMCMD1|; s|@2|\x02$ITEMCMD2|; s|@3|\x03$ITEMCMD3|; s|@4|\x04$ITEMCMD4|; s|@5|\x05$ITEMCMD5|; s|@6|\x06$ITEMCMD6|; s|@7|\x07$ITEMCMD7|; s|@8|\x08$ITEMCMD8|; s|@9|\x09$ITEMCMD9|; s|%|%%|g")" # Clickability
if [ "$CLICKABLE" = "true" ]; then
ITEMS_TEXT="$(echo "$ITEM_ORDER" | sed "s|@10|\x10$ITEMCMD10|; s|@11|\x11$ITEMCMD11|; s|@1|\x01$ITEMCMD1|; s|@2|\x02$ITEMCMD2|; s|@3|\x03$ITEMCMD3|; s|@4|\x04$ITEMCMD4|; s|@5|\x05$ITEMCMD5|; s|@6|\x06$ITEMCMD6|; s|@7|\x07$ITEMCMD7|; s|@8|\x08$ITEMCMD8|; s|@9|\x09$ITEMCMD9|; s|%|%%|g")"
else
ITEMS_TEXT="$(echo "$ITEM_ORDER" | sed "s|@10|$ITEMCMD10|; s|@11|$ITEMCMD11|; s|@1|$ITEMCMD1|; s|@2|$ITEMCMD2|; s|@3|$ITEMCMD3|; s|@4|$ITEMCMD4|; s|@5|$ITEMCMD5|; s|@6|$ITEMCMD6|; s|@7|$ITEMCMD7|; s|@8|$ITEMCMD8|; s|@9|$ITEMCMD9|; s|%|%%|g")"
fi
# Auto-get character limit based on screen resolution # Auto-get character limit based on screen resolution
# This is pretty hacky, but it works as a default. # This is pretty hacky, but it works as a default.
@ -593,8 +622,8 @@ ITEM9() {
if [ "$data" != "" ]; then if [ "$data" != "" ]; then
echo "$SEPARATOR $ITEM9_ICON $data" echo "$SEPARATOR $ITEM9_ICON $data"
fi fi
fi
fi fi
fi
fi fi
fi fi
} }
@ -641,6 +670,8 @@ BASE() {
BASE BASE
} }
setloading
LOADCONFIG LOADCONFIG
SETCOLORS_CMD SETCOLORS_CMD
PRINT_TEXT PRINT_TEXT

View file

@ -9,6 +9,15 @@
* *
* As for the modules here, they are only compatible with the built-in status bar by default. * As for the modules here, they are only compatible with the built-in status bar by default.
* You may add support in your own bar, though. * You may add support in your own bar, though.
*
* Syntax: { "<command", <clicknum> },
*
* On click, the file /tmp/speedwm-button is created. In this file:
*
* 1 - Left click
* 2 - Middle click
* 3 - Right click
*
*/ */
static const StatusCmd statuscmds[] = { static const StatusCmd statuscmds[] = {
{ "module_ram", 1 }, { "module_ram", 1 },

71
text.h Normal file
View file

@ -0,0 +1,71 @@
/* Header for text, do not edit it. */
/* Text for tags */
static char *tags[] = { text_tag1_empty,
text_tag2_empty, /* Tag 2 text (empty) */
text_tag3_empty, /* Tag 3 text (empty) */
text_tag4_empty, /* Tag 4 text (empty) */
text_tag5_empty, /* Tag 5 text (empty) */
text_tag6_empty, /* Tag 6 text (empty) */
text_tag7_empty, /* Tag 7 text (empty) */
text_tag8_empty, /* Tag 8 text (empty) */
text_tag9_empty, /* Tag 9 text (empty) */
};
/* Text for tags with windows open */
static char *usedtags[] = { text_tag1_used, /* Tag 1 text (used) */
text_tag2_used, /* Tag 2 text (used) */
text_tag3_used, /* Tag 3 text (used) */
text_tag4_used, /* Tag 4 text (used) */
text_tag5_used, /* Tag 5 text (used) */
text_tag6_used, /* Tag 6 text (used) */
text_tag7_used, /* Tag 7 text (used) */
text_tag8_used, /* Tag 8 text (used) */
text_tag9_used, /* Tag 9 text (used) */
};
/* Text for layouts */
static Layout layouts[] = {
#if LAYOUT_TILE
{ text_layout1, tile, },
#endif
/* floating layout (if no layout is available */
{ text_layout2, NULL, },
#if LAYOUT_MONOCLE
{ text_layout3, monocle, },
#endif
#if LAYOUT_GRID
{ text_layout4, grid },
#endif
#if LAYOUT_DECK
{ text_layout5, deck },
#endif
#if LAYOUT_CM
{ text_layout6, centeredmaster },
#endif
#if LAYOUT_CFM
{ text_layout7, centeredfloatingmaster },
#endif
#if LAYOUT_SPIRAL
{ text_layout8, spiral },
#endif
#if LAYOUT_DWINDLE
{ text_layout9, dwindle },
#endif
#if LAYOUT_BSTACK
{ text_layout10, bstack },
#endif
#if LAYOUT_BSTACKH
{ text_layout11, bstackhoriz },
#endif
#if LAYOUT_HGRID
{ text_layout12, horizgrid },
#endif
#if LAYOUT_DGRID
{ text_layout13, dynamicgrid },
#endif
#if LAYOUT_CUSTOM
{ text_layout14, custom },
#endif
{ NULL, NULL },
};

View file

@ -3,7 +3,7 @@
#include <string.h> #include <string.h>
#include <sys/epoll.h> #include <sys/epoll.h>
#include "../util.h" #include "../main.h"
IPCClient * IPCClient *
ipc_client_new(int fd) ipc_client_new(int fd)

View file

@ -12,7 +12,7 @@
#include <yajl/yajl_gen.h> #include <yajl/yajl_gen.h>
#include <yajl/yajl_tree.h> #include <yajl/yajl_tree.h>
#include "../util.h" #include "../main.h"
#include "ipc-yajl.h" #include "ipc-yajl.h"
static struct sockaddr_un sockaddr; static struct sockaddr_un sockaddr;