Compare commits

...

3 Commits

5 changed files with 54 additions and 6 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
*.swp
*.tmp
c/scream
c/xgetnewwindow
c/timer
c/boid
c/a.out

View File

@ -38,7 +38,7 @@ sh:
check:
shellcheck sh/*
mkc: c/scream c/timer c/boid c/anaconda c/colors
mkc: c/scream c/timer c/boid c/anaconda c/colors c/xgetnewwindow
c/boid:
cc c/boid.c -o c/boid -lm -lX11
@ -46,16 +46,21 @@ c/boid:
c/anaconda:
cc c/anaconda.c -o c/anaconda -lm -lX11
c/xgetnewwindow:
cc c/xgetnewwindow.c -o c/xgetnewwindow -lX11
c:
cp -f c/scream $(DESTDIR)$(PREFIX)/bin
cp -f c/timer $(DESTDIR)$(PREFIX)/bin
cp -f c/boid $(DESTDIR)$(PREFIX)/bin
cp -f c/anaconda $(DESTDIR)$(PREFIX)/bin
cp -f c/colors $(DESTDIR)$(PREFIX)/bin
cp -f c/xgetnewwindow $(DESTDIR)$(PREFIX)/bin
clean:
rm c/scream
rm c/timer
rm c/boid
rm c/anaconda
rm c/simplestatus
rm -f c/scream
rm -f c/timer
rm -f c/boid
rm -f c/anaconda
rm -f c/simplestatus
rm -f c/xgetnewwindow

29
c/xgetnewwindow.c Normal file
View File

@ -0,0 +1,29 @@
#include <X11/Xlib.h>
#include <stdio.h>
int main(void) {
Display* display = XOpenDisplay(NULL);
if(!display) {
printf("Error: Unable to open display.\n");
return 1;
}
int screen = DefaultScreen(display);
Window root = RootWindow(display, screen);
/* SubstructureNotifyMask allows us to be notified of CreateNotify events */
XSelectInput(display, root, SubstructureNotifyMask);
XEvent event;
for(;;) {
XNextEvent(display, &event);
if(event.type == CreateNotify) {
/* print window id */
printf("0x%x\n", event.xcreatewindow.window);
break;
}
}
XCloseDisplay(display);
return 0;
}

10
man/xgetnewwindow.1 Normal file
View File

@ -0,0 +1,10 @@
.TH XGETNEWWINDOW 1 xgetnewwindow
.SH NAME
xgetnewwindow
.SH SYNOPSIS
xgetnewwindow blocks until it recieves a CreateNotify event; that is, until a new window is created within the current Xorg instance. Once a new window is created, xgetnewwindow prints the window id (in hexadecimal) to stdout and exits.
.SH EXIT CODES
1 for abnormal termination, 0 for success.
.SH AUTHOR
randomuser

View File

@ -7,6 +7,7 @@ power_prefix="/sys/class/power_supply/"
[ "$(pgrep -c pulseaudio)" -eq 1 ] && ss="pulse" || ss="alsa"
mod_bspwm () {
set -x
used_desk=$(bspc query -D -d .occupied --names | tr '\n' ' ')
current_desk=$(bspc query -D -d .focused --names)
final_string=""
@ -23,6 +24,7 @@ mod_bspwm () {
final_string=${final_string}"*$current_desk "
printf "%s" "$final_string"
set +x
}
mod_period () {
@ -36,6 +38,7 @@ mod_sensors () {
mod_power () {
[ -z "$bat" ] ||
tr -d '\n' < /sys/class/power_supply/$bat/capacity
sed 's/Charging/↑/g;s/Discharging/↓/g;s/Full/-/g' < /sys/class/power_supply/$bat/status
}
mod_vol () {