Skip to content

Commit

Permalink
Format ;)
Browse files Browse the repository at this point in the history
  • Loading branch information
lostallmymoney committed Feb 16, 2024
1 parent 5ab21bd commit ffd8f88
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 40 deletions.
16 changes: 6 additions & 10 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
if [ "$(id -u)" = "0" ]; then
printf "This script must not be executed as root\n"
exit 1
printf "This script must not be executed as root\n"
exit 1
fi

sudo sh src/nagaKillroot.sh >/dev/null
Expand Down Expand Up @@ -29,14 +29,13 @@ 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
if ! nc -z 8.8.8.8 53 >/dev/null 2>&1
then
if ! nc -z 8.8.8.8 53 >/dev/null 2>&1; then
printf "\033[0;31mNO INTERNET CONNECTION\033[0m\n"
exit 1
fi
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
grep 'alias naga=' ~/.bash_aliases || printf "alias naga='nagaWayland'" | tee -a ~/.bash_aliases >/dev/null

while true; do
printf "\033[38;2;255;165;0mNaga for Wayland is currently installing,\n do you want to install for X11 too ? (recommended) y/n : \033[0m"
Expand All @@ -53,15 +52,14 @@ if [ "$LOGINTYPE" = "Type=wayland" ]; then
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
grep 'alias naga=' ~/.bash_aliases || printf "alias naga='nagaX11'" | tee -a ~/.bash_aliases >/dev/null

while true; do
printf "\033[38;2;255;165;0mNaga for Wayland is currently installing,\n do you want to install for X11 too ? (recommended) y/n : \033[0m"
read -r yn
case $yn in
[Yy]*)
if ! nc -z 8.8.8.8 53 >/dev/null 2>&1
then
if ! nc -z 8.8.8.8 53 >/dev/null 2>&1; then
printf "\033[0;31mNO INTERNET CONNECTION\033[0m\n"
exit 1
fi
Expand Down Expand Up @@ -90,15 +88,13 @@ sudo udevadm control --reload-rules && sudo udevadm trigger
sleep 0.5
sudo cat /etc/sudoers | grep -qxF "$USER ALL=(ALL) NOPASSWD:/bin/systemctl start naga" || printf "\n%s ALL=(ALL) NOPASSWD:/bin/systemctl start naga\n" "$USER" | sudo EDITOR='tee -a' visudo >/dev/null


sudo systemctl enable naga
sudo systemctl start naga

printf "\033[0;32mService started !\nStop with naga service stop\nStart with naga service start\033[0m\n"
printf "Star the repo here 😁 :\n"
printf "\033[0;35mhttps://github.com/lostallmymoney/Razer_Mouse_Linux\033[0m\n\n"


xdg-open https://github.com/lostallmymoney/Razer_Mouse_Linux >/dev/null 2>&1

if [ "$LOGINTYPE" = "Type=wayland" ]; then
Expand Down
10 changes: 6 additions & 4 deletions src/_installWayland.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

printf "Installing requirements...\n"

sudo apt install -y g++ nano pkexec procps wget gnome-shell-extension-prefs dbus-x11 curl libdbus-1-dev libxkbcommon-dev golang-go scdoc

printf "Checking requirements...\n"
Expand Down Expand Up @@ -27,20 +29,20 @@ printf "Installing dotool :\n"

sleep 0.1
wget https://git.sr.ht/~geb/dotool/archive/b5812c001daeeaff1f259031661e47f3a612220c.tar.gz -O dotool.tar.gz
tar -xf dotool.tar.gz > /dev/null
mv -fu dotool-b5812c001daeeaff1f259031661e47f3a612220c dotool > /dev/null
tar -xf dotool.tar.gz >/dev/null
mv -fu dotool-b5812c001daeeaff1f259031661e47f3a612220c dotool >/dev/null
sleep 0.1
cd dotool || exit 1
./build.sh
sudo ./build.sh install
cd ..
sleep 0.1
rm -rf dotool* > /dev/null
rm -rf dotool* >/dev/null
sleep 0.1

clear -x

sudo gnome-extensions disable window-calls-extended@hseliger.eu > /dev/null
sudo gnome-extensions disable window-calls-extended@hseliger.eu >/dev/null
sudo gnome-extensions uninstall -q window-calls-extended@hseliger.eu
gnome-extensions install ./src/window-calls-extended@hseliger.eu.shell-extension.zip --force

Expand Down
1 change: 0 additions & 1 deletion src/_installX11.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ fi
sudo mv ./src/nagaX11 /usr/local/bin/
sudo chmod 755 /usr/local/bin/nagaX11


