add extra services

This commit is contained in:
aliriza committed 2023-04-11 07:33:10 +00:00
1 parent e07205f461
commit e1b85c3263
4 files changed
+97 -1

No files matched your search

@@ -0,0 +1,45 @@
#!/sbin/openrc-run
# Copyright (c) 2007-2015 The OpenRC Authors.
# See the Authors file at the top-level directory of this distribution and
# https://github.com/OpenRC/openrc/blob/master/AUTHORS
#
# This file is part of OpenRC. It is subject to the license terms in
# the LICENSE file found in the top-level directory of this
# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
# This file may not be copied, modified, propagated, or distributed
# except according to the terms contained in the LICENSE file.
description="Save & restore backlight state."
depend()
{
after *
}
start()
{
if [ ! -d /var/cache/backlight ] ; then
mkdir -p /var/cache/backlight
fi
for device in $(ls /sys/class/backlight/) ; do
if [ -f /var/cache/backlight/${device} ] ; then
cat /var/cache/backlight/${device} > /sys/class/backlight/${device}/brightness
fi
done
return 0
}
stop()
{
if [ ! -d /var/cache/backlight ] ; then
mkdir -p /var/cache/backlight
fi
for device in $(ls /sys/class/backlight/) ; do
cat /sys/class/backlight/${device}/brightness > /var/cache/backlight/${device}
done
return 0
}
restart(){
stop
start
}
@@ -0,0 +1,11 @@
#!/sbin/openrc-run
name=disable-secondary-gpu
depend() {
before dbus
}
start() {
/usr/libexec/disable-secondary-gpu
}
@@ -0,0 +1,29 @@
#!/bin/bash
if [[ ! -f /var/cache/disable-gpu ]] &>/dev/null; then
exit 0
fi
if grep "nomodeset" /proc/cmdline ; then
exit 0
fi
remove_pci(){
if [[ -d "/sys/bus/pci/devices/0000:$1/driver" ]] ; then
module=$(basename $(readlink /sys/bus/pci/devices/0000:$1/driver/module))
echo "Disabled: $module ($1)"
rmmod -f $module
fi
echo 1 > /sys/bus/pci/devices/0000:$1/remove
}
echo 1 > /sys/bus/pci/rescan
for dir in /sys/class/drm/card[0-9*] ; do
# 03 Display controller
# 02 3D controller
if grep "^0x0302" $dir/device/class ; then
pci="$(basename $(readlink $dir/device))"
echo "Found 3D controller: ${pci:5}"
remove_pci "${pci:5}"
fi
done
udevadm control --reload
+12 -1
View File
@@ -10,10 +10,16 @@ license=('GPLv3')
source=("https://github.com/OpenRC/openrc/archive/refs/tags/$version.zip"
"openrc.sysconf"
"reboot"
"poweroff")
"poweroff"
"extras/backlight-restore.initd"
"extras/disable-secondary-gpu.initd"
"extras/disable-secondary-gpu.sh")
depends=()
makedepends=()
md5sums=('8b74d3db544b496f6bb33d2648db5d2f'
'SKIP'
'SKIP'
'SKIP'
'SKIP'
'SKIP'
'SKIP')
@@ -61,5 +67,10 @@ package(){
install ../reboot ${DESTDIR}/sbin/reboot
install ../poweroff ${DESTDIR}/sbin/poweroff
ln -s openrc-shutdown ${DESTDIR}/sbin/shutdown
# install extras
mkdir -p ${DESTDIR}/usr/libexec
install ../disable-secondary-gpu.sh ${DESTDIR}/usr/libexec/disable-secondary-gpu
install ../disable-secondary-gpu.initd ${DESTDIR}/etc/init.d
install ../backlight-restore.initd ${DESTDIR}/etc/init.d
}