Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite for GNOME >= 45 #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
# gnome-shell-extension-asus-rgb

gnome extension to control rgb lighting of asus laptops

extension link : https://extensions.gnome.org/extension/3454/rgb/

## extension for managing rgb on your asus laptop

![Screenshot](/screenshots/ss.png)

### advance menu

![Advance menu](/screenshots/ss3.png)

## Update

if installing version 2 of extension u need to install one addtional file: https://github.com/drunckj/rog-rgb-control/releases/download/v2.0/RogRgbControl.deb

## requirements

## requirements
- rogauracore
- asusctl
- libusb-dev-1.0
- autoconf

### steps for installation of requirements

```
wget https://raw.githubusercontent.com/drunckj/gnome-shell-extension-asus-rgb/master/requirements/setup.sh
chmod +x setup.sh
./setup.sh
```

# for other desktop environments
ive created a full app for managing rgb lights on rog machines: https://github.com/drunckj/rog-rgb-control
# for other desktop environments

ive created a full app for managing rgb lights on rog machines: https://github.com/drunckj/rog-rgb-control

#### Want to buy me a coffee: https://www.paypal.me/drunkcj
18 changes: 18 additions & 0 deletions brightnessOptions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default [
{
label: "Off",
cmd: "off",
},
{
label: "Low",
cmd: "low",
},
{
label: "Med",
cmd: "med",
},
{
label: "High",
cmd: "high",
},
];
30 changes: 30 additions & 0 deletions colors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export default [
{
label: "Green",
color: "00ff00",
},
{
label: "Blue",
color: "0000ff",
},
{
label: "White",
color: "ffffff",
},
{
label: "Yellow",
color: "ffff00",
},
{
label: "Magenta",
color: "ff00ff",
},
{
label: "Pink",
color: "ff69b4",
},
{
label: "Sky Blue",
color: "87ceeb",
},
];
221 changes: 98 additions & 123 deletions extension.js
Original file line number Diff line number Diff line change
@@ -1,127 +1,102 @@
const Main = imports.ui.main;
const St = imports.gi.St;
const GObject = imports.gi.GObject;
const Gio = imports.gi.Gio;
const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const GLib = imports.gi.GLib;
let myPopup;

