From 3a9d68fee6e12f2e1a5a4db2279a81e01a27a8ce Mon Sep 17 00:00:00 2001 From: Cam Date: Thu, 15 Feb 2024 14:09:29 -0500 Subject: [PATCH] Fix and update Wayland --- README.md | 2 +- install.sh | 4 +++ src/_installWayland.sh | 16 ++++----- src/_installX11.sh | 5 +-- src/nagaServerCatcher.sh | 2 +- src/nagaWayland.cpp | 36 ++++++++++++------- src/nagaX11.cpp | 9 ++++- .../extension.js | 4 +-- 8 files changed, 49 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 6b1231a..5b33f0c 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Works for sure with : `naga start` //Starts a daemon. `naga edit ($EDITOR)` //Edits naga config, then restart service if edited. (you can also specify editor : naga edit vim) - `naga debug` //Shows logs in realt time. + `naga debug` //Shows logs in realt time. (Add arg to override journalctl's args.) `naga stop` //Stops the daemon. `naga fix` //Restarts usb services. `naga uninstall` //Uninstalls the daemon tool. diff --git a/install.sh b/install.sh index 5d12774..be1ed4e 100755 --- a/install.sh +++ b/install.sh @@ -30,8 +30,12 @@ printf 'KERNEL=="event[0-9]*",SUBSYSTEM=="input",GROUP="razerInputGroup",MODE="6 LOGINTYPE=$(loginctl show-session $(loginctl | grep $(whoami) | awk '{print $1}') -p Type) if [ "$LOGINTYPE" = "Type=wayland" ]; then sh ./src/_installWayland.sh + sed -i '/alias naga=/d' ~/.bash_aliases + grep 'alias naga=' ~/.bash_aliases || printf "alias naga='nagaWayland'" | tee -a ~/.bash_aliases > /dev/null else sh ./src/_installX11.sh + sudo sed -i '/alias naga=/d' ~/.bash_aliases + grep 'alias naga=' ~/.bash_aliases || printf "alias naga='nagaX11'" | tee -a ~/.bash_aliases > /dev/null fi if [ "$LOGINTYPE" = "Type=wayland" ]; then diff --git a/src/_installWayland.sh b/src/_installWayland.sh index 08c2eef..df0ab7a 100644 --- a/src/_installWayland.sh +++ b/src/_installWayland.sh @@ -1,6 +1,6 @@ #!/bin/bash -sudo apt install -y g++ nano pkexec procps wget gnome-shell-extension-prefs dbus-x11 curl libdbus-1-dev +sudo apt install -y g++ nano pkexec procps wget gnome-shell-extension-prefs dbus-x11 curl libdbus-1-dev libxkbcommon-dev echo "Checking requirements..." @@ -26,14 +26,16 @@ sudo chmod 755 /usr/local/bin/nagaWayland echo "Installing dotool :" -wget https://git.sr.ht/~geb/dotool/archive/874650ad22dfb20ef24ab1f78666aa2e5178a0f0.tar.gz -O dotool.tar.gz +sleep 1 +wget https://git.sr.ht/~geb/dotool/archive/b5812c001daeeaff1f259031661e47f3a612220c.tar.gz -O dotool.tar.gz tar -xf dotool.tar.gz > /dev/null -mv -f dotool-874650ad22dfb20ef24ab1f78666aa2e5178a0f0 dotool > /dev/null +mv -fu dotool-b5812c001daeeaff1f259031661e47f3a612220c dotool > /dev/null +sleep 1 cd dotool -sudo sh install.sh > /dev/null +./build.sh +sudo ./build.sh install cd .. -#rm -rdf dotool -rm -f dotool.tar.gz > /dev/null +rm -rf dotool* > /dev/null cp -rf ./src/window-calls-extended@hseliger.eu ~/.local/share/gnome-shell/extensions @@ -47,5 +49,3 @@ sudo chown -R "root:root" "$_dir"/keyMapWayland.txt sudo groupadd -f razerInputGroup printf 'KERNEL=="uinput", GROUP="razerInputGroup"' | sudo tee /etc/udev/rules.d/80-nagaWayland.rules >/dev/null - -grep 'alias naga=' ~/.bash_aliases || printf "alias naga='nagaWayland'" | tee -a ~/.bash_aliases > /dev/null diff --git a/src/_installX11.sh b/src/_installX11.sh index 24c73d1..5f8ca7f 100644 --- a/src/_installX11.sh +++ b/src/_installX11.sh @@ -45,7 +45,4 @@ sudo chmod 755 /usr/local/bin/nagaX11 _dir="/home/$USER/.naga" mkdir -p "$_dir" sudo cp -r -n -v "keyMap.txt" "$_dir" -sudo chown -R "root:root" "$_dir"/keyMap.txt - - -grep 'alias naga=' ~/.bash_aliases || printf "alias naga='nagaX11'" | tee -a ~/.bash_aliases > /dev/null \ No newline at end of file +sudo chown -R "root:root" "$_dir"/keyMap.txt \ No newline at end of file diff --git a/src/nagaServerCatcher.sh b/src/nagaServerCatcher.sh index accf463..d8fc5de 100644 --- a/src/nagaServerCatcher.sh +++ b/src/nagaServerCatcher.sh @@ -1,7 +1,7 @@ #!/bin/sh #Finds the visual server and starts the right one if [ "$(loginctl show-session $(loginctl | grep $(whoami) | awk '{print $1}') -p Type)" = "Type=wayland" ]; then - killall dotoold + killall dotoold > /dev/null 2>&1 setsid bash -c 'dotoold'& if [ $# -eq 0 ]; then nagaWayland serviceHelper diff --git a/src/nagaWayland.cpp b/src/nagaWayland.cpp index 81c8bab..7b7fe2b 100644 --- a/src/nagaWayland.cpp +++ b/src/nagaWayland.cpp @@ -34,7 +34,7 @@ static const string getTitle() DBusConnection *connection = dbus_bus_get(DBUS_BUS_SESSION, &error); if (dbus_error_is_set(&error)) { - std::cerr << "Error connecting to bus: " << error.message << std::endl; + cerr << "Error connecting to bus: " << error.message << endl; dbus_error_free(&error); return ""; } @@ -42,14 +42,14 @@ static const string getTitle() DBusMessage *message = dbus_message_new_method_call(DB_DESTINATION, DB_PATH, DB_INTERFACE, DB_METHOD); if (message == nullptr) { - std::cerr << "Error creating message" << std::endl; + cerr << "Error creating message" << endl; return ""; } DBusMessage *reply = dbus_connection_send_with_reply_and_block(connection, message, -1, &error); if (dbus_error_is_set(&error)) { - std::cerr << "Error calling method: " << error.message << std::endl; + cerr << "Error calling method: " << error.message << endl; dbus_error_free(&error); return ""; } @@ -57,7 +57,7 @@ static const string getTitle() char *result; if (!dbus_message_get_args(reply, &error, DBUS_TYPE_STRING, &result, DBUS_TYPE_INVALID)) { - std::cerr << "Error reading reply: " << error.message << std::endl; + cerr << "Error reading reply: " << error.message << endl; dbus_error_free(&error); return ""; } @@ -143,6 +143,7 @@ class configSwitchScheduler loadConf(true); } } + } void remapRoutine() { @@ -161,6 +162,7 @@ class configSwitchScheduler } void scheduleReMap(const string *const reMapStr) { + clog << "Remap Routine"< guard(configSwitcherMutex); if (winConfigActive) { @@ -197,12 +199,11 @@ class NagaDaemon const int size = sizeof(ev1); vector> devices; bool areSideBtnEnabled = true, areExtraBtnEnabled = true; - map>> *currentConfigPtr; void initConf() { string commandContent; - map>> *iteratedConfig; + map>> *iteratedConfig; bool isIteratingConfig = false; ifstream in(conf_file.c_str(), ios::in); @@ -255,13 +256,16 @@ class NagaDaemon if (!configKeysMap[commandType]->Prefix()->empty()) commandContent = *configKeysMap[commandType]->Prefix() + commandContent; + if (!configKeysMap[commandType]->Suffix()->empty()) + commandContent = commandContent + *configKeysMap[commandType]->Suffix(); + (*iteratedButtonConfig)[configKeysMap[commandType]->IsOnKeyPressed()].emplace_back(new MacroEvent(configKeysMap[commandType], new string(commandContent))); // Encode and store mapping v3 } else if (commandType == "key") { - string *commandContent2 = new string(*configKeysMap["keyreleaseonrelease"]->Prefix() + commandContent); - commandContent = *configKeysMap["keypressonpress"]->Prefix() + commandContent; + string *commandContent2 = new string(*configKeysMap["keyreleaseonrelease"]->Prefix() + commandContent + *configKeysMap["keyreleaseonrelease"]->Suffix()); + commandContent = *configKeysMap["keypressonpress"]->Prefix() + commandContent + *configKeysMap["keypressonpress"]->Suffix(); (*iteratedButtonConfig)[true].emplace_back(new MacroEvent(configKeysMap["keypressonpress"], new string(commandContent))); (*iteratedButtonConfig)[false].emplace_back(new MacroEvent(configKeysMap["keyreleaseonrelease"], new string(*commandContent2))); } @@ -321,7 +325,7 @@ class NagaDaemon { case 2 ... 13: configSwitcher->checkForWindowConfig(); - thread(runActions, &(*currentConfigPtr)[ev11->code][ev11->value == 1]).detach(); // real key number = ev11->code - 1 + thread(runActions, &(*configSwitcher->currentConfigPtr)[ev11->code][ev11->value == 1]).detach(); // real key number = ev11->code - 1 break; } } @@ -336,7 +340,7 @@ class NagaDaemon { case 275 ... 276: configSwitcher->checkForWindowConfig(); - thread(runActions, &(*currentConfigPtr)[ev11->code - 261][ev11->value == 1]).detach(); // real key number = ev11->code - OFFSET (#262) + thread(runActions, &(*configSwitcher->currentConfigPtr)[ev11->code - 261][ev11->value == 1]).detach(); // real key number = ev11->code - OFFSET (#262) break; } } @@ -388,6 +392,7 @@ class NagaDaemon const static void executeThreadNow(const string *const macroContent) { thread(executeNow, macroContent).detach(); + clog<<"EXECUTED : "<< macroContent->c_str() << endl; } // end of configKeys functions @@ -399,7 +404,7 @@ class NagaDaemon } } - void emplaceConfigKey(const std::string &key, bool onKeyPressed, auto functionPtr, const std::string &prefix = "", const std::string &suffix = "") + void emplaceConfigKey(const string &key, bool onKeyPressed, auto functionPtr, const string &prefix = "", const string &suffix = "") { configKeysMap.emplace(key, new configKey(onKeyPressed, functionPtr, prefix, suffix)); } @@ -522,7 +527,14 @@ int main(const int argc, const char *const argv[]) else if (strstr(argv[1], "debug") != NULL) { clog << "Starting naga debug, logs :" << endl; - (void)!(system("journalctl -fu naga")); + if (argc > 2) + { + (void)!(system(("journalctl " + string(argv[2]) + " naga").c_str())); + } + else + { + (void)!(system("journalctl -fu naga")); + } } else if (strstr(argv[1], "kill") != NULL || strstr(argv[1], "stop") != NULL) { diff --git a/src/nagaX11.cpp b/src/nagaX11.cpp index 418265f..fa5a611 100644 --- a/src/nagaX11.cpp +++ b/src/nagaX11.cpp @@ -538,7 +538,14 @@ int main(const int argc, const char *const argv[]) else if (strstr(argv[1], "debug") != NULL) { clog << "Starting naga debug, logs :" << endl; - (void)!(system("journalctl -fu naga")); + if (argc > 2) + { + (void)!(system(("journalctl " + string(argv[2]) + " naga").c_str())); + } + else + { + (void)!(system("journalctl -fu naga")); + } } else if (strstr(argv[1], "kill") != NULL || strstr(argv[1], "stop") != NULL) { diff --git a/src/window-calls-extended@hseliger.eu/extension.js b/src/window-calls-extended@hseliger.eu/extension.js index 04c0088..30ba694 100644 --- a/src/window-calls-extended@hseliger.eu/extension.js +++ b/src/window-calls-extended@hseliger.eu/extension.js @@ -27,7 +27,7 @@ /* exported init */ -const { Gio } = imports.gi; +import Gio from 'gi://Gio'; const MR_DBUS_IFACE = ` @@ -38,7 +38,7 @@ const MR_DBUS_IFACE = ` `; -class Extension { +export default class WCExtension { enable() { this._dbus = Gio.DBusExportedObject.wrapJSObject(MR_DBUS_IFACE, this); this._dbus.export(Gio.DBus.session, '/org/gnome/Shell/Extensions/WindowsExt');