Automatically detect loaded module.
This commit is contained in:
parent
7af9381e6e
commit
2aedbced66
4 changed files with 20 additions and 10 deletions
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
pkg/
|
||||||
|
src/
|
||||||
|
sway-dynamic-*/
|
||||||
|
sway-dynamic-*.pkg.tar.zst
|
2
PKGBUILD
2
PKGBUILD
|
@ -1,6 +1,6 @@
|
||||||
# Maintainer redxef <redxef@redxef.at>
|
# Maintainer redxef <redxef@redxef.at>
|
||||||
pkgname=sway-dynamic
|
pkgname=sway-dynamic
|
||||||
pkgver=1.0.0
|
pkgver=1.0.1
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="Helper files to dynamically launch sway for NVIDIA comaptibility or not"
|
pkgdesc="Helper files to dynamically launch sway for NVIDIA comaptibility or not"
|
||||||
arch=('any')
|
arch=('any')
|
||||||
|
|
11
README.md
11
README.md
|
@ -4,11 +4,6 @@ Dynamically switch between sway and sway-nvidia based on active gpu.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
When booting a GPU set the environment variable `GPUMODE=<driver>` with something
|
Blacklist the module which should not be loaded on boot, the script
|
||||||
like `systemd.setenv=GPUMODE=<driver>`. The script will decide how to
|
detects if the `nvidia` or `nouveau` driver is loaded and either calls
|
||||||
launch sway depending on this variable. Possible values:
|
`sway-nvidia` or `sway`.
|
||||||
|
|
||||||
- `nvidia`
|
|
||||||
- `nouveau`
|
|
||||||
|
|
||||||
|
|
||||||
|
|
13
sway-dynamic
13
sway-dynamic
|
@ -1,6 +1,17 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if [ "$GPUMODE" = 'nvidia' ]; then
|
active_module() {
|
||||||
|
if [ -n "$(lsmod | grep "nvidia")" ]; then
|
||||||
|
echo "nvidia"
|
||||||
|
elif [ -n "$(lsmod | grep "nouveau")" ]; then
|
||||||
|
echo nouveau
|
||||||
|
else
|
||||||
|
# no nvidia modules loaded
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$(active_module)" = 'nvidia' ]; then
|
||||||
exec sway-nvidia
|
exec sway-nvidia
|
||||||
else
|
else
|
||||||
exec sway
|
exec sway
|
||||||
|
|
Loading…
Reference in a new issue