commit f897c93012bd728f989e2bd2bd47064469eb20d0
parent 5532718ef592bca63a3e26411df6123b93817342
Author: mcol <mcol@posteo.net>
Date: Tue, 19 Mar 2019 17:47:33 +0000
Clarify and simplify helper files and installation locations
Diffstat:
7 files changed, 55 insertions(+), 48 deletions(-)
diff --git a/PKGBUILD b/PKGBUILD
@@ -40,7 +40,7 @@ build() {
package() {
cd "${srcdir}/${pkgname%-git}"
- make DESTDIR="${pkgdir}" install
+ make PREFIX="/usr" DESTDIR="${pkgdir}" install
mkdir -p $pkgdir/usr/share/licenses/${pkgname%-git}
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/${pkgname%-git}/LICENSE"
diff --git a/lemontools b/lemontools
@@ -159,12 +159,12 @@ kill_lemonbar() {
# if a theme name is passed, kill that bar
if [[ $# -gt 0 ]]
then
- if [[ -e $dir/run/fifo-$1 ]]
+ if [[ -e $run/fifo-$1 ]]
then
- _pid=$(cat $dir/run/pid-$1)
- rm $dir/run/pid-$1
- rm $dir/run/log-$1
- rm $dir/run/fifo-$1
+ _pid=$(cat $run/pid-$1)
+ rm $run/pid-$1
+ rm $run/log-$1
+ rm $run/fifo-$1
kill -TERM -- -$_pid
else
return 1
@@ -172,16 +172,16 @@ kill_lemonbar() {
else
# otherwise, kill them all
- if ls $dir/run/pid-* &> /dev/null
+ if ls $run/pid-* &> /dev/null
then
- for pidfile in $(ls $dir/run/pid-*)
+ for pidfile in $(ls $run/pid-*)
do
kill -TERM -- -$(cat $pidfile)
done
[[ -n "$dir" ]] && {
- rm -f $dir/run/pid-*
- rm -f $dir/run/log-*
- rm -f $dir/run/fifo-*
+ rm -f $run/pid-*
+ rm -f $run/log-*
+ rm -f $run/fifo-*
}
else
return 1
@@ -296,6 +296,10 @@ NC='\033[0m'
dir=$(get_dir)
dir_usr=/usr/share/lemontools
+# run directory: logs, fifos, pids
+run=/var/run/user/$UID/lemontools
+[[ ! -e $run ]] && mkdir $run
+
# Modules
modules_dir=$dir/modules
modules_c_dir=$dir/modules_c
@@ -351,7 +355,7 @@ while getopts ":hlTvt:f:k:KdDu:cC" arg; do
cat_fifo=true
;;
- u) [[ -n $(ls $dir/run) ]] && echo update_$OPTARG > $dir/run/fifo-*
+ u) [[ -n $(ls $run) ]] && echo update_$OPTARG > $run/fifo-*
exit
;;
@@ -398,7 +402,7 @@ fi
. $dir/themes/$theme.bar
# log pid using theme name
-pidfile=$dir/run/pid-$theme
+pidfile=$run/pid-$theme
if [[ -f "$pidfile" ]]
then
echo "Bar with theme $theme is already running."
@@ -407,11 +411,11 @@ fi
echo $$ > $pidfile
# log for commands output from lemonbar
-log=$dir/run/log-$theme
+log=$run/log-$theme
touch $log
# Setup fifo
-fifo=$dir/run/fifo-$theme
+fifo=$run/fifo-$theme
mkfifo $fifo
# Trap on INT signal to kill bar using lemontools -k $theme or lemontools -K
diff --git a/makefile b/makefile
@@ -1,7 +1,7 @@
CC = gcc
CFLAGS += -Wall
-PREFIX ?= /usr
+PREFIX ?= /usr/local
MODPREFIX = $(PREFIX)/share/$(NAME)
WAKEPREFIX = /usr/lib/systemd/system-sleep/
@@ -36,11 +36,13 @@ install:
@find $(SRC) -type f ! -name '*.c' -exec install -D -m 755 {} -t $(DESTDIR)$(MODPREFIX)/modules_c/ \;
@install -D -m 644 themes/* -t $(DESTDIR)$(MODPREFIX)/themes/
@if [[ -d $(WAKEPREFIX) ]]; then \
- echo Installing sleep-update as update-lemontools in $(DESTDIR)$(WAKEPREFIX); \
+ echo Installing update-after-wake as update-after-wake-lemontools in $(DESTDIR)$(WAKEPREFIX); \
mkdir -p $(DESTDIR)$(WAKEPREFIX); \
- cp sleep-update $(DESTDIR)$(WAKEPREFIX)/update-lemontools; \
- chmod 755 $(DESTDIR)$(WAKEPREFIX)/update-lemontools; \
+ cp update-after-wake $(DESTDIR)$(WAKEPREFIX)/update-after-wake-lemontools; \
+ chmod 755 $(DESTDIR)$(WAKEPREFIX)/update-after-wake-lemontools; \
fi
+ @echo Installing udev rule as /etc/udev/rules.d/90-update-battery-lemontools.rules
+ @install -m 644 update-battery-on-charge /etc/udev/rules.d/90-update-battery-lemontools.rules
uninstall:
@@ -50,8 +52,12 @@ uninstall:
@rm -r $(DESTDIR)$(MODPREFIX)
@if [[ -e $(WAKEPREFIX)/update-lemontools ]]; then \
echo Removing update-lemontools from $(DESTDIR)$(WAKEPREFIX); \
- rm $(DESTDIR)$(WAKEPREFIX)/update-lemontools; \
+ rm $(DESTDIR)$(WAKEPREFIX)/update-after-wake-lemontools; \
fi
+ @echo Removing udev rule /etc/udev/rules.d/90-update-battery-lemontools.rules
+ @rm /etc/udev/rules.d/90-update-battery-lemontools.rules
+ @echo Removing any folders in /var/run/user
+ @rm -r /var/run/user/*/lemontools
.PHONY: all clean install uninstall
diff --git a/sleep-update b/sleep-update
@@ -1,22 +0,0 @@
-#!/bin/bash
-#
-# Make this executable,
-# place it into /lib/systemd/system-sleep/,
-# and it will be passed 'pre' or 'post' before or after system suspend.
-# Depends on systemd.
-
-post(){
- if pgrep lemontools > /dev/null
- then
- lemontools -u battery
- lemontools -u clock
- lemontools -u date
- fi
-}
-
-
-case $1 in
- 'post')
- post
- ;;
-esac
diff --git a/udev-battery b/udev-battery
@@ -1,6 +0,0 @@
-# This udev rule will update the battery module when a laptop charger is plugged in or removed
-
-KERNEL=="AC0", SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", RUN+="/usr/bin/bash -c 'lemontools -u battery'"
-KERNEL=="AC0", SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="1", RUN+="/usr/bin/bash -c 'lemontools -u battery'"
-
-# vim: ft=udevrules
diff --git a/update-after-wake b/update-after-wake
@@ -0,0 +1,20 @@
+#!/bin/bash
+#
+# Make this executable,
+# place it into /usr/lib/systemd/system-sleep/,
+# and it will be passed 'pre' or 'post' before or after system suspend.
+# Depends on systemd.
+
+case $1 in
+
+ 'post')
+
+ for module in battery clock date
+ do
+ # This updates the above modules for all users and all running bars
+ echo update_$module > /var/run/user/*/lemontools/fifo-*
+ done
+
+ ;;
+
+esac
diff --git a/update-battery-on-charge b/update-battery-on-charge
@@ -0,0 +1,5 @@
+# This udev rule will update the battery module when a laptop charger is plugged in or removed
+
+KERNEL=="AC0", SUBSYSTEM=="power_supply", RUN+="/usr/bin/bash -c 'echo update_battery > /var/run/user/*/lemontools/fifo-*'"
+
+# vim: ft=udevrules