From f66fd1cefe0c21c16b56d48ddd9e88a6e84f03bc Mon Sep 17 00:00:00 2001 From: Andreev Gregory <1@example.com> Date: Tue, 4 Mar 2025 14:55:33 +0300 Subject: [PATCH] my first config attempt --- .gitignore | 2 +- Makefile | 5 +++-- config.def.h | 58 ++++++++++++++++++++++++++++++++---------------- dwm_random_bg.sh | 19 ++++++++++++++++ 4 files changed, 62 insertions(+), 22 deletions(-) create mode 100755 dwm_random_bg.sh diff --git a/.gitignore b/.gitignore index 6afe14e..38f06f1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ dwm *.o *.orig config.h - +transient diff --git a/Makefile b/Makefile index 3f26804..86d612d 100644 --- a/Makefile +++ b/Makefile @@ -25,15 +25,16 @@ clean: dist: clean mkdir -p dwm-${VERSION} cp -R LICENSE Makefile README config.def.h config.mk\ - dwm.1 drw.h util.h ${SRC} dwm.png transient.c dwm-${VERSION} + dwm.1 drw.h util.h dwm_random_bg.sh ${SRC} dwm.png transient.c dwm-${VERSION} tar -cf dwm-${VERSION}.tar dwm-${VERSION} gzip dwm-${VERSION}.tar rm -rf dwm-${VERSION} install: all mkdir -p ${DESTDIR}${PREFIX}/bin - cp -f dwm ${DESTDIR}${PREFIX}/bin + cp -f dwm dwm_random_bg.sh ${DESTDIR}${PREFIX}/bin chmod 755 ${DESTDIR}${PREFIX}/bin/dwm + chmod 755 ${DESTDIR}${PREFIX}/bin/dwm_random_bg.sh mkdir -p ${DESTDIR}${MANPREFIX}/man1 sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1 chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1 diff --git a/config.def.h b/config.def.h index 9efa774..0b42df7 100644 --- a/config.def.h +++ b/config.def.h @@ -1,5 +1,24 @@ /* See LICENSE file for copyright and license details. */ +#include +#include + +/* Function to toggle between the two layouts */ +void toggle_keyboard_layout(const Arg* arg) { + XkbStateRec state; + if (XkbGetState(dpy, XkbUseCoreKbd, &state) != Success) { + fprintf(stderr, "Failed to get keyboard state\n"); + return; + } + /* Toggle: if current group is 0 (English), switch to 1 (Russian), and vice versa */ + unsigned int newGroup = (state.group == 0) ? 1 : 0; + if (XkbLockGroup(dpy, XkbUseCoreKbd, newGroup) != True) { + fprintf(stderr, "Failed to toggle keyboard layout\n"); + } +} + +// Normal config.def.h continues. I just added some of my own functions + /* appearance */ static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ @@ -7,15 +26,10 @@ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ static const char *fonts[] = { "monospace:size=10" }; static const char dmenufont[] = "monospace:size=10"; -static const char col_gray1[] = "#222222"; -static const char col_gray2[] = "#444444"; -static const char col_gray3[] = "#bbbbbb"; -static const char col_gray4[] = "#eeeeee"; -static const char col_cyan[] = "#005577"; static const char *colors[][3] = { /* fg bg border */ - [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, - [SchemeSel] = { col_gray4, col_cyan, col_cyan }, + [SchemeNorm] = { "#eeeeee", "#222222", "#111111" }, + [SchemeSel] = { "#ffffff", "#e00000", "#e00000" }, }; /* tagging */ @@ -45,7 +59,7 @@ static const Layout layouts[] = { }; /* key definitions */ -#define MODKEY Mod1Mask +#define MODKEY Mod4Mask #define TAGKEYS(KEY,TAG) \ { MODKEY, KEY, view, {.ui = 1 << TAG} }, \ { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ @@ -57,28 +71,34 @@ static const Layout layouts[] = { /* commands */ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ -static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; +//static const char *dmenucmd_old[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; static const char *termcmd[] = { "st", NULL }; +static const char *flexcmd[]= {"st", "-g", "115x29", "-e", "sh", "-c", "neofetch; sleep 100", NULL}; +static const char *dmenucmd[] = {"dmenu_run.sh", NULL}; +static const char* termtmuxzshcmd[] = {"st", "-e", "tmux", "new-session", "zsh", NULL}; static const Key keys[] = { /* modifier key function argument */ - { MODKEY, XK_p, spawn, {.v = dmenucmd } }, - { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, + { MODKEY, XK_space, toggle_keyboard_layout, {0} }, + { MODKEY, XK_r, spawn, {.v = dmenucmd } }, + { MODKEY|ControlMask, XK_Return, spawn, {.v = termcmd } }, + { MODKEY, XK_Return, spawn, {.v = termtmuxzshcmd } }, + { MODKEY|ControlMask, XK_n, spawn, {.v = flexcmd } }, { MODKEY, XK_b, togglebar, {0} }, - { MODKEY, XK_j, focusstack, {.i = +1 } }, - { MODKEY, XK_k, focusstack, {.i = -1 } }, + { MODKEY, XK_k, focusstack, {.i = +1 } }, + { MODKEY, XK_l, focusstack, {.i = -1 } }, { MODKEY, XK_i, incnmaster, {.i = +1 } }, { MODKEY, XK_d, incnmaster, {.i = -1 } }, - { MODKEY, XK_h, setmfact, {.f = -0.05} }, - { MODKEY, XK_l, setmfact, {.f = +0.05} }, - { MODKEY, XK_Return, zoom, {0} }, + { MODKEY, XK_j, setmfact, {.f = -0.05} }, + { MODKEY, XK_semicolon , setmfact, {.f = +0.05} }, + { MODKEY|ControlMask, XK_Return, zoom, {0} }, { MODKEY, XK_Tab, view, {0} }, - { MODKEY|ShiftMask, XK_c, killclient, {0} }, + { MODKEY|Mod1Mask , XK_c, killclient, {0} }, { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, - { MODKEY, XK_space, setlayout, {0} }, - { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, + //{ MODKEY, XK_space, setlayout, {0} }, + //{ MODKEY|ShiftMask, XK_space, togglefloating, {0} }, { MODKEY, XK_0, view, {.ui = ~0 } }, { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, { MODKEY, XK_comma, focusmon, {.i = -1 } }, diff --git a/dwm_random_bg.sh b/dwm_random_bg.sh new file mode 100755 index 0000000..db7468e --- /dev/null +++ b/dwm_random_bg.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# Directory containing wallpapers +WALLPAPER_DIR="$HOME/.config/suckless_desktop/wallpaper" + +# Find all .png, .jpg, and .jpwg files (case-insensitive) +files=( $(find "$WALLPAPER_DIR" -type f \( -iname "*.png" -o -iname "*.jpg" -o -iname "*.jpwg" \)) ) + +# Check if we found any wallpapers +if [ ${#files[@]} -eq 0 ]; then + echo "No wallpaper files found in $WALLPAPER_DIR." + exit 1 +fi + +# Choose a random file from the array +RANDOM_FILE="${files[RANDOM % ${#files[@]}]}" + +# Set the chosen file as the wallpaper using xwallpaper +xwallpaper --zoom "$RANDOM_FILE" +