Tuesday, October 5, 2021

 # OpenRazer on RedHat 8.4

## building rpm

Basically follow the steps for Fedora listed here: https://github.com/openrazer/openrazer/wiki/Building-a-package

Steps

sudo dnf install rpm-build rpmdevtools

rpmdev-setuptree

cd ~/rpmbuild/SPECS

curl -O https://raw.githubusercontent.com/openrazer/OBS-packaging/master/openrazer.spec

# To build from custom sources, pause here to edit openrazer.spec:

# Replace the line with "#define gitcommit" with "%define gitcommit $yourcommit"

# Optionally you will have to edit the first "Source0:" line to point to a different repository than openrazer/openrazer.

spectool -g -R openrazer.spec

sudo dnf -y builddep openrazer.spec

rpmbuild -bb openrazer.spec

sudo dnf install ../RPMS/noarch/*.rpm

Issues

I have python 3.6 amd 3.8 installed, rpmbuild took wrong version in order to fix this add this define to override python_sitelib:

%define python3_sitelib /usr/lib/python3.8/site-packages

in addition I used the latest git commit hash from main (check yourself):
#define gitcommit 7c353f9c8f1439bce5396218331c412eae0c2563

I could not find a python3-daemonize package in redhat yum repository. But that does not matter, actually I  think I do not need the daemon anyway. Most frontends only require the driver. So you could remove that requirement if you want to get it installed then install daemonize via pip3 for example.


xautomation

I created this specfile to build xautomation rpm (again I do not make use of it ... but at that time thought I might require the dependency)


# use spectool to download source:
# spectool -g -R xautomation.spec


%define python3_sitelib /usr/lib/python3.8/site-packages

%define debug_package %{nil}


Name: xautomation

Version: 1.09

Release: 4%{?dist}

Summary: Controls X from the command line and does "visual scraping".

License: GPL-2.0

URL: https://hoopajoo.net/projects/xautomation.html

BuildArch: x86_64

Requires: libXtst-devel

Source0: https://hoopajoo.net/static/projects/%{name}-%{version}.tar.gz

%description
Controls X from the command line and does "visual scraping".


%prep
%autosetup -n xautomation-%{version}

%build
./configure --prefix=$RPM_BUILD_ROOT/usr
make

%install
make install

%files
/usr/bin/*
%{_prefix}/bin/*

%{_mandir}/man1/pat2ppm.1.gz
%{_mandir}/man1/patextract.1.gz
%{_mandir}/man1/png2pat.1.gz

%{_mandir}/man1/rgb2pat.1.gz|
%{_mandir}/man1/visgrep.1.gz
%{_mandir}/man1/xmousepos.1.gz
%{_mandir}/man1/xte.1.gz
%{_mandir}/man7/xautomation.7.gz


find keyboard

#!/bin/sh

[ -d /sys/bus/hid/drivers/razerkbd ] || exit 1

device=$(find -H /sys/bus/hid/drivers/razerkbd/0003\:1532\:0241.*/ -type f -name device_type)

device_type=$(cat $device)

device=$(echo ${device%/*})

if [ "Razer BlackWidow 2019" = "$device_type" ]; then

    echo "Keyboard found at: $device"

else

    echo "No Razer Blackwidow found!"

    exit 2

fi


set effects


# echo -n -e "\x03\x00\xFF\xFF" > $device/matrix_effect_reactive
matrix=$1
if [ -z "$matrix" ]; then
    echo "bye"
fi

case $matrix in
"wave")
    echo "setup wave pattern"
    echo -n "1" > $device/matrix_effect_wave
    ;;
"stars")
    echo "setup starlight pattern"
    ;;
"react")
    speed=$2
    color=$3
    if [ -z "$speed" ] || [ -z "$color" ]; then
echo "no speed and color provided using: \"\x03\x00\xFF\xFF\""
echo -n -e "\x03\x00\xFF\xFF" > $device/matrix_effect_reactive
#exit 3
    fi
    echo "setup reactive effect: \"$speed$color\""
    echo -n -e "$speed$color" > $device/matrix_effect_reactive
    ;;
#   *)
#     STATEMENTS
#     ;;
esac