From 894a672b848bc7951a3f9a12178302c3100c01d0 Mon Sep 17 00:00:00 2001 From: speedie Date: Sat, 29 Jul 2023 21:12:35 +0200 Subject: [PATCH] Fix default bindings --- .gitignore | 2 ++ libs/keybinds.h | 58 --------------------------------- libs/mouse.h | 31 ------------------ scripts/spmenu_make | 32 ------------------- spmenu.c | 78 +++++++++++++++++++++++++++++++++++++++++++-- 5 files changed, 78 insertions(+), 123 deletions(-) delete mode 100644 libs/keybinds.h delete mode 100644 libs/mouse.h diff --git a/.gitignore b/.gitignore index 9a616e0..89abf50 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,8 @@ spmenu *[.]PKGBUILD buildconf* build +*.ebuild +PKGBUILD libs/wl/wlr-layer-shell-unstable-v1-client-protocol.h libs/wl/wlr-layer-shell-unstable-v1-protocol.c diff --git a/libs/keybinds.h b/libs/keybinds.h deleted file mode 100644 index 47a4e4a..0000000 --- a/libs/keybinds.h +++ /dev/null @@ -1,58 +0,0 @@ -/* These are all your hardcoded keybinds. - * See LICENSE file for copyright and license details. - */ - -/* X11 hardcoded keybinds */ -#if USEX -static Key keys[] = { - { -1, 0, XK_Return, selectitem, {.i = +1 } }, - { -1, Shift, XK_Return, selectitem, {0} }, - { -1, Ctrl, XK_Return, markitem, {0} }, - { -1, 0, XK_Tab, complete, {0} }, - { -1, Ctrl, XK_v, paste, {.i = 2 } }, - { -1, 0, XK_BackSpace, backspace, {0} }, - { -1, Ctrl, XK_BackSpace, deleteword, {0} }, - { -1, Ctrl|Shift, XK_p, setprofile, {0} }, - { -1, 0, XK_Print, screenshot, {0} }, - { -1, Ctrl, XK_equal, setimgsize, {.i = +10 } }, - { -1, Ctrl, XK_minus, setimgsize, {.i = -10 } }, - { -1, 0, XK_k, moveup, {0} }, - { -1, 0, XK_j, movedown, {0} }, - { -1, 0, XK_h, moveleft, {0} }, - { -1, 0, XK_l, moveright, {0} }, - { -1, Ctrl, XK_u, moveup, {.i = 5 } }, - { -1, Ctrl, XK_d, movedown, {.i = 5 } }, - { -1, Shift, XK_h, viewhist, {0} }, - { -1, 0, XK_Escape, quit, {0} }, - { -1, Ctrl, XK_p, navhistory, {.i = -1 } }, - { -1, Ctrl, XK_n, navhistory, {.i = +1 } }, -}; -#endif - -/* Wayland hardcoded keybinds */ -#if USEWAYLAND -static WlKey wl_keys[] = { - { -1, WL_None, XKB_KEY_Return, selectitem, {.i = +1 } }, - { -1, WL_Shift, XKB_KEY_Return, selectitem, {0} }, - { -1, WL_Ctrl, XKB_KEY_Return, markitem, {0} }, - { -1, WL_None, XKB_KEY_Tab, complete, {0} }, - { -1, WL_Ctrl, XKB_KEY_v, paste, {.i = 2 } }, - { -1, WL_None, XKB_KEY_BackSpace, backspace, {0} }, - { -1, WL_Ctrl, XKB_KEY_BackSpace, deleteword, {0} }, - { -1, WL_CtrlShift, XKB_KEY_p, setprofile, {0} }, - { -1, WL_None, XKB_KEY_Print, screenshot, {0} }, - { -1, WL_Ctrl, XKB_KEY_equal, setimgsize, {.i = +10 } }, - { -1, WL_Ctrl, XKB_KEY_minus, setimgsize, {.i = -10 } }, - { -1, WL_None, XKB_KEY_k, moveup, {0} }, - { -1, WL_None, XKB_KEY_j, movedown, {0} }, - { -1, WL_None, XKB_KEY_h, moveleft, {0} }, - { -1, WL_None, XKB_KEY_l, moveright, {0} }, - { -1, WL_Ctrl, XKB_KEY_u, moveup, {.i = 5 } }, - { -1, WL_Ctrl, XKB_KEY_d, movedown, {.i = 5 } }, - { -1, WL_Shift, XKB_KEY_h, viewhist, {0} }, - { -1, WL_None, XKB_KEY_Escape, quit, {0} }, - { -1, WL_Ctrl, XKB_KEY_p, navhistory, {.i = -1 } }, - { -1, WL_Ctrl, XKB_KEY_n, navhistory, {.i = +1 } }, - -}; -#endif diff --git a/libs/mouse.h b/libs/mouse.h deleted file mode 100644 index 76602aa..0000000 --- a/libs/mouse.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Mouse bindings - * See LICENSE file for copyright and license details. - */ - -/* Only applies to X11 */ -#if USEX -static Mouse buttons[] = { - { ClickInput, Button1, clear, {0} }, - { ClickPrompt, Button1, clear, {0} }, - { ClickMode, Button1, switchmode, {0} }, - { ClickNumber, Button1, viewhist, {0} }, - { ClickItem, Button1, selecthover, {0} }, - { ClickItem, Button2, markhover, {0} }, - { ClickNone, Button5, movenext, {0} }, - { ClickNone, Button4, moveprev, {0} }, -}; -#endif - -/* Only applies to Wayland */ -#if USEWAYLAND -static WlMouse wl_buttons[] = { - { ClickInput, WL_Left, clear, {0} }, - { ClickPrompt, WL_Left, clear, {0} }, - { ClickMode, WL_Left, switchmode, {0} }, - { ClickNumber, WL_Left, viewhist, {0} }, - { ClickItem, WL_Left, selecthover, {0} }, - { ClickItem, WL_Right, markhover, {0} }, - { ClickNone, WL_Down, movenext, {0} }, - { ClickNone, WL_Up, moveprev, {0} }, -}; -#endif diff --git a/scripts/spmenu_make b/scripts/spmenu_make index 9c439cd..fddbc1b 100755 --- a/scripts/spmenu_make +++ b/scripts/spmenu_make @@ -58,35 +58,6 @@ docs() { fi } -kblist() { -grep "{ " "$1" | \ -grep -v "[*]" | \ -sed "s/{.i = //g; s/{.c = //g; s/{.f = //g; s/{0} }/0/g; s/ } }//g; s/,//g; s/{ //g; s/^\s*//g; s/XK_//g; s/|/+/g" > /tmp/data - -cat << EOF > /tmp/wipdata -| Mode | Modifier | Key | Function | Argument | -| :----------------- | :----------------- | :----------------- | :----------------- | :----------------- | -EOF - -i=1 - -while true; do - len="$(grep -c "" /tmp/data)" - mode="$(printf '%-18s' "$(sed -n ${i},${i}p /tmp/data | awk '{ print $1 }')")" - mod="$(printf '%-18s' "$(sed -n ${i},${i}p /tmp/data | awk '{ print $2 }')")" - key="$(printf '%-18s' "$(sed -n ${i},${i}p /tmp/data | awk '{ print $3 }')")" - func="$(printf '%-18s' "$(sed -n ${i},${i}p /tmp/data | awk '{ print $4 }')")" - arg="$(printf '%-18s' "$(sed -n ${i},${i}p /tmp/data | awk '{ print $5 }')")" -cat << EOF >> /tmp/wipdata -| $mode | $mod | $key | $func | $arg | -EOF - [ "$i" = "$len" ] && break - i=$((i+1)) -done -cat /tmp/wipdata -rm -f /tmp/wipdata /tmp/data -} - headers() { [ ! -x "$(command -v wayland-scanner)" ] && printf "wayland-scanner must be installed for this action.\n" && exit 1 @@ -366,7 +337,6 @@ $0 install Install spmenu $0 clean Remove tarballs and pacman packages $0 dist Create a distro package for spmenu $0 arglist Create an argument list for spmenu based on spmenu -h output -$0 kblist Create a keybind list in markdown column format based on keybinds.h $0 pkg_arch Create a Arch package for spmenu $0 pkg_gentoo Create a Gentoo package for spmenu $0 theme Create a theme for spmenu based on 18 colors @@ -382,7 +352,6 @@ main() { "clean") action="clean" ;; "dist") action="dist" ;; "arglist") action="arglist" ;; - "kblist") action="kblist" ;; "pkg_arch") action="arch" ;; "pkg_gentoo") action="gentoo" ;; "help") action="help" ;; @@ -408,7 +377,6 @@ main() { "arch") gen_arch_pkg ;; "gentoo") gen_gentoo_pkg ;; "theme") generate_theme "$2" ;; - "kblist") kblist "libs/keybinds.h" ;; "help") help ;; "arglist") gen_arg_list ;; "dist") gen_pkg ;; diff --git a/spmenu.c b/spmenu.c index e41b9bb..0be6b42 100644 --- a/spmenu.c +++ b/spmenu.c @@ -271,11 +271,85 @@ static size_t listsize; // user configuration #include "libs/options.h" -#include "libs/keybinds.h" -#include "libs/mouse.h" static char *fonts[] = { font }; +#if USEX +static Key keys[] = { + { -1, 0, XK_Return, selectitem, {.i = +1 } }, + { -1, Shift, XK_Return, selectitem, {0} }, + { -1, Ctrl, XK_Return, markitem, {0} }, + { -1, 0, XK_Tab, complete, {0} }, + { -1, Ctrl, XK_v, paste, {.i = 2 } }, + { -1, 0, XK_BackSpace, backspace, {0} }, + { -1, Ctrl, XK_BackSpace, deleteword, {0} }, + { -1, Ctrl|Shift, XK_p, setprofile, {0} }, + { -1, 0, XK_Print, screenshot, {0} }, + { -1, Ctrl, XK_equal, setimgsize, {.i = +10 } }, + { -1, Ctrl, XK_minus, setimgsize, {.i = -10 } }, + { -1, 0, XK_Up, moveup, {0} }, + { -1, 0, XK_Down, movedown, {0} }, + { -1, 0, XK_Left, moveleft, {0} }, + { -1, 0, XK_Right, moveright, {0} }, + { -1, Ctrl, XK_u, moveup, {.i = 5 } }, + { -1, Ctrl, XK_d, movedown, {.i = 5 } }, + { -1, Shift, XK_h, viewhist, {0} }, + { -1, 0, XK_Escape, quit, {0} }, + { -1, Ctrl, XK_p, navhistory, {.i = -1 } }, + { -1, Ctrl, XK_n, navhistory, {.i = +1 } }, +}; +#endif +#if USEWAYLAND +static WlKey wl_keys[] = { + { -1, WL_None, XKB_KEY_Return, selectitem, {.i = +1 } }, + { -1, WL_Shift, XKB_KEY_Return, selectitem, {0} }, + { -1, WL_Ctrl, XKB_KEY_Return, markitem, {0} }, + { -1, WL_None, XKB_KEY_Tab, complete, {0} }, + { -1, WL_Ctrl, XKB_KEY_v, paste, {.i = 2 } }, + { -1, WL_None, XKB_KEY_BackSpace, backspace, {0} }, + { -1, WL_Ctrl, XKB_KEY_BackSpace, deleteword, {0} }, + { -1, WL_CtrlShift, XKB_KEY_p, setprofile, {0} }, + { -1, WL_None, XKB_KEY_Print, screenshot, {0} }, + { -1, WL_Ctrl, XKB_KEY_equal, setimgsize, {.i = +10 } }, + { -1, WL_Ctrl, XKB_KEY_minus, setimgsize, {.i = -10 } }, + { -1, WL_None, XKB_KEY_Up, moveup, {0} }, + { -1, WL_None, XKB_KEY_Down, movedown, {0} }, + { -1, WL_None, XKB_KEY_Left, moveleft, {0} }, + { -1, WL_None, XKB_KEY_Right, moveright, {0} }, + { -1, WL_Ctrl, XKB_KEY_u, moveup, {.i = 5 } }, + { -1, WL_Ctrl, XKB_KEY_d, movedown, {.i = 5 } }, + { -1, WL_Shift, XKB_KEY_h, viewhist, {0} }, + { -1, WL_None, XKB_KEY_Escape, quit, {0} }, + { -1, WL_Ctrl, XKB_KEY_p, navhistory, {.i = -1 } }, + { -1, WL_Ctrl, XKB_KEY_n, navhistory, {.i = +1 } }, + +}; +#endif +#if USEX +static Mouse buttons[] = { + { ClickInput, Button1, clear, {0} }, + { ClickPrompt, Button1, clear, {0} }, + { ClickMode, Button1, switchmode, {0} }, + { ClickNumber, Button1, viewhist, {0} }, + { ClickItem, Button1, selecthover, {0} }, + { ClickItem, Button2, markhover, {0} }, + { ClickNone, Button5, movenext, {0} }, + { ClickNone, Button4, moveprev, {0} }, +}; +#endif +#if USEWAYLAND +static WlMouse wl_buttons[] = { + { ClickInput, WL_Left, clear, {0} }, + { ClickPrompt, WL_Left, clear, {0} }, + { ClickMode, WL_Left, switchmode, {0} }, + { ClickNumber, WL_Left, viewhist, {0} }, + { ClickItem, WL_Left, selecthover, {0} }, + { ClickItem, WL_Right, markhover, {0} }, + { ClickNone, WL_Down, movenext, {0} }, + { ClickNone, WL_Up, moveprev, {0} }, +}; +#endif + // color array #include "libs/colors.h"