forked from mirror/dwm
34 lines
742 B
C
34 lines
742 B
C
#include <unistd.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
/**
|
|
* Magically finds the current's executable path
|
|
*
|
|
* I'm doing the do{}while(); trick because Linux (what I'm running) is not
|
|
* POSIX compilant and so lstat() cannot be trusted on /proc entries
|
|
*
|
|
* @return char* the path of the current executable
|
|
*/
|
|
char *get_dwm_path(){
|
|
// Sorry non nixos users
|
|
return "/run/current-system/sw/bin/dwm";
|
|
}
|
|
|
|
/**
|
|
* self-restart
|
|
*
|
|
* Initially inspired by: Yu-Jie Lin
|
|
* https://sites.google.com/site/yjlnotes/notes/dwm
|
|
*/
|
|
void self_restart(const Arg *arg) {
|
|
char *const argv[] = {get_dwm_path(), NULL};
|
|
|
|
if(argv[0] == NULL){
|
|
return;
|
|
}
|
|
|
|
execv(argv[0], argv);
|
|
}
|