diff --git a/Makefile b/Makefile index 8bf9dd8..392f4ab 100644 --- a/Makefile +++ b/Makefile @@ -87,7 +87,6 @@ install: all cp -f scripts/speedwm-swal ${DESTDIR}${PREFIX}/bin ; chmod +x ${DESTDIR}${PREFIX}/bin/speedwm-swal cp -f scripts/speedwm-screenshotutil ${DESTDIR}${PREFIX}/bin ; chmod +x ${DESTDIR}${PREFIX}/bin/speedwm-screenshotutil cp -f scripts/speedwm-virtualkeyboard ${DESTDIR}${PREFIX}/bin ; chmod +x ${DESTDIR}${PREFIX}/bin/speedwm-virtualkeyboard - cp -f scripts/speedwm-pdfopen ${DESTDIR}${PREFIX}/bin ; chmod +x ${DESTDIR}${PREFIX}/bin/speedwm-pdfopen cp -f scripts/speedwm-audioctrl ${DESTDIR}${PREFIX}/bin ; chmod +x ${DESTDIR}${PREFIX}/bin/speedwm-audioctrl cp -f scripts/speedwm-applist ${DESTDIR}${PREFIX}/bin ; chmod +x ${DESTDIR}${PREFIX}/bin/speedwm-applist cp -f scripts/speedwm-netctrl ${DESTDIR}${PREFIX}/bin ; chmod +x ${DESTDIR}${PREFIX}/bin/speedwm-netctrl @@ -124,7 +123,6 @@ uninstall: ${DESTDIR}${PREFIX}/bin/speedwm-btctrl \ ${DESTDIR}${PREFIX}/bin/speedwm-screenshotutil \ ${DESTDIR}${PREFIX}/bin/speedwm-virtualkeyboard \ - ${DESTDIR}${PREFIX}/bin/speedwm-pdfopen \ ${DESTDIR}${PREFIX}/bin/speedwm-core \ ${DESTDIR}${PREFIX}/bin/speedwm-dfmpeg \ ${DESTDIR}${PREFIX}/bin/speedwm-debug \ diff --git a/actions.h b/actions.h new file mode 100644 index 0000000..b5fef70 --- /dev/null +++ b/actions.h @@ -0,0 +1,90 @@ +/* speedwm actions + * + * This header is for configuring the actions and classes keybinds and rules use. + * These should be set using the '#define' but if you prefer you can use a char as well. + * + * Example of a valid #define: #define MYAWESOMEKEYBIND "myawesomescript" + * In this example, myawesomescript is the command that will run and MYAWESOMEKEYBIND is the define itself. + * + * You can use this define in a keybind (see keybinds.h) or in a rule (see rules.h). + * + * For example if you wanted to change icecat to firefox: + * #define BROWSER "icecat" -> #define BROWSER "firefox" + * + * You do not need to edit 'keybinds.h' or 'rules.h' because that's where the values we defined are actually used. + * Once you're done with your edits, run 'make clean install' to install it. + */ + +/* Software options + * Note that any software named "speedwm-*" is bundled with this build and does not need to be replaced unless you want to. + */ + +/* Terminal */ +#define TERMINAL "st -e " /* Terminal to use */ +#define TERMINAL_CLASS "st" /* Terminal to use for rules */ + +/* Web browser */ +#define BROWSER "icecat" /* Web browser to use */ +#define BROWSER_CLASS "Navigator" /* Web browser to use for rules */ + +/* System monitor */ +#define SYSTEMSTAT "htop" /* System stat viewer to use */ + +/* RSS reader */ +#define RSS "newsboat" /* RSS reader to use */ + +/* Chat client */ +#define CHAT "tmux new-session -A -D -s weechat $(which --skip-alias weechat)" /* Chat client to use */ +#define CHAT2 "iron" /* Second chat client (such as an IM) to use */ + +/* Music visualizer */ +#define VISUALIZER "~/.local/bin/vis || vis" /* Music visualizer to use */ + +/* Email client */ +#define EMAIL "aerc" /* Email client to use */ + +/* Text editor */ +#define EDITOR "nvim" /* Text editor to use */ + +/* Run actions */ +#define RUN "dmenu_run -l 0 -p 'Run:'" /* Run launcher */ +#define RUN_ALT "speedwm-applist" /* Alternative run launcher */ +#define RUN_DESKTOP "j4-dmenu-desktop --term=st --dmenu='dmenu -l 20 -p Open'" + +/* Screenshot actions */ +#define SCREENSHOT "speedwm-screenshotutil -s" /* How to take screenshots (Selection) */ +#define SCREENSHOT_FULL "speedwm-screenshotutil -f" /* How to take screenshots (Full screen) */ + +/* File manager */ +#define FILEMANAGER "vifmrun || vifm" /* File manager that will be used */ +#define FILEMANAGER_CLASS "vifmrun" /* File manager that will be used for rules */ + +/* Screen locker */ +#define LOCKER "slock" /* Screen locker that will be used */ + +/* Music actions */ +#define MUSIC "tmux new-session -A -D -s cmus $(which --skip-alias cmus)" /* Music player to use */ +#define KILLMUSIC "pkill cmus" /* Command to run when killing the music player */ +#define NEXTMUSIC "cmus-remote --next" /* Command to run when skipping to the next track */ +#define PREVMUSIC "cmus-remote --prev" /* Command to run when moving back to the previous track */ +#define UPMUSIC "cmus-remote --volume +3000" /* Command to run when increasing music volume */ +#define DOWNMUSIC "cmus-remote --volume -3000" /* Command to run when decreasing music volume */ +#define PAUSEMUSIC "cmus-remote --pause" /* Command to run when pausing the track */ + +/* PDF reader */ +#define PDF_CLASS "Zathura" /* PDF reader to use for rules */ + +/* Audio options */ +#define MIXER "speedwm-audioctrl -runmixer" /* Audio mixer to use */ +#define VOL_DOWN "speedwm-audioctrl -lower" /* Command to run when decreasing volume */ +#define VOL_UP "speedwm-audioctrl -raise" /* Command to run when increasing volume */ +#define VOL_MUTE "speedwm-audioctrl -mute" /* Command to run when muting volume */ + +/* Managers */ +#define CLIPBOARD "xclip" /* Clipboard to use */ +#define COMPOSITOR "picom --experimental-backends" /* Compositor to use */ +#define NETWORK "speedwm-netctrl" /* Network manager to use */ +#define KILLNETWORK "speedwm-netctrl disconnect" /* Command to run when disconnecting */ +#define BLUETOOTH "speedwm-btctrl" /* Bluetooth manager to use */ +#define NOTIFICATION "dunst" /* Notification daemon to use */ + diff --git a/docs/doc-05 b/docs/doc-05 index acf20fb..c6b873b 100644 --- a/docs/doc-05 +++ b/docs/doc-05 @@ -12,6 +12,7 @@ Instead, config.h is split into different parts to make it easier to edit. Inste - mouse.h for adding/removing mouse binds. - 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. diff --git a/keybinds.h b/keybinds.h index b2e62e1..26fdf96 100644 --- a/keybinds.h +++ b/keybinds.h @@ -7,17 +7,28 @@ * * Modifiers * - * MODIFIER1 is what you defined (in options.h, default is Super) - * MODIFIER2 is what you defined (in options.h, default is Alt) + * MODIFIER1 is what you defined below, default is Super) + * MODIFIER2 is what you defined below, default is Alt) * SHIFT is unless changed going to be your Shift key. * CONTROL is unless changed going to be your Control key. - * - * It is recommended that you avoid using 'MODIFIER2' (Mod1Mask) by itself because it can break software defined shortcuts. + * ALT unless changed is going to be your left Alt key. + * ALTR unless changed is going to be your right Alt key. + * SUPER unless changed is going to be your left Super (Windows/macOS Command) key. + * SUPERR unless changed is going to be your right Super (Windows/macOS Command) key. + * + * It is recommended that you avoid using 'MODIFIER2' (Mod1Mask/ALT) by itself because it can break software defined shortcuts. * * If you need help, see speedwm-help. * Once you're done with your edits, run 'make clean install'. */ +/* Modifier keys + * Mod4Mask | Super (Windows/command) key + * Mod1Mask | Alt key + */ +#define MODIFIER1 Mod4Mask +#define MODIFIER2 Mod1Mask + /* Tag related keybinds */ #define TAGKEYS(CHAIN,KEY,TAG) { MODIFIER1, CHAIN, KEY, view, {.ui = 1 << TAG } }, \ { MODIFIER1|SHIFT, CHAIN, KEY, previewtag, {.ui = TAG} }, \ @@ -39,14 +50,13 @@ static const Key keys[] = { { MODIFIER1|SHIFT, -1, XK_f, spawn, RCMD(TERMINAL FILEMANAGER) }, { MODIFIER1|SHIFT, -1, XK_w, spawn, RCMD(BROWSER) }, { MODIFIER1|SHIFT, -1, XK_o, spawn, RCMD("speedwm-dfmpeg") }, - { MODIFIER1|SHIFT, -1, XK_d, spawn, RCMD(TERMINAL "iron") }, + { MODIFIER1|SHIFT, -1, XK_d, spawn, RCMD(TERMINAL CHAT2) }, { MODIFIER1|SHIFT, -1, XK_t, spawn, RCMD(TERMINAL EDITOR) }, { MODIFIER1|SHIFT, -1, XK_a, spawn, RCMD(TERMINAL MIXER) }, { MODIFIER1|SHIFT, -1, XK_m, spawn, RCMD(TERMINAL MUSIC) }, { MODIFIER1, -1, XK_Tab, spawn, RCMD("speedwm-winnav") }, { MODIFIER1|SHIFT, -1, XK_x, spawn, RCMD(TERMINAL SYSTEMSTAT) }, { MODIFIER1|SHIFT, -1, XK_c, spawn, RCMD(TERMINAL CHAT) }, - { MODIFIER1|SHIFT, -1, XK_i, spawn, RCMD(OPENPDF) }, { MODIFIER1|SHIFT, -1, XK_Escape, spawn, RCMD("speedwm-shutdown") }, { MODIFIER1|SHIFT, -1, XK_u, spawn, RCMD(TERMINAL RSS) }, { MODIFIER1|SHIFT, -1, XK_r, spawn, RCMD(TERMINAL EMAIL) }, diff --git a/options.h b/options.h index 5ec631e..8d8ae6f 100644 --- a/options.h +++ b/options.h @@ -38,7 +38,8 @@ * * speedwm unlike dwm doesn't just have a single header, config.h but rather multiple. Below is a list of them * - * - If you were looking for the software options, colors, and other options, they can be found here in options.h + * - If you were looking for the software options, they can be found here in actions.h + * - If you were looking for colors, and other options, they can be found here in options.h * - If you were looking for the keybinds, they can be found in keybinds.h * - If you use another operating system such as OpenBSD, FreeBSD or Solaris (Not GNU/Linux), edit host.mk * - If you're looking to disable a feature, see toggle.h (Disabling features) and toggle.mk (Disabling libraries the features depend on) @@ -61,17 +62,6 @@ * I do not recommend that you attempt to use the patch coreutil as it is not likely to patch successfully. * There are however a few speedwm specific patches available on my Codeberg (https://codeberg.org/speedie/patches). These were created when I removed a feature that I decided was not worth keeping in. * - * -- Bindings -- - * - * This build comes with #defines for common software such as your web browser or terminal. - * If you wish to use a different browser for example, simply change the values. - * - * For example if you wanted to change icecat to firefox: - * #define BROWSER "icecat" -> #define BROWSER "firefox" - * - * You do not need to edit 'keybinds.h' or 'rules.h' because that's where the values we defined are actually used. - * Once you're done with your edits, run 'make clean install' to install it. - * * Alternatively, you can change some of these in ~/.config/speedwm-de/speedwmrc. * * Do note that settings in speedwmrc will override the settings in all of the headers (as long as the file is valid). @@ -81,61 +71,6 @@ * ******************************************************/ -/* Software options - * Note that any software named "speedwm-*" is bundled with this build and does not need to be replaced unless you want to. - */ -#define TERMINAL "st -e " /* Terminal to use */ -#define BROWSER "icecat" /* Web browser to use */ -#define SYSTEMSTAT "htop" /* System stat viewer to use */ -#define RSS "newsboat" /* RSS reader to use */ -#define PDF "zathura" /* PDF reader to use */ -#define MUSIC "tmux new-session -A -D -s cmus $(which --skip-alias cmus)" /* Music player to use */ -#define CHAT "tmux new-session -A -D -s weechat $(which --skip-alias weechat)" /* Chat client to use */ -#define VISUALIZER "~/.local/bin/vis || vis" /* Music visualizer to use */ -#define EMAIL "aerc" /* Email client to use */ -#define EDITOR "nvim" /* Text editor to use */ -#define RUN "dmenu_run -l 0 -p 'Run:'" /* Run launcher */ -#define RUN_ALT "speedwm-applist" /* Alternative run launcher */ -#define RUN_DESKTOP "j4-dmenu-desktop --term=st --dmenu='dmenu -l 20 -p Open'" -#define SCREENSHOT "speedwm-screenshotutil -s" /* How to take screenshots (Selection) */ -#define SCREENSHOT_FULL "speedwm-screenshotutil -f" /* How to take screenshots (Full screen) */ -#define FILEMANAGER "vifmrun || vifm" /* File manager that will be used */ -#define LOCKER "slock" /* Screen locker that will be used */ -#define OPENPDF "speedwm-pdfopen ~/Documents zathura || ~/Scripts/speedwm-pdfopen ~/Documents zathura" /* Command to run when listing and opening PDFs. */ -#define KILLMUSIC "pkill cmus" /* Command to run when killing the music player */ -#define NEXTMUSIC "cmus-remote --next" /* Command to run when skipping to the next track */ -#define PREVMUSIC "cmus-remote --prev" /* Command to run when moving back to the previous track */ -#define UPMUSIC "cmus-remote --volume +3000" /* Command to run when increasing music volume */ -#define DOWNMUSIC "cmus-remote --volume -3000" /* Command to run when decreasing music volume */ -#define PAUSEMUSIC "cmus-remote --pause" /* Command to run when pausing the track */ - -/* Software classes */ -#define TERMINAL_CLASS "st" /* Terminal to use for rules */ -#define BROWSER_CLASS "Navigator" /* Web browser to use for rules */ -#define PDF_CLASS "Zathura" /* PDF reader to use for rules */ -#define FILEMANAGER_CLASS "vifmrun" /* File manager that will be used for rules */ - -/* Audio options */ -#define MIXER "speedwm-audioctrl -runmixer" /* Audio mixer to use */ -#define VOL_DOWN "speedwm-audioctrl -lower" /* Command to run when decreasing volume */ -#define VOL_UP "speedwm-audioctrl -raise" /* Command to run when increasing volume */ -#define VOL_MUTE "speedwm-audioctrl -mute" /* Command to run when muting volume */ - -/* Modifier keys - * Mod4Mask | Super (Windows/command) key - * Mod1Mask | Alt key - */ -#define MODIFIER1 Mod4Mask -#define MODIFIER2 Mod1Mask - -/* Managers */ -#define CLIPBOARD "xclip" /* Clipboard to use */ -#define COMPOSITOR "picom --experimental-backends" /* Compositor to use */ -#define NETWORK "speedwm-netctrl" /* Network manager to use */ -#define KILLNETWORK "speedwm-netctrl disconnect" /* Command to run when disconnecting */ -#define BLUETOOTH "speedwm-btctrl" /* Bluetooth manager to use */ -#define NOTIFICATION "dunst" /* Notification daemon to use */ - /* Options * * If xrdb is installed, you can simply edit ~/.config/speedwm-de/speedwmrc instead of recompiling. @@ -217,9 +152,10 @@ static char status[] = "status"; /* Status bar to use, * * If you didn't do any changes to the source code, just run speedwm_run -r' * If you use Polybar, the default settings here will work, just set altbar to 1 and set altbarcmd to 'polybar &'. + * */ static char *altbarcmd = ""; -static int altbar = 0; /* 1 means use non-speedwm status bar */ +static int altbar = 0; /* Use alternative bar */ static char *altbarclass = "Polybar"; /* Alternate bar class name */ static char *alttrayname = "tray"; /* Polybar tray instance name */ @@ -277,9 +213,8 @@ static int hidesticky = 0; /* Hide sticky indicator (1) static int statusallmons = 1; /* Draw status bar on all monitors */ /* Layout options - */ - -/* Monocle layout */ + * + * Monocle layout */ static unsigned int monocleclientcount = 0; /* Display client count in the Monocle layout */ static unsigned int monoclecount = 0; /* Display focused client and number of total clients in the Monocle layout */ static char monocleformat[] = "[%d/%d]"; /* Format of the monocle count. Unsigned integer monoclecount must be set to 1 for this to be used. */ @@ -290,7 +225,7 @@ static char deckformat[] = "[%d]"; /* Format of the deck co /* Stair layout */ static unsigned int stairpx = 20; /* Depth of the stairs layout */ -static int stairdirection = 1; /* 0: Left-aligned, 1: Right-aligned */ +static int stairdirection = 1; /* Left-aligned, Right-aligned */ static int stairsamesize = 1; /* 1 means shrink all the staired windows to the same size */ /* Dynamic Grid layout */ @@ -301,9 +236,9 @@ static int resetlayout = 1; /* Reset layout when there is static int resetmfact = 1; /* Reset mfact when there is only one client visible */ static int resetgaps = 1; /* Reset gaps when there is only one client visible */ -/* Colors */ - -/* Bar colors */ +/* Colors + * + * Bar colors */ static char col_background[] = "#222222"; /* speedwm bar background and status background color */ static char col_title[] = "#222222"; /* speedwm taskbar background color */ @@ -400,6 +335,7 @@ static char *tags[] = { "1", /* Tag 1 text (empty) * "9", /* Tag 9 text (empty) */ }; +/* Text for tags with windows open */ static char *usedtags[] = { "[1]", /* Tag 1 text (occupied) */ "[2]", /* Tag 2 text (occupied) */ "[3]", /* Tag 3 text (occupied) */ @@ -411,7 +347,10 @@ static char *usedtags[] = { "[1]", /* Tag 1 text (occupied "[9]", /* Tag 9 text (occupied) */ }; -/* Icon misc */ +/* Icon misc options + * + * Sticky + */ static XPoint stickyicon[] = { {0,0}, /* Represents the icon as an array of vertices */ {4,0}, {4,8}, @@ -419,6 +358,7 @@ static XPoint stickyicon[] = { {0,0}, /* Represents the icon a {0,8}, {0,0}, }; + static XPoint stickyiconbb = {4,8}; /* Defines the bottom right corner of the polygon's bounding box (speeds up scaling) */ /* You have reached the end of the configuration file. diff --git a/scripts/speedwm-dm b/scripts/speedwm-dm index 8ca78fe..cc71909 100755 --- a/scripts/speedwm-dm +++ b/scripts/speedwm-dm @@ -21,7 +21,7 @@ TOPBAR=$(grep "barposition" options.h | grep "1" | awk '{ print $5 }') PADDING=$(grep "barpaddingv" options.h | grep "0" | awk '{ print $5 }') # Write the compositor to /usr/share/speedwm/compositor -COMPOSITOR=$(grep "define COMPOSITOR " options.h | awk '{ print $3 }' | sed 's/"//g') +COMPOSITOR=$(grep "define COMPOSITOR " actions.h | awk '{ print $3 }' | sed 's/"//g') # Status STATUS=$(grep "char status" options.h | awk '{ print $5 }' | sed 's/"//g; s/;//g') diff --git a/scripts/speedwm-pdfopen b/scripts/speedwm-pdfopen deleted file mode 100755 index beece8d..0000000 --- a/scripts/speedwm-pdfopen +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# speedwm-pdfopen -# list of pdfs for the user to open in dmenu. - -cd $1 - -case "$RUNLAUNCHER" in -"") RUNLAUNCHER=dmenu ;; -esac - -HAVE_GRID="true" -if [ -e "$HOME/.config/speedwm-de/global/config" ]; then - . $HOME/.config/speedwm-de/global/config -else - mkdir -p $HOME/.config/speedwm-de/global - printf "HAVE_GRID=$HAVE_GRID # Whether or not to use the Grid argument. If you do not have the dmenu grid patch, set this to false. Doing so will disable grid." > $HOME/.config/speedwm-de/global/config -fi - -if [ "$HAVE_GRID" = "true" ]; then - GRIDNUM="1" -fi - -if [ "$HAVE_GRID" = "true" ]; then - GRIDARG="-g" -fi - -SELPDF=$(ls -Ap1 *.pdf | $RUNLAUNCHER $GRIDARG $GRIDNUM -l 50 -p "What PDF do you want to open?") - -case "$SELPDF" in -"") exit 0 ;; -esac - -$2 "$1/$SELPDF" diff --git a/speedwm.c b/speedwm.c index 374cf4b..a303f82 100644 --- a/speedwm.c +++ b/speedwm.c @@ -674,6 +674,7 @@ static xcb_connection_t *xcon; #endif /* Configuration */ +#include "actions.h" /* Include #defines */ #include "options.h" /* Include options */ #if USESYSTRAY @@ -690,7 +691,7 @@ static int systraypinningfailfirst = 1; #define ALT Mod1Mask #define ALTR Mod3Mask #define SUPER Mod4Mask -#define SHIFTL Mod5Mask +#define SUPERR Mod5Mask /* Misc */ #define STATUSBAR status