From 600680d3ec25de8e6a7816447577ff3c2a5e185d Mon Sep 17 00:00:00 2001 From: Ondrej Čerman Date: Sun, 29 Dec 2019 17:34:07 +0100 Subject: Makefile: Added option for app installation --- README.md | 27 ++++++++++++++++++++++----- data/org.pkexec.zenmonitor.policy.in | 18 ++++++++++++++++++ data/zenmonitor-root.desktop.in | 8 ++++++++ data/zenmonitor.desktop.in | 8 ++++++++ makefile | 28 ++++++++++++++++++++++++++++ 5 files changed, 84 insertions(+), 5 deletions(-) create mode 100644 data/org.pkexec.zenmonitor.policy.in create mode 100644 data/zenmonitor-root.desktop.in create mode 100644 data/zenmonitor.desktop.in diff --git a/README.md b/README.md index d4bdd34..c823858 100644 --- a/README.md +++ b/README.md @@ -5,14 +5,14 @@ It can monitor these values: - CPU Temperature - CPU Core (SVI2) Voltage, Current and Power - SOC (SVI2) Voltage, Current and Power - - Package and Core Power + - Package and Core Power (RAPL) - Core Frequency (from OS) ![screenshot](screenshot.png) ## Dependencies - [zenpower driver](https://github.com/ocerman/zenpower/) - For monitoring CPU temperature and SVI2 sensors - - MSR driver - For monitoring Package/Core Power + - MSR driver - For monitoring Package/Core Power (RAPL) Follow [zenpower README.md](https://github.com/ocerman/zenpower/blob/master/README.md) to install and activate zenpower module. Enter `sudo modprobe msr` to enable MSR driver. @@ -23,9 +23,25 @@ Make sure that GTK3 dev package and common build tools are installed. make ``` -## Running +## Launching +You can launch app by `sudo ./zenmonitor`, or you can install it to your system and then launch it from your OS menu. + +Note: Because superuser privileges are usually needed to access data from MSR driver, you need to launch zenmonitor as root for monitoring CPU power usage (RAPL). + +## Installing +By default, Zenmonitor will be installed to /usr/local. +``` +sudo make install +``` + +To add menu item for launching zenpower as root (Polkit is required): +``` +sudo make install-polkit +``` + +## Uninstalling ``` -sudo ./zenpower +sudo make uninstall ``` ## Setup on ubuntu @@ -39,5 +55,6 @@ cd ~ git clone https://github.com/ocerman/zenmonitor cd zenmonitor make -sudo ./zenmonitor +sudo make install +sudo make install-polkit ``` diff --git a/data/org.pkexec.zenmonitor.policy.in b/data/org.pkexec.zenmonitor.policy.in new file mode 100644 index 0000000..9c5a950 --- /dev/null +++ b/data/org.pkexec.zenmonitor.policy.in @@ -0,0 +1,18 @@ + + + + + + Run Zenmonitor as root + Authentication is required to run Zenmonitor as root. + + auth_admin + auth_admin + auth_admin + + @APP_EXEC@ + true + + + diff --git a/data/zenmonitor-root.desktop.in b/data/zenmonitor-root.desktop.in new file mode 100644 index 0000000..d8a4442 --- /dev/null +++ b/data/zenmonitor-root.desktop.in @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=Zenmonitor (root) +Comment=Monitoring software for AMD Zen-based CPUs +Exec=pkexec @APP_EXEC@ +Type=Application +Categories=GTK;System; +Terminal=false +Keywords=CPU;AMD;zen;system;core;speed;clock;temperature;voltage; diff --git a/data/zenmonitor.desktop.in b/data/zenmonitor.desktop.in new file mode 100644 index 0000000..91e583b --- /dev/null +++ b/data/zenmonitor.desktop.in @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=Zenmonitor +Comment=Monitoring software for AMD Zen-based CPUs +Exec=@APP_EXEC@ +Type=Application +Categories=GTK;System; +Terminal=false +Keywords=CPU;AMD;zen;system;core;speed;clock;temperature;voltage; diff --git a/makefile b/makefile index be1ac76..dabe5d2 100755 --- a/makefile +++ b/makefile @@ -1,5 +1,33 @@ +ifeq ($(PREFIX),) + PREFIX := /usr/local +endif + build: cc -Isrc/include `pkg-config --cflags gtk+-3.0` src/*.c src/ss/*.c -o zenmonitor `pkg-config --libs gtk+-3.0` -lm -no-pie -Wall +install: + mkdir -p $(DESTDIR)$(PREFIX)/bin + install -m 755 zenmonitor $(DESTDIR)$(PREFIX)/bin + + mkdir -p $(DESTDIR)$(PREFIX)/share/applications + sed -e "s|@APP_EXEC@|${DESTDIR}${PREFIX}/bin/zenmonitor|" \ + data/zenmonitor.desktop.in > \ + $(DESTDIR)$(PREFIX)/share/applications/zenmonitor.desktop + +install-polkit: + sed -e "s|@APP_EXEC@|${DESTDIR}${PREFIX}/bin/zenmonitor|" \ + data/zenmonitor-root.desktop.in > \ + $(DESTDIR)$(PREFIX)/share/applications/zenmonitor-root.desktop + + sed -e "s|@APP_EXEC@|${DESTDIR}${PREFIX}/bin/zenmonitor|" \ + data/org.pkexec.zenmonitor.policy.in > \ + $(DESTDIR)/usr/share/polkit-1/actions/org.pkexec.zenmonitor.policy + +uninstall: + rm -f $(DESTDIR)$(PREFIX)/bin/zenmonitor + rm -f $(DESTDIR)$(PREFIX)/share/applications/zenmonitor.desktop + rm -f $(DESTDIR)$(PREFIX)/share/applications/zenmonitor-root.desktop + rm -f $(DESTDIR)/usr/share/polkit-1/actions/org.pkexec.zenmonitor.policy + clean: rm -f zenmonitor -- cgit v1.2.3-70-g09d2