From 5569f969b034e32da03656ec6813ab4542ad7038 Mon Sep 17 00:00:00 2001 From: speedie Date: Thu, 20 Oct 2022 15:29:43 +0200 Subject: [PATCH] changes to codebase so i can maintain it easier --- Makefile | 8 +- README.md | 408 ---------------------------------------- colors.h | 6 +- docs/example.Xresources | 12 +- drw.c => draw.c | 40 +++- drw.h => draw.h | 0 keybinds.h | 2 +- layouts.c | 10 +- util.c => main.c | 33 ++-- util.h => main.h | 4 +- mouse.h | 10 + options.h | 2 - speedwm.c | 151 +++++---------- status | 41 +++- statusbar.h | 9 + text.h | 71 +++++++ toggle/ipc-cli.c | 2 +- toggle/ipc.c | 2 +- 18 files changed, 247 insertions(+), 564 deletions(-) delete mode 100644 README.md rename drw.c => draw.c (94%) rename drw.h => draw.h (100%) rename util.c => main.c (81%) rename util.h => main.h (95%) create mode 100644 text.h diff --git a/Makefile b/Makefile index 4e5c487..18c822d 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ include options.mk include host.mk include toggle.mk -SRC = drw.c speedwm.c util.c +SRC = draw.c speedwm.c main.c OBJ = ${SRC:.c=.o} ifdef USEIPC @@ -36,7 +36,7 @@ speedwm-msg: toggle/ipc-speedwm-msg.o endif clean: - rm -f speedwm ${OBJ} speedwm-${VERSION}.tar.gz + rm -f speedwm *.o speedwm-${VERSION}.tar.gz rm -f speedwm-msg echo "Cleaned!" @@ -49,7 +49,7 @@ dist: clean rm -rf speedwm-${VERSION} speedwm-msg install: all - @echo speedwm build options: + @echo speedwm ${VERSION} build options: @echo "CFLAGS = [${CFLAGS}]" @echo "LDFLAGS = [${LDFLAGS}]" @echo "CC = [${CC}]" @@ -86,6 +86,8 @@ install: all ./scripts/speedwm-compatcheck make modules_install [ -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: cp -f modules/module_* ${DESTDIR}${PREFIX}/bin diff --git a/README.md b/README.md deleted file mode 100644 index d722e9c..0000000 --- a/README.md +++ /dev/null @@ -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 (Left click) | Switch to tag - - 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: " 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 - -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=" to your .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. \ No newline at end of file diff --git a/colors.h b/colors.h index c39a395..aa9a473 100644 --- a/colors.h +++ b/colors.h @@ -18,7 +18,7 @@ static char *colors[][3] = { [SchemeTitleSel] = { col_textsel, col_titlesel, NULL }, [SchemeTitleHidden] = { col_titlesel, col_background, NULL }, [SchemeLayout] = { col_layouttext, col_layout, NULL }, - [SchemeSystray] = { col_systray, col_systray, NULL }, + [SchemeSystray] = { col_systray, col_systray, NULL }, /* text background window border */ }; @@ -55,6 +55,8 @@ static unsigned int alphas[][3] = { [SchemeLayout] = { OPAQUE, layoutopacity, layoutopacity }, [SchemeStatus] = { OPAQUE, statusopacity, statusopacity }, [SchemeBorderNorm] = { OPAQUE, normborderopacity, selborderopacity }, + [SchemeBorderSel] = { OPAQUE, normborderopacity, selborderopacity }, + [SchemeBorderUrg] = { OPAQUE, normborderopacity, selborderopacity }, [SchemeTagsNorm] = { tagselopacity, tagselopacity, tagnormopacity }, [SchemeTagsSel] = { tagselopacity, tagselopacity, tagnormopacity }, [SchemeTagsUrg] = { tagselopacity, tagselopacity, tagnormopacity }, @@ -73,7 +75,7 @@ static char *tagsel[][2] = { { col_tag7_text, col_tag7 }, { col_tag8_text, col_tag8 }, { col_tag9_text, col_tag9 }, - /* Text Background */ + /* Text Background */ }; /* Alpha for tags diff --git a/docs/example.Xresources b/docs/example.Xresources index 7de803e..60f3fe7 100644 --- a/docs/example.Xresources +++ b/docs/example.Xresources @@ -142,7 +142,9 @@ !! Deck layout - 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 @@ -152,7 +154,9 @@ - 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.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 @@ -180,10 +184,10 @@ !! 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: -!! Status bar script to run + !! Status bar script to run - speedwm.status.status: status - speedwm.status.statusallmons: 1 !! Display status text on all monitors (0/1) diff --git a/drw.c b/draw.c similarity index 94% rename from drw.c rename to draw.c index d9b4437..79e588f 100644 --- a/drw.c +++ b/draw.c @@ -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 #include #include #include + +/* include xft for drawing text */ #include -#include "drw.h" -#include "util.h" +/* include draw header */ +#include "draw.h" + +/* main functions */ +#include "main.h" + +/* toggle */ #include "toggle.h" + +/* imlib - for rendering window icons */ #if USEWINICON #include #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 long utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000}; static const long utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF}; -Clr transcheme[3]; + unsigned int ew; +/* transition scheme for powerlines */ +Clr transcheme[3]; + +/* decode utf byte */ static long utf8decodebyte(const char c, size_t *i) { @@ -31,6 +47,7 @@ utf8decodebyte(const char c, size_t *i) return 0; } +/* validate utf */ static size_t utf8validate(long *u, size_t i) { @@ -41,6 +58,7 @@ utf8validate(long *u, size_t i) return i; } +/* decode utf */ static size_t utf8decode(const char *c, long *u, size_t clen) { @@ -66,6 +84,7 @@ utf8decode(const char *c, long *u, size_t clen) return len; } +/* setup */ Drw * 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; } +/* resize window icon */ void 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 } +/* drawing powerline arrows */ void 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); } +/* set transition color scheme for powerlines */ void drw_settrans(Drw *drw, Clr *psc, Clr *nsc) { @@ -149,6 +171,7 @@ drw_settrans(Drw *drw, Clr *psc, Clr *nsc) } } +/* free memory */ void drw_free(Drw *drw) { @@ -195,6 +218,7 @@ xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern) die("no font specified."); } + /* Workaround for the old libXft crash. */ #if USEXFTWORKAROUND FcBool 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); } +/* function for drawing text */ int 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]; int ty; - //unsigned int ew; XftDraw *d = NULL; Fnt *usedfont, *curfont, *nextfont; 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); FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset); FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue); + + /* add color bool (libxft workaround) */ #if USEXFTWORKAROUND FcPatternAddBool(fcpattern, FC_COLOR, FcFalse); #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); } +/* draw image */ #if USEWINICON void 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 +/* map out area */ void 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; } +/* create cursor */ Cur * drw_cur_create(Drw *drw, int shape) { @@ -581,6 +610,7 @@ drw_cur_create(Drw *drw, int shape) return cur; } +/* free cursor */ void drw_cur_free(Drw *drw, Cur *cursor) { diff --git a/drw.h b/draw.h similarity index 100% rename from drw.h rename to draw.h diff --git a/keybinds.h b/keybinds.h index 5319ca0..354bb33 100644 --- a/keybinds.h +++ b/keybinds.h @@ -36,7 +36,7 @@ { MODIFIER1|SHIFT|CONTROL, CHAIN, KEY, tag, {.ui = 1 << TAG } }, /* Keybinds */ -static const Key keys[] = { +static Key keys[] = { /* modifier chain key key function argument */ /* Run keybinds */ diff --git a/layouts.c b/layouts.c index 9efffd5..23000ad 100644 --- a/layouts.c +++ b/layouts.c @@ -50,21 +50,17 @@ tile(Monitor *m) void monocle(Monitor *m) { - int oh, ov, ih, iv; Client *c; + unsigned int n = 0; if (monocleclientcount && !monoclecount) { - unsigned int n = 0; - - getgaps(m, &oh, &ov, &ih, &iv, &n); - for (c = m->clients; c; c = c->next) if (ISVISIBLE(c)) n++; 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); if (c && !c->isfloating) { XMoveWindow(dpy, c->win, m->wx, m->wy); diff --git a/util.c b/main.c similarity index 81% rename from util.c rename to main.c index df03024..363d95e 100644 --- a/util.c +++ b/main.c @@ -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 #include #include @@ -9,7 +12,7 @@ #include #endif -#include "util.h" +#include "main.h" void die(const char *fmt, ...) @@ -51,23 +54,23 @@ normalizepath(const char *path, char **normal) size_t newlen = 0; while ((match = strchr(walk, '/'))) { - // Copy everything between match and walk + /* copy everything between match and walk */ strncpy(*normal + newlen, walk, match - walk); newlen += match - walk; walk += match - walk; - // Skip all repeating slashes + /* skip all repeating slashes */ while (*walk == '/') walk++; - // If not last character in path + /* if not last character in path */ if (walk != path + len) (*normal)[newlen++] = '/'; } (*normal)[newlen++] = '\0'; - // Copy remaining path + /* copy remaining path */ strcat(*normal, walk); newlen += strlen(walk); @@ -84,19 +87,19 @@ parentdir(const char *path, char **parent) normalizepath(path, &normal); - // Pointer to last '/' + /* Pointer to last '/' */ if (!(walk = strrchr(normal, '/'))) { free(normal); return -1; } - // Get path up to last '/' + /* get path up to last '/' */ size_t len = walk - normal; *parent = (char *)malloc((len + 1) * sizeof(char)); - // Copy path up to last '/' + /* copy path up to last '/' */ strncpy(*parent, normal, len); - // Add null char + /* add null char */ (*parent)[len] = '\0'; free(normal); @@ -116,21 +119,21 @@ mkdirp(const char *path) walk = normal; while (walk < normal + normallen + 1) { - // Get length from walk to next / + /* get length from walk to next */ size_t n = strcspn(walk, "/"); - // Skip path / + /* skip path */ if (n == 0) { walk++; continue; } - // Length of current path segment + /* length of current path segment */ size_t curpathlen = walk - normal + n; char curpath[curpathlen + 1]; struct stat s; - // Copy path segment to stat + /* copy path segment to stat */ strncpy(curpath, normal, curpathlen); strcpy(curpath + curpathlen, ""); 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; } diff --git a/util.h b/main.h similarity index 95% rename from util.h rename to main.h index 8378b5d..f8f4657 100644 --- a/util.h +++ b/main.h @@ -4,7 +4,7 @@ #define MIN(A, B) ((A) < (B) ? (A) : (B)) #define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B)) -#ifdef USEIPC +#if USEIPC #ifdef _DEBUG #define DEBUG(...) fprintf(stderr, __VA_ARGS__) #else @@ -14,7 +14,7 @@ void die(const char *fmt, ...); void *ecalloc(size_t nmemb, size_t size); -#ifdef USEIPC +#if USEIPC int normalizepath(const char *path, char **normal); int mkdirp(const char *path); int parentdir(const char *path, char **parent); diff --git a/mouse.h b/mouse.h index d77eb87..4f687e4 100644 --- a/mouse.h +++ b/mouse.h @@ -5,6 +5,16 @@ * Once you're done with your edits, run 'make clean install'. * * 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 */ diff --git a/options.h b/options.h index 58f3a01..bb5ab31 100644 --- a/options.h +++ b/options.h @@ -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). * 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. * ******************************************************/ diff --git a/speedwm.c b/speedwm.c index 3d1c6a8..cf095f5 100644 --- a/speedwm.c +++ b/speedwm.c @@ -47,8 +47,8 @@ #include #endif /* __OpenBSD */ -#include "drw.h" -#include "util.h" +#include "draw.h" +#include "main.h" /* macros */ #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) @@ -95,8 +95,11 @@ #define MWM_DECOR_BORDER (1 << 1) #define MWM_DECOR_TITLE (1 << 3) +/* for compatibility with lines that use blw */ +#define blw TEXTW(m->ltsymbol) + /* enums */ -enum { CurNormal, CurResize, CurMove, CurResizeHorzArrow, CurResizeVertArrow, CurLast }; /* cursor */ +enum { CurNormal, CurResize, CurMove, CurResizeHorzArrow, CurResizeVertArrow, CurLast }; /* cursor, CurLast must be last */ /* color schemes */ enum { SchemeBorderNorm, @@ -390,8 +393,8 @@ static Monitor *dirtomon(int dir); #if USEMOUSE static void dragmfact(const Arg *arg); #endif -static void drawbar(Monitor *m); -static void drawbars(void); +static void drawbaritems(Monitor *m); +static void drawbar(void); static int drawarrows(Monitor *m); #if USEROUNDCORNERS static void drawroundedcorners(Client *c); @@ -414,12 +417,12 @@ static Picture geticonprop(Window w, unsigned int *icw, unsigned int *ich); #endif static int getrootptr(int *x, int *y); static long getstate(Window w); -#if USESYSTRAY static unsigned int getsystraywidth(); +static Monitor *systraytomon(Monitor *m); +#if USESYSTRAY static void removesystrayicon(Client *i); static void resizebarwin(Monitor *m); static void resizerequest(XEvent *e); -static Monitor *systraytomon(Monitor *m); static void updatesystray(void); static void updatesystrayicongeom(Client *i, int w, int h); 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 bh; /* bar 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 lrpad; /* sum of left and right padding for text */ static int vp; /* vertical padding for bar */ @@ -778,78 +780,10 @@ static int systraypinningfailfirst = 1; #include "ipc.h" /* Include IPC */ #endif +#include "text.h" /* Include tags and layouts */ + 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 */ #if USEIPC #include "toggle/ipc-yajl.c" @@ -1045,13 +979,13 @@ arrangemon(Monitor *m) m->lt[m->sellt]->arrange(m); } -#if USEROUNDCORNERS + #if USEROUNDCORNERS if (roundedcorners) { Client *c; for (c = nexttiled(m->clients); c; c = nexttiled(c->next)) drawroundedcorners(c); } -#endif + #endif } void @@ -1284,13 +1218,8 @@ buttonpress(XEvent *e) } else if (ev->x < x + TEXTW(selmon->ltsymbol) && !layoutposition && !selmon->isreset) /* right layout */ click = ClkLtSymbol; /* right layout */ - #if USESYSTRAY else if (ev->x > selmon->ww - statusw + lrpad - 2 - getsystraywidth() && !hidestatus) { 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; char *text = rawstext; int i = -1; @@ -2040,11 +1969,7 @@ drawstatusbar(Monitor *m, int bh, char* stext) { w += 2; /* 1px padding on both sides */ -#if USESYSTRAY 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->scheme[ColFg] = scheme[SchemeStatus][ColFg]; @@ -2265,8 +2190,9 @@ dragmfact(const Arg *arg) } #endif +/* draw the bar items (such as status, tags, indicators, etc.) */ void -drawbar(Monitor *m) +drawbaritems(Monitor *m) { int x = 0, w = 0, tw = 0, scm; 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 */ char *text, *s, ch; if (!hidestatus) { -#if USESYSTRAY tw = statusw = m->ww - drawstatusbar(m, bh, stext) - getsystraywidth(); -#else - tw = statusw = m->ww - drawstatusbar(m, bh, stext); -#endif } #if USESYSTRAY resizebarwin(m); @@ -2543,13 +2465,17 @@ resizebarwin(m); #endif } +/* draw the full bar + * arg 'selmon' = selected mon + * arg 'm' = all mons + */ void -drawbars(void) +drawbar(void) { Monitor *m; for (m = mons; m; m = m->next) - drawbar(m); + drawbaritems(m); } void @@ -2582,7 +2508,7 @@ expose(XEvent *e) XExposeEvent *ev = &e->xexpose; if (ev->count == 0 && (m = wintomon(ev->window))) { - drawbar(m); + drawbaritems(m); #if USESYSTRAY if (m == selmon) @@ -2635,7 +2561,7 @@ focus(Client *c) if (selmon->lt[selmon->sellt]->arrange == monocle) arrangemon(selmon); #endif - drawbars(); + drawbar(); } /* there are some notitle focus acquiring clients needing extra handling */ @@ -2879,17 +2805,22 @@ getstate(Window w) } -#if USESYSTRAY unsigned int getsystraywidth() { +/* doing it this way allows us to clean up the code for drawing the bar */ +#if USESYSTRAY unsigned int w = 0; Client *i; if(!hidesystray) for(i = systray->icons; i; w += i->w + systrayspacing, i = i->next) ; return w ? w + systrayspacing : 1; +#else + return 0; +#endif } +#if USESYSTRAY void togglesystray() { @@ -4429,20 +4360,20 @@ propertynotify(XEvent *e) break; case XA_WM_HINTS: updatewmhints(c); - drawbars(); + drawbar(); break; } if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) { updatetitle(c); updaterules(c); if (c == c->mon->sel && !hidetitle) - drawbar(c->mon); + drawbaritems(c->mon); } #if USEWINICON else if (ev->atom == netatom[NetWMIcon]) { updateicon(c); if (c == c->mon->sel) - drawbar(c->mon); + drawbaritems(c->mon); } #endif if (ev->atom == netatom[NetWMWindowType]) @@ -4641,7 +4572,7 @@ restack(Monitor *m) XEvent ev; XWindowChanges wc; - drawbar(m); + drawbaritems(m); if (!m->sel) return; if (m->sel->isfloating || !m->lt[m->sellt]->arrange) @@ -5048,7 +4979,7 @@ setlayout(const Arg *arg) if (selmon->sel) arrange(selmon); else - drawbar(selmon); + drawbaritems(selmon); } void @@ -6058,9 +5989,9 @@ updatestatus(void) } if (statusallmons) { for(m = mons; m; m = m->next) - drawbar(m); + drawbaritems(m); } else { - drawbar(selmon); + drawbaritems(selmon); } #if USESYSTRAY @@ -6541,9 +6472,11 @@ wintosystrayicon(Window w) { for (i = systray->icons; i && i->win != w; i = i->next) ; return i; } +#endif Monitor * systraytomon(Monitor *m) { +#if USESYSTRAY Monitor *t; int i, n; if(!systraypinning) { @@ -6556,9 +6489,11 @@ systraytomon(Monitor *m) { if(systraypinningfailfirst && n < systraypinning) return mons; return t; -} - +#else + return 0; #endif + /* doing this allows us to only have one instance of drawbar stuff */ +} Client * wintoclient(Window w) diff --git a/status b/status index d9942d7..cdf1f2b 100755 --- a/status +++ b/status @@ -22,6 +22,7 @@ SETMETHOD="speedwm -s" # Method used to set the status bar SEPARATOR="❰" # Separator to use. Alternative separators: "❰", "<", "|" COLORFG=true # Color foreground (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) 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() { - $SETMETHOD "$(printf "$ITEMS_TEXT")" +# set version +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() { if [ "$COLORFG" = "true" ]; then FSETCOLORCMD1="^C1^" @@ -166,6 +188,7 @@ case "$BINDIR" in "") BINDIR=$(cat /usr/share/speedwm-bindir) ;; esac +# remove old data rm -f /tmp/itest rm -f /tmp/wstatus rm -f /tmp/iscelsius @@ -174,7 +197,7 @@ pkill "$(pgrep -x status | sed "s/$$//g")" # Prevent duplicates 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 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 "\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 "\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 "\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 @@ -270,7 +294,12 @@ PRINT_TEXT() { ITEMCMD10="$FSETCOLORCMD9$BSETCOLORCMD9$ITEMCMD10" 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 # This is pretty hacky, but it works as a default. @@ -593,8 +622,8 @@ ITEM9() { if [ "$data" != "" ]; then echo "$SEPARATOR $ITEM9_ICON $data" fi - fi fi + fi fi fi } @@ -641,6 +670,8 @@ BASE() { BASE } +setloading + LOADCONFIG SETCOLORS_CMD PRINT_TEXT diff --git a/statusbar.h b/statusbar.h index a74778f..6fc611c 100644 --- a/statusbar.h +++ b/statusbar.h @@ -9,6 +9,15 @@ * * 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. + * + * Syntax: { " }, + * + * 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[] = { { "module_ram", 1 }, diff --git a/text.h b/text.h new file mode 100644 index 0000000..efb6e16 --- /dev/null +++ b/text.h @@ -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 }, +}; diff --git a/toggle/ipc-cli.c b/toggle/ipc-cli.c index 016030d..bdd4c1a 100644 --- a/toggle/ipc-cli.c +++ b/toggle/ipc-cli.c @@ -3,7 +3,7 @@ #include #include -#include "../util.h" +#include "../main.h" IPCClient * ipc_client_new(int fd) diff --git a/toggle/ipc.c b/toggle/ipc.c index 21c7544..e306ba5 100644 --- a/toggle/ipc.c +++ b/toggle/ipc.c @@ -12,7 +12,7 @@ #include #include -#include "../util.h" +#include "../main.h" #include "ipc-yajl.h" static struct sockaddr_un sockaddr;