diff --git a/.config/dwm/autostart.sh b/.config/dwm/autostart.sh index 7f4f808..3e1f583 100755 --- a/.config/dwm/autostart.sh +++ b/.config/dwm/autostart.sh @@ -1,8 +1,5 @@ #!/bin/bash -# Load top bar (Optional) -#dwmblocks & - # Network applet #connman-gtk --tray & nm-applet & @@ -28,5 +25,8 @@ sleep 5 && nitrogen --head=0 --set-scaled ${wallpaper_path} ; nitrogen --head=1 # Clipboard (Diodon) diodon & +# Status bar +~/.config/dwm/scripts/status_bar.sh & + # Load Conky sleep 10 && conky -c ~/.config/conky/conkyrc_dwm & diff --git a/.config/dwm/dwmblocks/Makefile b/.config/dwm/dwmblocks/Makefile deleted file mode 100644 index 8b3a30e..0000000 --- a/.config/dwm/dwmblocks/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -PREFIX ?= /usr/local -CC ?= cc - -output: dwmblocks.c blocks.def.h blocks.h - ${CC} `pkg-config --cflags x11 --libs x11` dwmblocks.c -o dwmblocks -blocks.h: - cp blocks.def.h $@ - - -clean: - rm -f *.o *.gch dwmblocks -install: output - mkdir -p $(DESTDIR)$(PREFIX)/bin - install -m 0755 dwmblocks $(DESTDIR)$(PREFIX)/bin/dwmblocks -uninstall: - rm -f $(DESTDIR)$(PREFIX)/bin/dwmblocks diff --git a/.config/dwm/dwmblocks/blocks.def.h b/.config/dwm/dwmblocks/blocks.def.h deleted file mode 100644 index 9c22d68..0000000 --- a/.config/dwm/dwmblocks/blocks.def.h +++ /dev/null @@ -1,11 +0,0 @@ -//Modify this file to change what commands output to your statusbar, and recompile using the make command. -static const Block blocks[] = { - /*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/ - {"Mem:", "free -h | awk '/^Mem/ { print $3\"/\"$2 }' | sed s/i//g", 30, 0}, - - {"", "date '+%b %d (%a) %I:%M%p'", 5, 0}, -}; - -//sets delimeter between status commands. NULL character ('\0') means no delimeter. -static char delim[] = " | "; -static unsigned int delimLen = 5; diff --git a/.config/dwm/dwmblocks/blocks.h b/.config/dwm/dwmblocks/blocks.h deleted file mode 100644 index f5abf01..0000000 --- a/.config/dwm/dwmblocks/blocks.h +++ /dev/null @@ -1,13 +0,0 @@ -static const Block blocks[] = { -// Icon Command Update Interval Update Signal - { " ", "~/.config/dwm/scripts/checkUpdates.sh", 1800, 0 }, - { " ", "~/.config/dwm/scripts/kernel_version.sh", 60, 0 }, - { " ", "~/.config/dwm/scripts/cpu_info.sh", 2, 0 }, - { " ", "~/.config/dwm/scripts/mem_info.sh", 5, 0 }, - { " ", "~/.config/dwm/scripts/get_volume.sh", 2, 0 }, - { "", "date '+ %d/%m/%Y %H:%M'", 5, 0 }, -}; - -// Sets delimeter between status commands. NULL character ('\0') means no delimeter. -static char delim[] = " "; -static unsigned int delimLen = 5; diff --git a/.config/dwm/dwmblocks/dwmblocks.c b/.config/dwm/dwmblocks/dwmblocks.c deleted file mode 100644 index 5abd10d..0000000 --- a/.config/dwm/dwmblocks/dwmblocks.c +++ /dev/null @@ -1,184 +0,0 @@ -#include -#include -#include -#include -#include -#include -#ifdef __OpenBSD__ -#define SIGPLUS SIGUSR1+1 -#define SIGMINUS SIGUSR1-1 -#else -#define SIGPLUS SIGRTMIN -#define SIGMINUS SIGRTMIN -#endif -#define LENGTH(X) (sizeof(X) / sizeof (X[0])) -#define CMDLENGTH 50 -#define MIN( a, b ) ( ( a < b) ? a : b ) -#define STATUSLENGTH (LENGTH(blocks) * CMDLENGTH + 1) - -typedef struct { - char* icon; - char* command; - unsigned int interval; - unsigned int signal; -} Block; -#ifndef __OpenBSD__ -void dummysighandler(int num); -#endif -void sighandler(int num); -void getcmds(int time); -void getsigcmds(unsigned int signal); -void setupsignals(); -void sighandler(int signum); -int getstatus(char *str, char *last); -void setroot(); -void statusloop(); -void termhandler(); - - -#include "blocks.h" - -static Display *dpy; -static int screen; -static Window root; -static char statusbar[LENGTH(blocks)][CMDLENGTH] = {0}; -static char statusstr[2][STATUSLENGTH]; -static int statusContinue = 1; -static void (*writestatus) () = setroot; - -//opens process *cmd and stores output in *output -void getcmd(const Block *block, char *output) -{ - strcpy(output, block->icon); - char *cmd = block->command; - FILE *cmdf = popen(cmd,"r"); - if (!cmdf) - return; - char c; - int i = strlen(block->icon); - fgets(output+i, CMDLENGTH-i-delimLen, cmdf); - i = strlen(output); - if (delim[0] != '\0' && --i) - strncpy(output+i, delim, delimLen); - else - output[i++] = '\0'; - pclose(cmdf); -} - -void getcmds(int time) -{ - const Block* current; - for (unsigned int i = 0; i < LENGTH(blocks); i++) - { - current = blocks + i; - if ((current->interval != 0 && time % current->interval == 0) || time == -1) - getcmd(current,statusbar[i]); - } -} - -void getsigcmds(unsigned int signal) -{ - const Block *current; - for (unsigned int i = 0; i < LENGTH(blocks); i++) - { - current = blocks + i; - if (current->signal == signal) - getcmd(current,statusbar[i]); - } -} - -void setupsignals() -{ -#ifndef __OpenBSD__ - /* initialize all real time signals with dummy handler */ - for (int i = SIGRTMIN; i <= SIGRTMAX; i++) - signal(i, dummysighandler); -#endif - - for (unsigned int i = 0; i < LENGTH(blocks); i++) - { - if (blocks[i].signal > 0) - signal(SIGMINUS+blocks[i].signal, sighandler); - } - -} - -int getstatus(char *str, char *last) -{ - strcpy(last, str); - str[0] = '\0'; - for (unsigned int i = 0; i < LENGTH(blocks); i++) - strcat(str, statusbar[i]); - str[strlen(str)-strlen(delim)] = '\0'; - return strcmp(str, last);//0 if they are the same -} - -void setroot() -{ - if (!getstatus(statusstr[0], statusstr[1]))//Only set root if text has changed. - return; - Display *d = XOpenDisplay(NULL); - if (d) { - dpy = d; - } - screen = DefaultScreen(dpy); - root = RootWindow(dpy, screen); - XStoreName(dpy, root, statusstr[0]); - XCloseDisplay(dpy); -} - -void pstdout() -{ - if (!getstatus(statusstr[0], statusstr[1]))//Only write out if text has changed. - return; - printf("%s\n",statusstr[0]); - fflush(stdout); -} - - -void statusloop() -{ - setupsignals(); - int i = 0; - getcmds(-1); - while (statusContinue) - { - getcmds(i++); - writestatus(); - sleep(1.0); - } -} - -#ifndef __OpenBSD__ -/* this signal handler should do nothing */ -void dummysighandler(int signum) -{ - return; -} -#endif - -void sighandler(int signum) -{ - getsigcmds(signum-SIGPLUS); - writestatus(); -} - -void termhandler() -{ - statusContinue = 0; -} - -int main(int argc, char** argv) -{ - for (int i = 0; i < argc; i++) //Handle command line arguments - { - if (!strcmp("-d",argv[i])) - strncpy(delim, argv[++i], delimLen); - else if (!strcmp("-p",argv[i])) - writestatus = pstdout; - } - delim[MIN(delimLen, strlen(delim))] = '\0'; - signal(SIGTERM, termhandler); - signal(SIGINT, termhandler); - statusloop(); -} diff --git a/.config/dwm/scripts/checkUpdates.sh b/.config/dwm/scripts/checkUpdates.sh index eb792f0..59ae3f2 100755 --- a/.config/dwm/scripts/checkUpdates.sh +++ b/.config/dwm/scripts/checkUpdates.sh @@ -6,7 +6,7 @@ # 30 * * * * root /usr/bin/pacman -Sy if [ -f /usr/bin/pacman ] ; then num_packages=$(pacman -Qu | wc -l) - echo "${num_packages}" + echo " ${num_packages} " # Check updates on Ubuntu/Debian/Devuan # Note: Create cron on /etc/cron.d/checkupdates with the following lines: @@ -14,9 +14,9 @@ if [ -f /usr/bin/pacman ] ; then # 30 * * * * root /usr/bin/aptitude update elif [ -f /usr/bin/aptitude ] ; then num_packages=$(aptitude search "~U" | wc -l) - echo "${num_packages}" + echo " ${num_packages} " # Disable for other distros else - echo "0" + echo " 0 " fi diff --git a/.config/dwm/scripts/cpu_info.sh b/.config/dwm/scripts/cpu_info.sh index 0ca1608..be0aa3d 100755 --- a/.config/dwm/scripts/cpu_info.sh +++ b/.config/dwm/scripts/cpu_info.sh @@ -4,17 +4,17 @@ check_sensor=$(sensors | grep "Tdie:" 2> /dev/null) if [ -z "${check_sensor}" ] ; then check_sensor=$(sensors | grep "Tctl:" 2> /dev/null) if [ -z "${check_sensor}" ] ; then - CPU_USAGE=$(~/.config/dwm/scripts/cpu_load.sh -p) - echo "$CPU_USAGE" | awk '{ printf("%6s \n"), $1, $2 }' + CPU_USAGE=$(~/.config/polybar/iscripts/cpu_load.sh -p) + echo "$CPU_USAGE" | awk '{ printf("%6s \n"), $1, $2 }' else TEMP=$(sensors | grep 'Package id 0:\|Tctl' | grep ':[ ]*+[0-9]*.[0-9]*°C' -o | grep '+[0-9]*.[0-9]*°C' -o) #CPU_USAGE=$(mpstat 1 1 | awk '/Average:/ {printf("%s\n", $(NF-9))}') - CPU_USAGE=$(~/.config/dwm/scripts/cpu_load.sh -p) - echo "$CPU_USAGE $TEMP" | awk '{ printf("%6s @ %s \n"), $1, $2 }' + CPU_USAGE=$(~/.config/polybar/scripts/cpu_load.sh -p) + echo "$CPU_USAGE $TEMP" | awk '{ printf("%6s @ %s \n"), $1, $2 }' fi else TEMP=$(sensors | grep 'Package id 0:\|Tdie' | grep ':[ ]*+[0-9]*.[0-9]*°C' -o | grep '+[0-9]*.[0-9]*°C' -o) #CPU_USAGE=$(mpstat 1 1 | awk '/Average:/ {printf("%s\n", $(NF-9))}') - CPU_USAGE=$(~/.config/dwm/scripts/cpu_load.sh -p) - echo "$CPU_USAGE $TEMP" | awk '{ printf("%6s @ %s \n"), $1, $2 }' + CPU_USAGE=$(~/.config/polybar/iscripts/cpu_load.sh -p) + echo "$CPU_USAGE $TEMP" | awk '{ printf("%6s @ %s \n"), $1, $2 }' fi diff --git a/.config/dwm/scripts/current_date.sh b/.config/dwm/scripts/current_date.sh new file mode 100755 index 0000000..224de78 --- /dev/null +++ b/.config/dwm/scripts/current_date.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +current_date=$(date "+%d/%m/%Y %H:%M") +echo " ${current_date} " diff --git a/.config/dwm/scripts/disk_info.sh b/.config/dwm/scripts/disk_info.sh index 9bf7120..da3f2b2 100755 --- a/.config/dwm/scripts/disk_info.sh +++ b/.config/dwm/scripts/disk_info.sh @@ -1,4 +1,3 @@ #!/bin/bash -disk_info=$(df -h / | awk '/\//{ printf(" %4s / %s \n", $4, $2) }') -echo ${disk_info} +df -h / | awk '/\//{ printf(" %4s / %s \n", $4, $2) }' diff --git a/.config/dwm/scripts/get_volume.sh b/.config/dwm/scripts/get_volume.sh index bee0121..a501178 100755 --- a/.config/dwm/scripts/get_volume.sh +++ b/.config/dwm/scripts/get_volume.sh @@ -1,4 +1,4 @@ #!/bin/bash get_volume=$(amixer | grep "%" | head -1 | cut -d "%" -f 1 | cut -d "[" -f 2) -echo "${get_volume}%" +echo " ${get_volume}% " diff --git a/.config/dwm/scripts/kernel_version.sh b/.config/dwm/scripts/kernel_version.sh index 4bb57a2..390a687 100755 --- a/.config/dwm/scripts/kernel_version.sh +++ b/.config/dwm/scripts/kernel_version.sh @@ -30,5 +30,5 @@ kernelVersion=${kernelVersion}${kernelVersionTempDot} #kernelVersion=${kernelVersion}-${archCommand} kernelVersion=${kernelVersion} #echo "Kernel: Linux ${kernelVersion} " -echo "${kernelVersion}" +echo " Linux ${kernelVersion} " diff --git a/.config/dwm/scripts/kernel_version_num.sh b/.config/dwm/scripts/kernel_version_num.sh new file mode 100755 index 0000000..8483f29 --- /dev/null +++ b/.config/dwm/scripts/kernel_version_num.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Parameters +longNumber=2 +kernelCommand="uname -r" +archCommand=$(uname -m) + +# Kernel version +kernelVersion="" +count=1 + +# Extract numbers of kernel version +kernelVersionTemp=$(uname -r | cut -d "." -f ${count}) + kernelVersionTempDot="${kernelVersionTemp}" + kernelVersion="${kernelVersion}${kernelVersionTempDot}" + count=$(expr ${count} + 1) + +while [ ${count} -le ${longNumber} ] ; do + kernelVersionTemp=$(uname -r | cut -d "." -f ${count}) + kernelVersionTempDot=".${kernelVersionTemp}" + kernelVersion="${kernelVersion}${kernelVersionTempDot}" + count=$(expr ${count} + 1) +done + +kernelVersionTemp=$(uname -r | cut -d "." -f ${count} | cut -d "-" -f 1) +kernelVersionTempDot=".${kernelVersionTemp}" +kernelVersion=${kernelVersion}${kernelVersionTempDot} + +# Apply arch +#kernelVersion=${kernelVersion}-${archCommand} +kernelVersion=${kernelVersion} +#echo "Kernel: Linux ${kernelVersion} " +echo " ${kernelVersion} " + diff --git a/.config/dwm/scripts/launch-spectrwm.sh b/.config/dwm/scripts/launch-spectrwm.sh new file mode 100755 index 0000000..8406e40 --- /dev/null +++ b/.config/dwm/scripts/launch-spectrwm.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Terminate already running bar instances +killall -q polybar + +# Restore config for i3 +#cp -rfv ~/.config/polybar/config.i3 ~/.config/polybar/config + +# Wait until the processes have been shut down +while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done + +if type "xrandr"; then + for m in $(xrandr --query | grep " connected" | cut -d" " -f1); do + MONITOR=$m polybar --reload mainbar-spectrwm -c ~/.config/polybar/config & + done +else + polybar --reload mainbar-spectrwm -c ~/.config/polybar/config & +fi + +# Launch bar1 and bar2 +#polybar example & + +#echo "Bars launched..." diff --git a/.config/dwm/scripts/launch.sh b/.config/dwm/scripts/launch.sh new file mode 100755 index 0000000..93692e1 --- /dev/null +++ b/.config/dwm/scripts/launch.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Terminate already running bar instances +killall -q polybar + +# Restore config for i3 +#cp -rfv ~/.config/polybar/config.i3 ~/.config/polybar/config + +# Wait until the processes have been shut down +while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done + +if type "xrandr"; then + for m in $(xrandr --query | grep " connected" | cut -d" " -f1); do + MONITOR=$m polybar --reload mainbar-i3 -c ~/.config/polybar/config & + done +else + polybar --reload mainbar-i3 -c ~/.config/polybar/config & +fi + +# Launch bar1 and bar2 +#polybar example & + +#echo "Bars launched..." diff --git a/.config/dwm/scripts/mem_info.sh b/.config/dwm/scripts/mem_info.sh index 05ae6cc..6c8eeec 100755 --- a/.config/dwm/scripts/mem_info.sh +++ b/.config/dwm/scripts/mem_info.sh @@ -1,4 +1,6 @@ #!/bin/bash -mem_info=$(free -h | awk '/Mem:/ { printf("%5s/%s \n", $3, $2) }') -echo ${mem_info} +mem_info=$(free -h | awk '/Mem:/ { printf(" %5s/%s \n", $3, $2) }') +echo -n " " +echo -n ${mem_info} +echo " " diff --git a/.config/dwm/scripts/status_bar.sh b/.config/dwm/scripts/status_bar.sh new file mode 100755 index 0000000..9c1befd --- /dev/null +++ b/.config/dwm/scripts/status_bar.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +status_bar=0 + +while [ ${status_bar} -eq 0 ] ; do + updates=$(~/.config/dwm/scripts/checkUpdates.sh) + kernel=$(~/.config/dwm/scripts/kernel_version.sh) + cpuinfo=$(~/.config/dwm/scripts/cpu_info.sh) + meminfo=$(~/.config/dwm/scripts/mem_info.sh) + volume=$(~/.config/dwm/scripts/get_volume.sh) + date=$(~/.config/dwm/scripts/current_date.sh) + #echo "${updates} ${kernel} ${cpuinfo} ${meminfo} ${volume} ${date}" + xsetroot -name "${updates} ${kernel} ${cpuinfo} ${meminfo} ${volume} ${date}" + sleep 2 +done diff --git a/Dependencies.md b/Dependencies.md index c5e667c..19f7d9b 100644 --- a/Dependencies.md +++ b/Dependencies.md @@ -20,7 +20,7 @@ dotfiles - My tiling Qtile, Spectrwm, i3 , Dwm & Sway configurations (for Arch/D xfce4-screenshooter xscreensaver alsa-utils pulseaudio-alsa light xorg-xbacklight \ xorg-xrandr sway swaybg swayidle wofi meson waybar wayland-protocols xorg-xwayland \ wf-recorder xdg-desktop-portal-wlr wl-clipboard grim slurp jq wlroots pulseaudio \ - alacritty qtile python-pip + alacritty qtile python-pip xorg-xsetroot ```` ```shell diff --git a/examples/dwm.png b/examples/dwm.png index cdccf21..98ffc63 100644 Binary files a/examples/dwm.png and b/examples/dwm.png differ