Hack to support waybar autohide
Small C program to send hide signal to bar. Coordination script which expects the C program to be compiled at scripts/waybar/toggle
This commit is contained in:
parent
93125c95ee
commit
2ef12fe5de
|
@ -0,0 +1,30 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <ctype.h>
|
||||
|
||||
int main(int argc, char*argv[])
|
||||
{
|
||||
int pid;
|
||||
if (argc <= 1) {
|
||||
printf("No PID given\n");
|
||||
return(1);
|
||||
} else if (argc > 2) {
|
||||
printf("Too many arguments\n");
|
||||
return(1);
|
||||
} else {
|
||||
long val;
|
||||
char *next;
|
||||
val = strtol(argv[1], &next, 10);
|
||||
if ((next == argv[1]) || (*next != '\0')) {
|
||||
printf("Argument '%s' is not a number\n", argv[1]);
|
||||
return(1);
|
||||
} else {
|
||||
pid = val;
|
||||
}
|
||||
}
|
||||
kill(pid, SIGUSR1);
|
||||
return(0);
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash
|
||||
|
||||
ARG=$1
|
||||
if [[ $ARG == '' ]]; then
|
||||
ARG="toggle"
|
||||
fi
|
||||
|
||||
if [[ $ARG == 'toggle' ]]; then
|
||||
if [[ -e '/home/jpm/.config/waybar/.hidden' ]]; then
|
||||
rm '/home/jpm/.config/waybar/.hidden';
|
||||
else
|
||||
touch '/home/jpm/.config/waybar/.hidden';
|
||||
fi
|
||||
elif [[ $ARG == 'hide' ]]; then
|
||||
if [[ ! -e '/home/jpm/.config/waybar/.hidden' ]]; then
|
||||
touch '/home/jpm/.config/waybar/.hidden';
|
||||
else
|
||||
echo 'Already hidden. You may need to use the "invert" option if action is reversed';
|
||||
exit;
|
||||
fi
|
||||
elif [[ $ARG == 'show' ]]; then
|
||||
if [[ -e '/home/jpm/.config/waybar/.hidden' ]]; then
|
||||
rm '/home/jpm/.config/waybar/.hidden';
|
||||
else
|
||||
echo 'Already shown. You may need to use the "invert" option if action is reversed';
|
||||
exit;
|
||||
fi
|
||||
elif [[ $ARG != 'invert' ]]; then
|
||||
echo "Invalid argument";
|
||||
fi
|
||||
|
||||
/home/jpm/scripts/waybar/toggle `pgrep waybar`
|
Loading…
Reference in New Issue