_dir="/home/$USER/.naga"
mkdir -p "$_dir"
sudo cp -r -n -v "keyMap.txt" "$_dir"
Expand Down
13 changes: 6 additions & 7 deletions src/fakeKeysX11.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ struct FakeKey
KeySym *keysyms;
KeyCode modifier_table[N_MODIFIER_INDEXES];

~FakeKey() {
XFree(keysyms);
}
~FakeKey()
{
XFree(keysyms);
}
};

static int utf8_to_ucs4(const unsigned char *src_orig, unsigned int *dst, int len)
Expand Down Expand Up @@ -97,7 +98,6 @@ FakeKey *fakekey_init(Display *xdpy)
if (xdpy == NULL || !XTestQueryExtension(xdpy, &event, &error, &major, &minor))
return NULL;


fk = (FakeKey *)malloc(sizeof(FakeKey));
memset(fk, 0, sizeof(FakeKey));

Expand Down Expand Up @@ -149,7 +149,7 @@ int fakekey_send_keyevent(FakeKey *fk, KeyCode keycode, Bool is_press, int flags
XTestFakeKeyEvent(fk->xdpy, fk->modifier_table[ControlMapIndex],
is_press, CurrentTime);

if (flags & Mod1Mask) //ALT MASK
if (flags & Mod1Mask) // ALT MASK
XTestFakeKeyEvent(fk->xdpy, fk->modifier_table[Mod1MapIndex],
is_press, CurrentTime);

Expand Down Expand Up @@ -228,7 +228,7 @@ int fakekey_press(FakeKey *fk, const unsigned char *utf8_char_in, int len_bytes,
unsigned int ucs4_out;

if (fk->held_keycode) /* key is already held down */
return 0;
return 0;

if (len_bytes < 0)
{
Expand All @@ -243,7 +243,6 @@ int fakekey_press(FakeKey *fk, const unsigned char *utf8_char_in, int len_bytes,
if (ucs4_out > 0x00ff) /* < 0xff assume Latin-1 1:1 mapping */
ucs4_out = ucs4_out | 0x01000000; /* This gives us the magic X keysym */


return fakekey_press_keysym(fk, (KeySym)ucs4_out, flags);
}

Expand Down
20 changes: 10 additions & 10 deletions src/nagaKillroot.sh
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
#!/bin/sh
# shellcheck disable=SC2046
# shellcheck disable=SC2009
if [ "$(id -u)" -ne 0 ];then
if [ "$(id -u)" -ne 0 ]; then
if [ $# -eq 0 ]; then
#X11
kill $(pgrep -f "nagaX11 serviceHelper") > /dev/null 2>&1
kill $(pgrep -f "nagaX11 serviceHelper") >/dev/null 2>&1
if [ "$(pgrep -f "nagaX11 serviceHelper" -G 0 -c)" -ne 0 ]; then
pkexec --user root kill $(pgrep -f "nagaX11 serviceHelper" -G 0)
fi
#Wayland
kill $(pgrep -f "nagaWayland serviceHelper") > /dev/null 2>&1
kill $(pgrep -f "nagaWayland serviceHelper") >/dev/null 2>&1
if [ "$(pgrep -f "nagaWayland serviceHelper" -G 0 -c)" -ne 0 ]; then
pkexec --user root kill $(pgrep -f "nagaWayland serviceHelper" -G 0)
fi
else
#X11
kill $(pgrep -f "nagaX11 serviceHelper" | grep -v "$1") > /dev/null 2>&1
kill $(pgrep -f "nagaX11 serviceHelper" | grep -v "$1") >/dev/null 2>&1
if [ "$(pgrep -f "nagaX11 serviceHelper" -G 0 | grep -v "$1" -c)" -ne 0 ]; then
pkexec --user root kill $(pgrep -f "nagaX11 serviceHelper" -G 0 | grep -v "$1")
fi
#Wayland
kill $(pgrep -f "nagaWayland serviceHelper" | grep -v "$1") > /dev/null 2>&1
kill $(pgrep -f "nagaWayland serviceHelper" | grep -v "$1") >/dev/null 2>&1
if [ "$(pgrep -f "nagaWayland serviceHelper" -G 0 | grep -v "$1" -c)" -ne 0 ]; then
pkexec --user root kill $(pgrep -f "nagaWayland serviceHelper" -G 0 | grep -v "$1")
fi
fi
fi
else
if [ $# -eq 0 ]; then
#X11
kill $(ps aux | grep "nagaX11 serviceHelper" | grep -v root | grep -v grep | awk '{print $2}') > /dev/null 2>&1
kill $(ps aux | grep "nagaX11 serviceHelper" | grep -v root | grep -v grep | awk '{print $2}') >/dev/null 2>&1
if [ "$(pgrep -f "nagaX11 serviceHelper" -G 0 -c)" -ne 0 ]; then
kill $(pgrep -f "nagaX11 serviceHelper" -G 0)
fi
#Wayland
kill $(ps aux | grep "nagaWayland serviceHelper" | grep -v root | grep -v grep | awk '{print $2}') > /dev/null 2>&1
kill $(ps aux | grep "nagaWayland serviceHelper" | grep -v root | grep -v grep | awk '{print $2}') >/dev/null 2>&1
if [ "$(pgrep -f "nagaWayland serviceHelper" -G 0 -c)" -ne 0 ]; then
kill $(pgrep -f "nagaWayland serviceHelper" -G 0)
fi
else
#X11
kill $(ps aux | grep "nagaX11 serviceHelper" | grep -v root | grep -v "$1" | grep -v grep | awk '{print $2}') > /dev/null 2>&1
kill $(ps aux | grep "nagaX11 serviceHelper" | grep -v root | grep -v "$1" | grep -v grep | awk '{print $2}') >/dev/null 2>&1
if [ "$(pgrep -f "nagaX11 serviceHelper" -G 0 | grep -v "$1" -c)" -ne 0 ]; then
kill $(pgrep -f "nagaX11 serviceHelper" -G 0 | grep -v "$1")
fi
#Wayland
kill $(ps aux | grep "nagaWayland serviceHelper" | grep -v root | grep -v "$1" | grep -v grep | awk '{print $2}') > /dev/null 2>&1
kill $(ps aux | grep "nagaWayland serviceHelper" | grep -v root | grep -v "$1" | grep -v grep | awk '{print $2}') >/dev/null 2>&1
if [ "$(pgrep -f "nagaWayland serviceHelper" -G 0 | grep -v "$1" -c)" -ne 0 ]; then
kill $(pgrep -f "nagaWayland serviceHelper" -G 0 | grep -v "$1")
fi
Expand Down
6 changes: 3 additions & 3 deletions src/nagaServerCatcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#Finds the visual server and starts the right one
if [ "$(loginctl show-session "$(loginctl | grep "$(whoami)" | awk '{print $1}')" -p Type)" = "Type=wayland" ]; then
gnome-extensions enable window-calls-extended@hseliger.eu
killall dotoold > /dev/null 2>&1
setsid bash -c 'dotoold'&
killall dotoold >/dev/null 2>&1
setsid bash -c 'dotoold' &
if [ $# -eq 0 ]; then
nagaWayland serviceHelper
else
Expand All @@ -15,4 +15,4 @@ else
else
nagaX11 serviceHelper $1
fi
fi
fi
2 changes: 1 addition & 1 deletion src/nagaUninstall.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
sh /usr/local/bin/Naga_Linux/nagaKillroot.sh
sleep 0.3 > /dev/null 2>&1 &
sleep 0.3 >/dev/null 2>&1 &
echo "Deleting app"
#Deleting dotool
sudo rm -vf /usr/local/bin/dotool /usr/local/bin/dotoolc /usr/local/bin/dotoold
Expand Down
7 changes: 3 additions & 4 deletions src/nagaWayland.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ class configSwitchScheduler
loadConf(true);
}
}

}
void remapRoutine()
{
Expand All @@ -162,7 +161,7 @@ class configSwitchScheduler
}
void scheduleReMap(const string *const reMapStr)
{
clog << "Remap Routine"<<endl;
clog << "Remap Routine" << endl;
lock_guard<mutex> guard(configSwitcherMutex);
if (winConfigActive)
{
Expand Down Expand Up @@ -392,7 +391,7 @@ class NagaDaemon
const static void executeThreadNow(const string *const macroContent)
{
thread(executeNow, macroContent).detach();
clog<<"EXECUTED : "<< macroContent->c_str() << endl;
clog << "EXECUTED : " << macroContent->c_str() << endl;
}
// end of configKeys functions

Expand Down Expand Up @@ -529,7 +528,7 @@ int main(const int argc, const char *const argv[])
clog << "Starting naga debug, logs :" << endl;
if (argc > 2)
{
(void)!(system(("journalctl " + string(argv[2]) + " naga").c_str()));
(void)!(system(("journalctl " + string(argv[2]) + " naga").c_str()));
}
else
{
Expand Down

0 comments on commit ffd8f88

Please sign in to comment.