-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 419e5a8
Showing
14 changed files
with
764 additions
and
0 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,45 @@ | ||
name: Build and Release Extension | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
build-and-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Install build tools | ||
run: sudo apt-get update && sudo apt-get install -y make zip jq | ||
- name: Build extension | ||
run: make | ||
- name: Locate built ZIP file | ||
id: find_zip | ||
run: | | ||
ZIP_FILE=$(ls *.zip | head -n 1) | ||
if [ -z "$ZIP_FILE" ]; then | ||
echo "No ZIP file found!" | ||
exit 1 | ||
fi | ||
echo "ZIP_FILE=$ZIP_FILE" >> $GITHUB_ENV | ||
- name: Create GitHub Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref_name }} | ||
release_name: Release ${{ github.ref_name }} | ||
draft: false | ||
prerelease: false | ||
- name: Upload Build Artifact | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ${{ env.ZIP_FILE }} | ||
asset_name: ${{ env.ZIP_FILE }} | ||
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
*.zip |
Large diffs are not rendered by default.
Oops, something went wrong.
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,18 @@ | ||
.PHONY: all install clean | ||
|
||
UUID := $(shell jq -r .uuid metadata.json) | ||
VERSION := $(shell jq .version metadata.json) | ||
ZIP_NAME := $(UUID).shell-extension.zip | ||
|
||
all: $(ZIP_NAME) | ||
|
||
$(ZIP_NAME): | ||
rm -f schemas/gschemas.compiled | ||
glib-compile-schemas ./schemas | ||
zip -r $(ZIP_NAME) metadata.json icons/ schemas/ prefs.js extension.js | ||
|
||
install: | ||
gnome-extensions install -f $(ZIP_NAME) | ||
|
||
clean: | ||
rm -f $(ZIP_NAME) |
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,71 @@ | ||
![License](https://img.shields.io/github/license/amnezia-vpn/toggle-awg-gnome-shell) | ||
|
||
# Toggle AWG Extension | ||
|
||
A GNOME Shell extension that allows you to toggle the **AWG Quick Service** conveniently from the system status bar. The extension supports custom icons for light and dark themes, which can be manually configured through the preferences. | ||
|
||
## Features | ||
|
||
- Start/Stop awg-quick Service with a single click. | ||
- Configure the interface name directly in the settings. | ||
- Customizable icons for active/inactive states for both dark and light themes. | ||
- Manual theme selection for icons (dark or light). | ||
- Adjustable icon size. | ||
|
||
## Gnome Versions Support | ||
|
||
- 43 - `master` branch, `v1` tag | ||
|
||
## Manual Installation | ||
|
||
### Get extension from GIT: | ||
|
||
```bash | ||
git clone https://github.com/amnezia-vpn/toggle-awg-gnome-shell.git ~/.local/share/gnome-shell/extensions/toggle-awg@amnezia-vpn | ||
``` | ||
> add `--branch v<version tag>` if you need exact version | ||
### Get extension from ZIP: | ||
```bash | ||
wget https://github.com/amnezia-vpn/toggle-awg-gnome-shell/releases/download/latest/[email protected] | ||
gnome-extensions install [email protected] --force | ||
``` | ||
|
||
> Replace `latest` in url with `v<version tag>` if you need exact version | ||
### Apply extension | ||
|
||
1. Restart GNOME Shell | ||
- *For X11*: press `Alt + F2`, type `r`, and hit `Enter`. | ||
- *For Wayland*: logout and login again | ||
|
||
2. Enable the extension using GNOME Extensions app or with `gnome-extensions enable toggle-awg@amnezia-vpn` command | ||
|
||
## Configuration | ||
|
||
Open the extension preferences through the GNOME Extensions app to configure the following: | ||
|
||
- *Interface Name*: Specify the system interface name (default is awg1). | ||
- *Icon Size*: Adjust the size of the icons displayed in the system panel. | ||
- *Icon Theme*: Choose between dark or light theme icons. | ||
|
||
## Work Mechanics | ||
|
||
The extension interacts with the systemctl command to manage the AWG Quick Service: | ||
|
||
- *Start*: `sudo systemctl start awg-quick@<interface>` | ||
- *Stop*: `sudo systemctl stop awg-quick@<interface>` | ||
|
||
Ensure that the awg-quick service is properly configured on your system. | ||
|
||
## AmneziaWG client setup | ||
|
||
TODO | ||
|
||
## License | ||
|
||
This project is licensed under the GPL-2.0 License. See the [LICENSE](LICENSE) file for details. | ||
|
||
## Contribution | ||
|
||
Feel free to open issues or submit pull requests to improve this extension. |
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,104 @@ | ||
const { GObject, St, Gio, GLib } = imports.gi; | ||
const Main = imports.ui.main; | ||
const PanelMenu = imports.ui.panelMenu; | ||
const ExtensionUtils = imports.misc.extensionUtils; | ||
const Me = ExtensionUtils.getCurrentExtension(); | ||
const Util = imports.misc.util; | ||
|
||
class ToggleAWG { | ||
constructor(settings) { | ||
this._isActive = false; | ||
this.settings = settings; | ||
} | ||
|
||
_getIconPath(isActive) { | ||
const manualTheme = this.settings.get_string('manual-theme'); | ||
const iconType = manualTheme === 'dark' ? 'dark' : 'light'; | ||
return `${Me.path}/icons/${isActive ? 'active-' : 'inactive-'}${iconType}.png`; | ||
} | ||
|
||
toggleService() { | ||
const iface = this.settings.get_string('interface'); | ||
if (!iface) { | ||
Main.notify('Toggle AWG', 'No interface set in settings!'); | ||
return; | ||
} | ||
|
||
const action = this._isActive ? 'stop' : 'start'; | ||
const command = ['sudo', 'systemctl', action, `awg-quick@${iface}`]; | ||
|
||
Util.spawn(command); | ||
this._isActive = !this._isActive; | ||
} | ||
} | ||
|
||
var ToggleAWGButton = GObject.registerClass( | ||
class ToggleAWGButton extends PanelMenu.Button { | ||
_init(toggleAWG, settings) { | ||
super._init(0.0, 'Toggle AWG Button'); | ||
this.toggleAWG = toggleAWG; | ||
this.settings = settings; | ||
|
||
this._icon = this._createIcon(false); | ||
this.add_child(this._icon); | ||
|
||
this.connect('button-press-event', () => { | ||
this.toggleAWG.toggleService(); | ||
this._updateIcon(); | ||
}); | ||
|
||
this.settings.connect('changed', () => this._updateIcon()); | ||
} | ||
|
||
_createIcon(isActive) { | ||
return new St.Icon({ | ||
gicon: Gio.icon_new_for_string(this.toggleAWG._getIconPath(isActive)), | ||
icon_size: this.settings.get_int('icon-size'), | ||
style_class: 'system-status-icon', | ||
}); | ||
} | ||
|
||
_updateIcon() { | ||
const isActive = this.toggleAWG._isActive; | ||
this._icon.gicon = Gio.icon_new_for_string(this.toggleAWG._getIconPath(isActive)); | ||
this._icon.icon_size = this.settings.get_int('icon-size'); | ||
} | ||
} | ||
); | ||
|
||
class Extension { | ||
constructor() { | ||
} | ||
|
||
_initializeDefaults() { | ||
if (!this._settings.get_string('interface')) { | ||
this._settings.set_string('interface', 'awg0'); | ||
} | ||
if (!this._settings.get_int('icon-size')) { | ||
this._settings.set_int('icon-size', 32); | ||
} | ||
if (!this._settings.get_string('manual-theme')) { | ||
this._settings.set_string('manual-theme', 'dark'); | ||
} | ||
} | ||
|
||
enable() { | ||
this._button = null; | ||
this._settings = ExtensionUtils.getSettings('org.gnome.shell.extensions.toggle-awg'); | ||
this._initializeDefaults(); | ||
const toggleAWG = new ToggleAWG(this._settings); | ||
this._button = new ToggleAWGButton(toggleAWG, this._settings); | ||
Main.panel.addToStatusArea('toggle-awg-button', this._button); | ||
} | ||
|
||
disable() { | ||
if (this._button) { | ||
this._button.destroy(); | ||
this._button = null; | ||
} | ||
} | ||
} | ||
|
||
function init() { | ||
return new Extension(); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,9 @@ | ||
{ | ||
"uuid": "toggle-awg@amnezia-vpn", | ||
"name": "AmneziaWG Toggle Button", | ||
"description": "A button to toggle AmneziaWG service on/off", | ||
"shell-version": ["43"], | ||
"url": "https://github.com/amnezia-vpn/toggle-awg-gnome-shell", | ||
"settings-schema": "org.gnome.shell.extensions.toggle-awg", | ||
"version": 1 | ||
} |
Oops, something went wrong.