Dotfiles config update (2022-05-22)
This commit is contained in:
parent
b5979b0b09
commit
70faa5d60e
|
@ -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 &
|
||||
|
|
|
@ -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
|
|
@ -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;
|
|
@ -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;
|
|
@ -1,184 +0,0 @@
|
|||
#include<stdlib.h>
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
#include<unistd.h>
|
||||
#include<signal.h>
|
||||
#include<X11/Xlib.h>
|
||||
#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();
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
4
.config/dwm/scripts/current_date.sh
Executable file
4
.config/dwm/scripts/current_date.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
current_date=$(date "+%d/%m/%Y %H:%M")
|
||||
echo " ${current_date} "
|
|
@ -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) }'
|
||||
|
|
|
@ -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}% "
|
||||
|
|
|
@ -30,5 +30,5 @@ kernelVersion=${kernelVersion}${kernelVersionTempDot}
|
|||
#kernelVersion=${kernelVersion}-${archCommand}
|
||||
kernelVersion=${kernelVersion}
|
||||
#echo "Kernel: Linux ${kernelVersion} "
|
||||
echo "${kernelVersion}"
|
||||
echo " Linux ${kernelVersion} "
|
||||
|
||||
|
|
34
.config/dwm/scripts/kernel_version_num.sh
Executable file
34
.config/dwm/scripts/kernel_version_num.sh
Executable file
|
@ -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} "
|
||||
|
23
.config/dwm/scripts/launch-spectrwm.sh
Executable file
23
.config/dwm/scripts/launch-spectrwm.sh
Executable file
|
@ -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..."
|
23
.config/dwm/scripts/launch.sh
Executable file
23
.config/dwm/scripts/launch.sh
Executable file
|
@ -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..."
|
|
@ -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 " "
|
||||
|
|
15
.config/dwm/scripts/status_bar.sh
Executable file
15
.config/dwm/scripts/status_bar.sh
Executable file
|
@ -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
|
|
@ -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
|
||||
|
|
BIN
examples/dwm.png
BIN
examples/dwm.png
Binary file not shown.
Before Width: | Height: | Size: 3.0 MiB After Width: | Height: | Size: 3.0 MiB |
Loading…
Reference in New Issue
Block a user