-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from martin31821/feature/makefile
Add Makefile and new installation methods supporting multi-user environments
- Loading branch information
Showing
43 changed files
with
2,926 additions
and
829 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
name: latest build | ||
|
||
jobs: | ||
build: | ||
name: Build project | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Build | ||
run: make package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
name: release build | ||
|
||
jobs: | ||
release: | ||
name: Create Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
draft: false | ||
prerelease: false | ||
- name: Output Release URL File | ||
run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url | ||
- name: Save Release URL File for publish | ||
uses: actions/upload-artifact@v1 | ||
with: | ||
name: release_url | ||
path: release_url | ||
pkg-extension-zip: | ||
name: Create GNOME Extensions ZIP | ||
needs: release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Release GNOME Extensions ZIP | ||
id: gnome-zip | ||
run: | | ||
VERSION="${GITHUB_REF:11}" | ||
echo "::set-output name=version::$VERSION" | ||
make package | ||
cp target/cpupower-$VERSION.zip $GITHUB_WORKSPACE/cpupower-$VERSION.zip | ||
- name: Load Release URL File from release job | ||
uses: actions/download-artifact@v1 | ||
with: | ||
name: release_url | ||
- name: Get Release File Name & Upload URL | ||
id: get_release_info | ||
run: | | ||
value=`cat release_url/release_url` | ||
echo ::set-output name=upload_url::$value | ||
- name: Upload GNOME Extension Release Assets | ||
id: upload-release-asset | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.get_release_info.outputs.upload_url }} | ||
asset_path: cpupower-${{ steps.gnome-zip.outputs.version }}.zip | ||
asset_name: cpupower-${{ steps.gnome-zip.outputs.version }}.zip | ||
asset_content_type: application/zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
.last-settings | ||
mko.cpupower.policy | ||
*.mo | ||
target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
PREFIX ?= /usr | ||
|
||
VERSION = "8.0.0" | ||
MSGFMT = /usr/bin/msgfmt | ||
GLIB_COMPILE_SCHEMAS = /usr/bin/glib-compile-schemas | ||
EXTENSION_INSTALL_DIR = "$(PREFIX)/share/gnome-shell/extensions/[email protected]" | ||
EXTENSION_FILES="$(shell find . -path './.git' -prune -o -path './target' -prune -o -print)" | ||
|
||
build: | ||
@echo Compiling schemas... | ||
@$(GLIB_COMPILE_SCHEMAS) ./schemas | ||
@echo Updating translations... | ||
@MSGFMT="$(MSGFMT)" ./scripts/update-translations.sh | ||
|
||
clean: | ||
@rm -r target | ||
|
||
package: build | ||
@mkdir -p target | ||
@zip target/cpupower-${VERSION}.zip "$(EXTENSION_FILES)" | ||
|
||
install: package | ||
@mkdir -p "$(EXTENSION_INSTALL_DIR)" | ||
@unzip -o target/cpupower-${VERSION}.zip -d "$(EXTENSION_INSTALL_DIR)" | ||
|
||
uninstall: | ||
@rm -r "$(EXTENSION_INSTALL_DIR)" | ||
|
||
install-tool: | ||
@./tool/installer.sh --prefix "$(PREFIX)" --tool-suffix "$(TOOL_SUFFIX)" install | ||
|
||
uninstall-tool: | ||
@./tool/installer.sh --prefix "$(PREFIX)" --tool-suffix "$(TOOL_SUFFIX)" uninstall | ||
|
||
release: | ||
@./scripts/release.sh "$(VERSION)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,51 @@ | ||
# CPU Power Manager for Gnome Shell | ||
<h1 align="center">CPU Power Manager for Gnome Shell</h1> | ||
<p align="center"> | ||
<a href="https://extensions.gnome.org/extension/945/cpu-power-manager/"> | ||
<img alt="Get it on GNOME Extensions" width="228" src="https://raw.githubusercontent.com/andyholmes/gnome-shell-extensions-badge/master/get-it-on-ego.svg?sanitize=true"/> | ||
</a> | ||
<br> | ||
<a href="https://github.com/martin31821/cpupower/actions?query=workflow%3A%22latest%20build%22"> | ||
<img src="https://github.com/martin31821/cpupower/workflows/latest%20build/badge.svg" alt="latest build"> | ||
</a> | ||
<a href="https://github.com/martin31821/cpupower/actions?query=workflow%3A%22release%20build%22"> | ||
<img src="https://github.com/martin31821/cpupower/workflows/release%20build/badge.svg" alt="release build"> | ||
</a> | ||
<a href="https://github.com/martin31821/cpupower/releases"> | ||
<img alt="Lastest release" src="https://img.shields.io/github/v/release/martin31821/cpupower?label=latest%20release&sort=semver"> | ||
</a> | ||
<img alt="Gnome" src="https://img.shields.io/badge/gnome-3.36-blue?logo=gnome&logoColor=white"> | ||
<a href="https://github.com/martin31821/cpupower/blob/master/LICENSE"> | ||
<img alt="License" src="https://img.shields.io/github/license/martin31821/cpupower.svg"> | ||
</a> | ||
<a href="http://makeapullrequest.com"> | ||
<img alt="PRs Welcome" src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" target="_blank" /> | ||
</a> | ||
<br> | ||
<i>Gnome-Shell Extension for intel-pstate driver</i> | ||
<br><br> | ||
<a href="#prerequisites">Prerequisites</a> • | ||
<a href="#installation">Installation</a> • | ||
<a href="#translating">Translating</a> • | ||
<a href="#packaging">Packaging</a> • | ||
<a href="#developing">Developing</a> | ||
</p> | ||
|
||
Gnome-Shell Extension for intel-pstate driver. | ||
## Prerequisites | ||
|
||
You need to have an **Intel Core i CPU** of at least the **second Generation (2xxx Model Number)** and the following | ||
software installed to use this extension: | ||
|
||
- Gnome (since it's an extension) | ||
- Policykit (ships default with gnome) | ||
- intel_pstate needs to be enabled in the kernel (should be the default in almost all Distros) | ||
- bash | ||
|
||
### Installing via Makefile | ||
|
||
In order to use the Makefile you need the following packages: | ||
|
||
- make | ||
- gettext | ||
|
||
## Installation | ||
|
||
|
@@ -11,12 +56,147 @@ Click on the CPU icon in the top bar of your Gnome shell and follow the installa | |
You need to enter your root password to install a policy kit rule. This rule is used to set the clock | ||
frequency of your CPU with your user. | ||
|
||
## Prerequisites | ||
### Installing for another (admin) user | ||
|
||
You need to have an **Intel Core i CPU** of at least the **second Generation (2xxx Model Number)** and the following | ||
software installed to use this extension: | ||
Impersonate the (admin) user, clone the git repository, and run the following command: | ||
|
||
- Gnome (since it's an extension) | ||
- Policykit (ships default with gnome) | ||
- intel_pstate needs to be enabled in the kernel (should be the default in almost all Distros) | ||
- bash | ||
> Note: Cloning and installing the extension while impersonating the other user, enables this user | ||
> to install updates for this extension from extensions.gnome.org. | ||
```shell | ||
$ sudo -u username bash | ||
$ cd /tmp | ||
$ git clone https://github.com/martin31821/cpupower.git | ||
$ cd cpupower | ||
$ make install PREFIX=/home/username/.local | ||
``` | ||
|
||
Restart the gnome-shell (log out and back in) to make the extension available. | ||
|
||
The user can enable the extension in his settings and install the polkit rule and `cpufreqctl` tool by using the included installation guide. | ||
|
||
#### Uninstalling | ||
|
||
The user can uninstall the tools in the settings of this extension. The extension itself can be removed from withing the extension settings or with this command: | ||
|
||
```shell | ||
$ make uninstall PREFIX=/home/username/.local | ||
``` | ||
|
||
### Installing for another (non-admin) user | ||
|
||
Impersonate the (non-admin) user, clone the git repository, and run the following command: | ||
|
||
> Note: Cloning and installing the extension while impersonating the other user, enables this user | ||
> to install updates for this extension from extensions.gnome.org. However, the tool **must** | ||
> be updated and installed by an administrator. The extension may stop working after the user | ||
> installed an update and may need updating of the tool by an administrator. | ||
```shell | ||
$ sudo -u username bash | ||
$ cd /tmp | ||
$ git clone https://github.com/martin31821/cpupower.git | ||
$ cd cpupower | ||
$ make install PREFIX=/home/username/.local | ||
``` | ||
|
||
And with an admin user run the following commands: | ||
|
||
```shell | ||
$ sudo make install-tool TOOL_SUFFIX=username | ||
``` | ||
|
||
> Note: Also, use this command to update the tool for another user in an outdated installation. | ||
> Note: Using another PREFIX than `/usr` in this setup might include security risks and may not work. | ||
Restart the gnome-shell (log out and back in) to make the extension available. | ||
|
||
The extension will work out-of-the-box for this user only! | ||
|
||
#### Uninstalling | ||
|
||
```shell | ||
$ sudo make uninstall PREFIX=/home/username/.local | ||
$ sudo make uninstall-tool TOOL_SUFFIX=username | ||
``` | ||
|
||
### Installing for all users | ||
|
||
Clone the git repository and run the following command: | ||
|
||
```shell | ||
$ sudo make install install-tool | ||
``` | ||
|
||
This will install the extensions, polkit rule, and the tool for all users on the system. | ||
|
||
#### Uninstalling | ||
|
||
Run the following command to uninstall: | ||
|
||
```shell | ||
$ sudo make uninstall uninstall-tool | ||
``` | ||
|
||
## Translating | ||
|
||
In order to translate this extension you first need to install [`Poedit`](https://poedit.net/). You may use your distributions package manager to install it. | ||
|
||
When finished, [fork](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) this project and clone like described in the linked guide. | ||
|
||
### Creating a new translation | ||
|
||
Open Poedit and select `File` / `New From POT/PO File...` and select `cpupower/locale/template.pot`. Select the language you want to translate to. Now start translating. | ||
|
||
### Edit or update an existing translation | ||
|
||
Open Poedit and select `Open`. Navigate to the `cpupower/locale` folder and select the language file (`.po`) you want to edit/update. Now select `Catalog` / `Update from POT File...` and select `cpupower/locale/template.pot`. Now, you can start updating the translation. | ||
|
||
### Saving your work | ||
|
||
When finished save the file into the `locale` folder and [push](https://help.github.com/en/github/managing-files-in-a-repository/adding-a-file-to-a-repository-using-the-command-line) your changes to your fork. Now, you can create a [pull request](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request) to make your translation available in the main cpupower installation. | ||
|
||
## Packaging | ||
|
||
You are a package maintainer and looking into packaging this extension? Great! Below is a short summary of how to properly install this extension (run as `root`): | ||
|
||
```shell | ||
# make install install-tool PREFIX=/usr | ||
``` | ||
|
||
This will install a polkit rule to `/usr/share/polkit-1/actions/mko.cpupower.setcpufreq.policy` and an executable bash script to `/usr/bin/cpufreqctl`. The extension is installed to `/usr/share/gnome-shell/extensions/[email protected]`. It still includes the `scripts` folder, the policykit rule template in `data/mko.cpupower.policy.in`, a useless copy of the tool in the `tool` folder, and the `Makefile`. These are included in the distribution of the extension to enable user installation if the extension got installed over the GNOME extensions website. If you do not want to distribute those files in your package, you can safely remove them. | ||
|
||
> If you find any issues in packaging this extension, please don't hesitate to report them! | ||
## Developing | ||
|
||
### Option 1 | ||
|
||
Clone the repository and run: | ||
|
||
```shell | ||
$ make install PREFIX=/home/username/.local | ||
``` | ||
|
||
and reload the extension by restarting your gnome-shell. | ||
|
||
### Option 2 | ||
|
||
Clone the respository to `~/.local/share/gnome-shell/extensions/[email protected]` and reload the extension by restarting your gnome-shell. | ||
|
||
You can now enable the extension in your extension settings. | ||
|
||
### Viewing log output | ||
|
||
```shell | ||
$ journalctl /usr/bin/gnome-shell -f | ||
``` | ||
|
||
### Creating a new release | ||
|
||
Only core contributors to this project can make a new release. To create one, run: | ||
|
||
```shell | ||
$ make release | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
polkit.addRule(function(action, subject) { | ||
var idx = action.id.lastIndexOf('.'); | ||
var username_stripped = action.id.substring(0, idx); | ||
var username = action.id.substring(idx + 1); | ||
if (username_stripped === "mko.cpupower.setcpufreq") { | ||
if (subject.user === username) { | ||
return polkit.Result.YES; | ||
} else { | ||
return polkit.Result.NO; | ||
} | ||
} | ||
}); |
Oops, something went wrong.