From 22aa128454f8dd56bad519d62fae9a42ab2eb9b3 Mon Sep 17 00:00:00 2001 From: Sravan Balaji Date: Sat, 28 Sep 2024 13:09:19 -0400 Subject: [PATCH] Add swhkd package and use systemd.eclass - Add swhkd package with support for systemd and openrc - Use systemd.eclass in greenclip, snapborg, and swhkd packages - Add swhkd as dwl dependency --- app-backup/snapborg/snapborg-9999.ebuild | 16 ++--- app-misc/swhkd/files/openrc/swhkd | 5 ++ app-misc/swhkd/files/systemd/hotkeys.service | 10 +++ app-misc/swhkd/files/systemd/hotkeys.sh | 5 ++ app-misc/swhkd/swhkd-9999.ebuild | 65 ++++++++++++++++++++ x11-misc/greenclip/greenclip-4.2.ebuild | 6 +- 6 files changed, 97 insertions(+), 10 deletions(-) create mode 100644 app-misc/swhkd/files/openrc/swhkd create mode 100644 app-misc/swhkd/files/systemd/hotkeys.service create mode 100644 app-misc/swhkd/files/systemd/hotkeys.sh create mode 100644 app-misc/swhkd/swhkd-9999.ebuild diff --git a/app-backup/snapborg/snapborg-9999.ebuild b/app-backup/snapborg/snapborg-9999.ebuild index b2efcaa..453f4eb 100644 --- a/app-backup/snapborg/snapborg-9999.ebuild +++ b/app-backup/snapborg/snapborg-9999.ebuild @@ -6,7 +6,7 @@ EAPI=8 PYTHON_COMPAT=( python3_{11..13} ) DISTUTILS_SINGLE_IMPL=1 DISTUTILS_USE_PEP517=setuptools -inherit distutils-r1 git-r3 +inherit distutils-r1 git-r3 systemd DESCRIPTION="Synchronize snapper snapshots to a borg repository" HOMEPAGE="https://github.com/enzingerm/snapborg" @@ -34,13 +34,13 @@ python_install() { distutils-r1_python_install if use systemd ; then - insinto /usr/lib/systemd/system - doins "${S}/usr/lib/systemd/system/snapborg-backup-all-daily.timer" - doins "${S}/usr/lib/systemd/system/snapborg-backup-all-hourly.timer" - doins "${S}/usr/lib/systemd/system/snapborg-backup-all.service" - doins "${S}/usr/lib/systemd/system/snapborg-backup-daily@.timer" - doins "${S}/usr/lib/systemd/system/snapborg-backup-hourly@.timer" - doins "${S}/usr/lib/systemd/system/snapborg-backup@.service" + systemd_dounit "${S}/usr/lib/systemd/system/snapborg-backup-all-daily.timer" + systemd_dounit "${S}/usr/lib/systemd/system/snapborg-backup-all-hourly.timer" + systemd_dounit "${S}/usr/lib/systemd/system/snapborg-backup-all.service" + systemd_dounit "${S}/usr/lib/systemd/system/snapborg-backup-daily@.timer" + systemd_dounit "${S}/usr/lib/systemd/system/snapborg-backup-hourly@.timer" + systemd_dounit "${S}/usr/lib/systemd/system/snapborg-backup@.service" + elog "Run \`systemctl enable --now snapborg-backup-all-.timer\` to enable regular backups (hourly or daily) for all configs." elog "Run \`systemctl enable --now snapborg-backup-@.timer\` enable regular backups (hourly or daily) for a specific config." fi diff --git a/app-misc/swhkd/files/openrc/swhkd b/app-misc/swhkd/files/openrc/swhkd new file mode 100644 index 0000000..8243213 --- /dev/null +++ b/app-misc/swhkd/files/openrc/swhkd @@ -0,0 +1,5 @@ +#!/sbin/openrc-run + +command="/usr/bin/swhkd" +command_background=true +pidfile="/run/${RC_SVCNAME}.pid" diff --git a/app-misc/swhkd/files/systemd/hotkeys.service b/app-misc/swhkd/files/systemd/hotkeys.service new file mode 100644 index 0000000..fb18d05 --- /dev/null +++ b/app-misc/swhkd/files/systemd/hotkeys.service @@ -0,0 +1,10 @@ +[Unit] +Description=swhkd hotkey daemon +BindsTo=default.target + +[Service] +Type=simple +ExecStart=/usr/bin/hotkeys.sh + +[Install] +WantedBy=default.target diff --git a/app-misc/swhkd/files/systemd/hotkeys.sh b/app-misc/swhkd/files/systemd/hotkeys.sh new file mode 100644 index 0000000..c55c434 --- /dev/null +++ b/app-misc/swhkd/files/systemd/hotkeys.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +killall swhks + +/usr/bin/swhks & sudo /usr/bin/swhkd diff --git a/app-misc/swhkd/swhkd-9999.ebuild b/app-misc/swhkd/swhkd-9999.ebuild new file mode 100644 index 0000000..3a40f29 --- /dev/null +++ b/app-misc/swhkd/swhkd-9999.ebuild @@ -0,0 +1,65 @@ +# Copyright 2022-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit linux-info cargo git-r3 systemd + +DESCRIPTION="Simple Wayland HotKey Daemon" +HOMEPAGE="https://github.com/waycrate/swhkd" +EGIT_REPO_URI="${HOMEPAGE}.git" + +LICENSE="BSD-2" +SLOT="0" +KEYWORDS="~amd64" +IUSE="man systemd openrc" + +S="${WORKDIR}/${P}" + +CONFIG_CHECK=" + INPUT_EVDEV + INPUT_UINPUT +" + +BDEPEND=" + man? ( + app-text/scdoc + ) + virtual/libudev + app-arch/gzip +" + +src_unpack(){ + git-r3_src_unpack + cargo_live_src_unpack +} + +src_compile(){ + emake build +} + +src_install(){ + # Man Files + gzip -d ${S}/docs/*.gz + doman ${S}/docs/*.1 + doman ${S}/docs/*.5 + + # Binaries + dobin ${S}/target/release/swhkd + dobin ${S}/target/release/swhks + + if use systemd ; then + dobin ${FILESDIR}/systemd/hotkeys.sh + systemd_douserunit ${FILESDIR}/systemd/hotkeys.service + + elog "Add \`%wheel ALL=(ALL:ALL) NOPASSWD: /usr/bin/swhkd\` to \`/etc/sudoers\` to allow \`wheel\` group users to run \`sudo /usr/bin/swhkd\` without asking for a password." + elog "Run \`systemctl --user enable --now hotkeys.service\` to enable swhkd daemon and server." + fi + + if use openrc ; then + doinitd ${FILESDIR}/openrc/swhkd + + elog "Run \`sudo rc-update add swhkd\` to enable swhkd service." + elog "Add \`swhks\` to startup processes." + fi +} diff --git a/x11-misc/greenclip/greenclip-4.2.ebuild b/x11-misc/greenclip/greenclip-4.2.ebuild index c73599e..34fb8e0 100644 --- a/x11-misc/greenclip/greenclip-4.2.ebuild +++ b/x11-misc/greenclip/greenclip-4.2.ebuild @@ -3,6 +3,8 @@ EAPI=8 +inherit systemd + DESCRIPTION="Simple clipboard manager to be integrated with rofi - Static binary available" HOMEPAGE="https://github.com/erebe/greenclip" @@ -31,8 +33,8 @@ src_compile() { src_install() { if use systemd ; then - insinto /usr/lib/systemd/user/ - doins "${FILESDIR}"/greenclip.service + systemd_douserunit "${FILESDIR}"/greenclip.service + elog "Run \`systemctl --user enable --now greenclip.service\` to enable greenclip systemd user service." fi