diff options
author | Mattias Andrée <maandree@kth.se> | 2021-07-25 14:57:57 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-07-25 14:57:57 +0200 |
commit | c68f44677240cd4d777993494e2e9a7327c08e63 (patch) | |
tree | 1eb2ebf97bb085fc5ab122f6ccad02fb3a0a9f8b | |
parent | Fix previous commit (diff) | |
download | dotfiles-c68f44677240cd4d777993494e2e9a7327c08e63.tar.gz dotfiles-c68f44677240cd4d777993494e2e9a7327c08e63.tar.bz2 dotfiles-c68f44677240cd4d777993494e2e9a7327c08e63.tar.xz |
Add xinitrc script for dbus and add new-c-proj command
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r-- | base/Makefile | 2 | ||||
-rwxr-xr-x | base/new-c-proj | 161 | ||||
-rw-r--r-- | dbus/Makefile | 15 | ||||
-rw-r--r-- | dbus/xinit | 4 |
4 files changed, 182 insertions, 0 deletions
diff --git a/base/Makefile b/base/Makefile index 083eb91..365bde6 100644 --- a/base/Makefile +++ b/base/Makefile @@ -35,6 +35,7 @@ install: test ! -d ~/.local/bin/iswork test -x /bin/false ln -sf -- /bin/false ~/.local/bin/iswork + ln -sf ~/.dotfiles/base/new-c-proj ~/.local/bin/ test ! -r ../.secrets/bin/Makefile || make -C ../.secrets/bin install uninstall: @@ -45,6 +46,7 @@ uninstall: -unlink -- ~/.config/geolocation -unlink -- ~/.config/metar -unlink -- ~/.local/bin/iswork + -unlink -- ~/.local/bin/new-c-proj -test ! -r ../.secrets/bin/Makefile || make -C ../.secrets/bin uninstall .PHONY: install uninstall diff --git a/base/new-c-proj b/base/new-c-proj new file mode 100755 index 0000000..f10a26f --- /dev/null +++ b/base/new-c-proj @@ -0,0 +1,161 @@ +#!/bin/sh + +set -e + +if ! test $# = 1; then + printf 'usage %s: proj-name\n' "$0" >&2 + exit 1 +fi + +if printf '%s\n' "$1" | grep / >/dev/null 2>/dev/null; then + printf 'project name cannot contain a slash\n' "$0" >&2 + exit 1 +fi + +mkdir -- "$1" +cd -- "$1" +git init . + +cat > LICENSE <<EOF +ISC License + +© $(date +%Y) Mattias Andrée <maandree@kth.se> + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +EOF + +cat > .gitignore <<EOF +*\#* +*~ +*.o +*.a +*.lo +*.su +*.so +*.so.* +*.gch +*.gcov +*.gcno +*.gcda +EOF + +printf '_*\n' >> .git/info/exclude + +if printf '%s\n' "$1" | grep '^lib' >/dev/null 2>/dev/null; then + UPPERCASE="$(printf '%s\n' "$1" | tr '[a-z-]' '[A-Z_]')" + + printf '%s\n' >> "$1".h \ + '/* See LICENSE file for copyright and license details. */' \ + "#ifndef ${UPPERCASE}_H" \ + "#define ${UPPERCASE}_H" \ + '' \ + '#endif' + + cat <<-EOF | sed 's/x\t/\t/g' > Makefile + .POSIX: + + CONFIGFILE = config.mk + include \$(CONFIGFILE) + + OBJ = + + HDR =\\ + x $1.h + + all: $1.a + \$(OBJ): \$(@:.o=.c) \$(HDR) + + .c.o: + x \$(CC) -c -o \$@ \$< \$(CFLAGS) \$(CPPFLAGS) + + .c.lo: + x \$(CC) -fPIC -c -o \$@ \$< \$(CFLAGS) \$(CPPFLAGS) + + $1.a: \$(OBJ) + x @rm -f -- \$@ + x \$(AR) rc \$@ \$(OBJ) + + install: $1.a + x mkdir -p -- "\$(DESTDIR)\$(PREFIX)/lib" + x mkdir -p -- "\$(DESTDIR)\$(PREFIX)/include" + x cp -- $1.a "\$(DESTDIR)\$(PREFIX)/lib/" + x cp -- $1.h "\$(DESTDIR)\$(PREFIX)/include/" + + uninstall: + x -rm -f -- "\$(DESTDIR)\$(PREFIX)/lib/$1.a" + x -rm -f -- "\$(DESTDIR)\$(PREFIX)/include/$1.h" + + clean: + x -rm -f -- *.o *.a *.lo *.su *.so *.so.* *.gch *.gcov *.gcno *.gcda + + .SUFFIXES: + .SUFFIXES: .lo .o .c + + .PHONY: all install uninstall clean + EOF +else + printf '%s\n' "/$1" >> .gitignore + + printf '%s\n' '/* See LICENSE file for copyright and license details. */' >> "$1".c + + cat <<-EOF | sed 's/x\t/\t/g' > Makefile + .POSIX: + + CONFIGFILE = config.mk + include \$(CONFIGFILE) + + OBJ =\\ + x $1.o + + HDR = + + all: $1 + \$(OBJ): \$(@:.o=.c) \$(HDR) + + .c.o: + x \$(CC) -c -o \$@ \$< \$(CFLAGS) \$(CPPFLAGS) + + $1: \$(OBJ) + x \$(CC) -o \$@ \$(OBJ) \$(LDFLAGS) + + install: $1 + x mkdir -p -- "\$(DESTDIR)\$(PREFIX)/bin" + x mkdir -p -- "\$(DESTDIR)\$(MANPREFIX)/man1/$1.1" + x cp -- $1 "\$(DESTDIR)\$(PREFIX)/bin/" + x cp -- $1.1 "\$(DESTDIR)\$(MANPREFIX)/man1/" + + uninstall: + x -rm -f -- "\$(DESTDIR)\$(PREFIX)/bin/$1" + x -rm -f -- "\$(DESTDIR)\$(MANPREFIX)/man1/$1.1" + + clean: + x -rm -f -- *.o *.a *.lo *.su *.so *.so.* *.gch *.gcov *.gcno *.gcda + x -rm -f -- $1 + + .SUFFIXES: + .SUFFIXES: .o .c + + .PHONY: all install uninstall clean + EOF +fi + +cat > config.mk <<-EOF + PREFIX = /usr + MANPREFIX = \$(PREFIX)/share/man + + CC = cc + + CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_GNU_SOURCE + CFLAGS = -std=c99 -Wall -g + LDFLAGS = +EOF diff --git a/dbus/Makefile b/dbus/Makefile new file mode 100644 index 0000000..aab1396 --- /dev/null +++ b/dbus/Makefile @@ -0,0 +1,15 @@ +.POSIX: +include ../common.mk + +XINITRC_ORDER = 50 + +install: + mkdir -p -- ~/.config/X11/xinit/xinitrc.d + test ! -d ~/.config/X11/xinit/xinitrc.d/$(XINITRC_ORDER)-dbus + ln -sf -- ~/.dotfiles/dbus/xinit ~/.config/X11/xinit/xinitrc.d/$(XINITRC_ORDER)-dbus + +uninstall: + -unlink -- ~/.config/X11/xinit/xinitrc.d/$(XINITRC_ORDER)-dbus + -rmdir -- ~/.config/X11/xinit/xinitrc.d + +.PHONY: install uninstall diff --git a/dbus/xinit b/dbus/xinit new file mode 100644 index 0000000..28bb1d1 --- /dev/null +++ b/dbus/xinit @@ -0,0 +1,4 @@ +# -*- shell-script -*- + +# Functional alernative to /etc/X11/xinit/xinitrc.d/50-systemd-user.sh, just skips first part +dbus-update-activation-environment DISPLAY XAUTHORITY |