1
0
Fork 0
mirror of https://gitlab.com/dwt1/dotfiles.git synced 2023-02-13 20:55:19 -05:00

Adding the selfrestart.c needed for my dwm build.

This commit is contained in:
Derek Taylor 2019-02-18 15:08:42 -06:00
parent c6795b62c6
commit f1af653f99
4 changed files with 77 additions and 34 deletions

View file

@ -33,29 +33,6 @@ invert-color-include = [ ];
glx-copy-from-front = false;
glx-swap-method = "undefined";
opacity-rule = [ "99:name *?= 'Call'",
"99:class_g = 'Chromium'",
"99:name *?= 'Conky'",
"99:class_g = 'Darktable'",
"50:class_g = 'Dmenu'",
"99:name *?= 'Event'",
"99:class_g = 'Firefox'",
"99:class_g = 'GIMP'",
"99:name *?= 'Image'",
"99:class_g = 'Lazpaint'",
"99:class_g = 'Midori'",
"99:name *?= 'Minitube'",
"99:class_g = 'Mousepad'",
"99:name *?= 'MuseScore'",
"90:name *?= 'Page Info'",
"90:name *?= 'Panel'",
"99:class_g = 'Pinta'",
"90:name *?= 'Restart'",
"99:name *?= 'sudo'",
"99:name *?= 'Screenshot'",
"99:class_g = 'Viewnior'",
"99:class_g = 'VirtualBox'",
"99:name *?= 'VLC'",
"99:name *?= 'Write'",
"95:name *?= 'Lynx'",
"95:name *?= 'toot'",
"95:name *?= 'nmon'",

View file

@ -46,23 +46,23 @@
highlight clear
highlight Win cterm=none ctermfg=white ctermbg=default
highlight Directory cterm=bold ctermfg=cyan ctermbg=default
highlight Link cterm=bold ctermfg=yellow ctermbg=default
highlight Win cterm=none ctermfg=default ctermbg=default
highlight Directory cterm=bold ctermfg=green ctermbg=default
highlight Link cterm=bold ctermfg=default ctermbg=default
highlight BrokenLink cterm=bold ctermfg=red ctermbg=default
highlight Socket cterm=bold ctermfg=magenta ctermbg=default
highlight Device cterm=bold ctermfg=red ctermbg=default
highlight Fifo cterm=bold ctermfg=cyan ctermbg=default
highlight Executable cterm=bold ctermfg=green ctermbg=default
highlight Executable cterm=bold ctermfg=red ctermbg=default
highlight Selected cterm=bold ctermfg=magenta ctermbg=default
highlight CurrLine cterm=bold,reverse ctermfg=default ctermbg=default
highlight TopLine cterm=none ctermfg=147 ctermbg=red
highlight CurrLine cterm=bold,reverse ctermfg=4 ctermbg=black
highlight TopLine cterm=none ctermfg=147 ctermbg=8
highlight TopLineSel cterm=bold ctermfg=white ctermbg=default
highlight StatusLine cterm=bold ctermfg=white ctermbg=red
highlight StatusLine cterm=bold ctermfg=white ctermbg=8
highlight WildMenu cterm=underline,reverse ctermfg=white ctermbg=black
highlight CmdLine cterm=none ctermfg=white ctermbg=black
highlight CmdLine cterm=none ctermfg=green ctermbg=black
highlight ErrorMsg cterm=none ctermfg=red ctermbg=black
highlight Border cterm=none ctermfg=black ctermbg=red
highlight Border cterm=none ctermfg=black ctermbg=8
highlight JobLine cterm=bold,reverse ctermfg=black ctermbg=white
highlight SuggestBox cterm=bold ctermfg=default ctermbg=default
highlight CmpMismatch cterm=bold ctermfg=white ctermbg=red

View file

@ -1,3 +1,4 @@
distrowatch.com/
https://gitlab.com/dwt1
https://www.youtube.com/c/DistroTube/
https://www.patreon.com/distrotube

65
dwm/selfrestart.c Executable file
View file

@ -0,0 +1,65 @@
#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(){
struct stat s;
int r, length, rate = 42;
char *path = NULL;
if(lstat("/proc/self/exe", &s) == -1){
perror("lstat:");
return NULL;
}
length = s.st_size + 1 - rate;
do{
length+=rate;
free(path);
path = malloc(sizeof(char) * length);
if(path == NULL){
perror("malloc:");
return NULL;
}
r = readlink("/proc/self/exe", path, length);
if(r == -1){
perror("readlink:");
return NULL;
}
}while(r >= length);
path[r] = '\0';
return path;
}
/**
* 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);
}