const MyPopup = GObject.registerClass(
class MyPopup extends PanelMenu.Button {

_init () {

super._init(0);

let icon = new St.Icon({
//icon_name : 'security-low-symbolic',
gicon : Gio.icon_new_for_string( Me.dir.get_path() + '/icon.svg' ),
style_class : 'system-status-icon',
});

this.add_child(icon);
//RED
let red = new PopupMenu.PopupMenuItem('Red');
this.menu.addMenuItem(red);
red.connect('activate', () => {
check("red");
});
//BLUE
let blue = new PopupMenu.PopupMenuItem('Blue');
this.menu.addMenuItem(blue);
blue.connect('activate', () => {
check("blue");
});
//GREEN
let green = new PopupMenu.PopupMenuItem('Green');
this.menu.addMenuItem(green);
green.connect('activate', () => {
check("green");
});
//yellow
let yellow = new PopupMenu.PopupMenuItem('Yellow');
this.menu.addMenuItem(yellow);
yellow.connect('activate', () => {
check("yellow");
});
//gold
let gold = new PopupMenu.PopupMenuItem('Gold');
this.menu.addMenuItem(gold);
gold.connect('activate', () => {
check("gold");
});
//cyan
let cyan = new PopupMenu.PopupMenuItem('Cyan');
this.menu.addMenuItem(cyan);
cyan.connect('activate', () => {
check("cyan");
});
//PURPLE
let magenta = new PopupMenu.PopupMenuItem('Purple');
this.menu.addMenuItem(magenta);
magenta.connect('activate', () => {
check("magenta");
});
//white
let white = new PopupMenu.PopupMenuItem('White');
this.menu.addMenuItem(white);
white.connect('activate', () => {
check("white");
});
//keyboard off
let black = new PopupMenu.PopupMenuItem('Rgb off');
this.menu.addMenuItem(black);
black.connect('activate', () => {
check("black");
});




// sub menu
let subItem = new PopupMenu.PopupSubMenuMenuItem('Brightness');
this.menu.addMenuItem(subItem);
let one=new PopupMenu.PopupMenuItem('1');
let two=new PopupMenu.PopupMenuItem('2');
let three=new PopupMenu.PopupMenuItem('3');
subItem.menu.addMenuItem(one, 0);
one.connect('activate', () => {
bright("1");
});
subItem.menu.addMenuItem(two, 1);
subItem.menu.addMenuItem(three, 2);
two.connect('activate', () => {
bright("2");
});
three.connect('activate', () => {
bright("3");
});


import St from "gi://St";
import GObject from "gi://GObject";
import Gio from "gi://Gio";

import * as PopupMenu from "resource:///org/gnome/shell/ui/popupMenu.js";
import * as PanelMenu from "resource:///org/gnome/shell/ui/panelMenu.js";
import { Extension } from "resource:///org/gnome/shell/extensions/extension.js";
import * as Main from "resource:///org/gnome/shell/ui/main.js";

import colors from "./colors.js";
import brightnessOptions from "./brightnessOptions.js";
import rgbOptions from "./rgbOptions.js";

import GLib from "gi://GLib";

const Indicator = GObject.registerClass(
class Indicator extends PanelMenu.Button {
_init() {
const IconPath = GLib.Uri.resolve_relative(
import.meta.url,
"icon.svg",
GLib.UriFlags.NONE
);
console.log("Icon Path: ", IconPath);
super._init(0.0, _("My Indicator"));

let icon = new St.Icon({
gicon: Gio.icon_new_for_string(IconPath),
style_class: "system-status-icon",
});

this.add_child(icon);

// Create submenus and menus

const brightnessControl = new PopupMenu.PopupSubMenuMenuItem(
"Keyboard Brightness"
);

const colorControl = new PopupMenu.PopupSubMenuMenuItem("Keyboard Color");

const RBGControl = new PopupMenu.PopupSubMenuMenuItem("RGB Mode");

brightnessOptions.forEach(({ label, cmd }) => {
const option = new PopupMenu.PopupMenuItem(label);
option.connect("activate", () => {
this._setBrightness(cmd);
});
brightnessControl.menu.addMenuItem(option);
});

colors.forEach(({ label, color }) => {
const option = new PopupMenu.PopupMenuItem(label);
option.connect("activate", () => {
this._setColor(color);
});
colorControl.menu.addMenuItem(option);
});

rgbOptions.forEach(({ name, cmd }) => {
const option = new PopupMenu.PopupMenuItem(name, {
reactive: true,
can_focus: true,
style_class: "menu-item",
});

option.connect("activate", () => {
this._setRGBMode(cmd);
});
RBGControl.menu.addMenuItem(option);
});

this.menu.addMenuItem(brightnessControl);
this.menu.addMenuItem(RBGControl);
this.menu.addMenuItem(colorControl);
}

_setColor(color) {
GLib.spawn_command_line_async(`asusctl led-mode static -c ${color}`);
}

_setRGBMode(mode) {
GLib.spawn_command_line_async(`asusctl led-mode ${mode}`);
}

_setBrightness(value) {
GLib.spawn_command_line_async(`asusctl -k ${value}`);
}
}
});
//------------------------------------------------------------------------------
);

export default class IndicatorExampleExtension extends Extension {
enable() {
this._indicator = new Indicator();
Main.panel.addToStatusArea(this.uuid, this._indicator);
}

//-----------------------------------------------------------------------------
function init() {
}

function enable() {
myPopup = new MyPopup();
Main.panel.addToStatusArea('myPopup', myPopup, 1);
}

function disable() {
myPopup.destroy();
}
function check(command){
GLib.spawn_command_line_sync("rogauracore "+command);

}

function bright(value){
GLib.spawn_command_line_sync("rogauracore brightness "+value);
disable() {
this._indicator.destroy();
this._indicator = null;
}
}
5 changes: 3 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
"name" : "RGB",
"description" : "Rgb control for asus laptops",
"shell-version" : [
"3.36"
"45",
"46"
],
"url" : "",
"uuid" : "rgb@drunkcj.com",
"version" : 1.0
"version" : 1.1
}
18 changes: 18 additions & 0 deletions rgbOptions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default [
{
name: "Static",
cmd: "static -c ffffff",
},
{
name: "Breathe",
cmd: "breathe",
},
{
name: "Strobe",
cmd: "strobe",
},
{
name: "Pulse",
cmd: "pulse",
},
];