cem-utils

Random utilities
git clone git://git.ckyln.com/~cem/cem-utils.git
Log | Files | Refs | README

commit e88aef5553dccb0685ad0a0cdaadac7a15805f90
Author: Cem Keylan <cem@ckyln.com>
Date:   Sun,  2 Feb 2020 22:18:48 +0300

initial commit

Diffstat:
AREADME | 37+++++++++++++++++++++++++++++++++++++
Anap/Makefile | 15+++++++++++++++
Anap/nap | 14++++++++++++++
3 files changed, 66 insertions(+), 0 deletions(-)

diff --git a/README b/README @@ -0,0 +1,37 @@ +cem-utils +========= + +These are some utilities that are not much +use to anyone, but I use for my own. Most of +them are just simpler re-implementations of +programs that are pretty unnecessary for most +people. If i published them standalone, lots +of people would get mad at me for just modifying +some program that they like with really small +changes. + +I really don't care about what you think about +these. I just use them. + +Here are some explanations per utility. Right now +there is only one but I will be publishing others. + + +nap +--- + +Literally Leah's zzz with only suspend feature. +It is compatible with zzz so it can read zzz.d +Why don't I add hybernation stuff? Because my +computer cannot hybernate. + +You see my point? I don't have a use for more +than half of the things zzz script does. So +I deleted them. + +To install run, as root if necessary + + make -C nap install + +This will create the /etc/zzz.d directories and +install nap diff --git a/nap/Makefile b/nap/Makefile @@ -0,0 +1,15 @@ +PREFIX=/usr/local +BINDIR=${PREFIX}/bin +ETCDIR=/etc + +install: + mkdir -p ${DESTDIR}${ETCDIR}/zzz.d/suspend + mkdir -p ${DESTDIR}${ETCDIR}/zzz.d/resume + install -Dm755 nap ${DESTDIR}${BINDIR}/nap + +uninstall: + rm -f ${DESTDIR}${BINDIR}/nap + @echo not removing /etc/zzz.d, you can remove \ + it manually + +.PHONY: install uninstall diff --git a/nap/nap b/nap/nap @@ -0,0 +1,14 @@ +#!/bin/sh +# nap - not the full zzz, but a light one + +usage() { printf 'Usage: %s\nThere are not many options when taking a nap.\n' "${0##*/}" ; exit 1 ;} +[ "$1" ] && usage +grep -q mem /sys/power/state || { printf "Suspend not supported.\n"; exit 1 ;} +test -w /sys/power/state || { printf "Sleep permission denied.\n" ; exit 1 ;} +for hook in /etc/zzz.d/suspend/* ; do + [ -x "$hook" ] && "$hook" +done +printf mem >/sys/power/state || { printf "Could not suspend.\n" ; exit 1 ;} +for hook in /etc/zzz.d/resume/*; do + [ -x "$hook" ] && "$hook" +done