diff --git a/Launch-Scripts/create-shortcut-ubuntu.sh b/Launch-Scripts/create-shortcut-ubuntu.sh deleted file mode 100755 index ff10a98c4..000000000 --- a/Launch-Scripts/create-shortcut-ubuntu.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -PWD=`pwd` -DIR=${PWD%/*} - -touch Superalgos.desktop - -echo "[Desktop Entry] -Type=Application -Encoding=UTF-8 -Name=Superalgos -Comment=Launch Shortcut for Superalgos -Path=$PWD -Exec=gnome-terminal -e $PWD/launch-linux.sh -Terminal=true -Icon=$DIR/Projects/Superalgos/Icons/superalgos.png -Categories=Application;" > Superalgos.desktop - -chmod +x Superalgos.desktop - -cp Superalgos.desktop ~/Desktop/Superalgos.desktop -cp Superalgos.desktop ~/.local/share/applications/Superalgos.desktop - -rm Superalgos.desktop - -# Keep terminal open for debugging -#$SHELL \ No newline at end of file diff --git a/Launch-Scripts/create-shortcut-windows.bat b/Launch-Scripts/create-shortcut-windows.bat deleted file mode 100644 index 40d28012b..000000000 --- a/Launch-Scripts/create-shortcut-windows.bat +++ /dev/null @@ -1,12 +0,0 @@ -set TARGET='%CD%\launch-windows.bat' -set SHORTCUT='%USERPROFILE%\Desktop\Superalgos.lnk' -set STARTMENU='%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Superalgos.lnk' -set ICON='%CD%\superalgos.ico' -set PWS=powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile - -%PWS% -Command "$ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut(%SHORTCUT%); $S.TargetPath = %Target%; $S.IconLocation = %ICON%; $S.Save()" - -%PWS% -Command "$ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut(%STARTMENU%); $S.TargetPath = %Target%; $S.IconLocation = %ICON%; $S.Save()" - -REM Keep terminal open for debug -REM cmd /k echo "keep open" \ No newline at end of file diff --git a/Launch-Scripts/create-shortcut.js b/Launch-Scripts/create-shortcut.js new file mode 100644 index 000000000..09ec86e99 --- /dev/null +++ b/Launch-Scripts/create-shortcut.js @@ -0,0 +1,100 @@ +const path = require("path"); +const fs = require("fs"); +const { exec } = require("child_process"); +const os = require("os"); + +// Get the name of the main directory +let cwd = __dirname; +let dirs = cwd.split(path.sep); +let name = dirs[dirs.length - 2]; + +// Windows Shortcuts +if (os.platform() == "win32") { + // Paths and Icon for Windows shortcuts + let target = path.join( __dirname, "launch-windows.bat"); + let icon = path.join( __dirname, "superalgos.ico"); + let shortcutPaths = [ + path.join( os.homedir(), "Desktop", `${name}.lnk`), + path.join( os.homedir(), "AppData", "Roaming", "Microsoft", "Windows", "Start Menu", "Programs", `${name}.lnk`) + ] + + // Place Shortcuts using powershell + for (let dir of shortcutPaths) { + let command = `$ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut("${dir}"); $S.TargetPath = "${target}"; $S.IconLocation = "${icon}"; $S.Save()`; + + exec( command, + { + shell: "powershell.exe", + execArgv: "-ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -Command" + }, + function ( error, stdout){ + if (error) { + console.log(''); + console.log("There was an error installing a shortcut: "); + console.log(''); + console.log( error ); + return; + } else { + console.log(''); + console.log("Shortcut added successfully!"); + console.log(''); + console.log(stdout); + } + }); + }; + +// Linux Shortcuts +} else if (os.platform() == "linux") { + // Check for Ubuntu + let version = os.version(); + if (version.includes("Ubuntu")) { + // Paths and Icon for Ubuntu shortcuts + let icon = path.join( __dirname,"..", "/Projects/Superalgos/Icons/superalgos.png"); + + // Create .desktop shortcut file + fs.writeFileSync( `${name}.desktop`, + `[Desktop Entry] + Type=Application + Encoding=UTF-8 + Name=${name} + Comment=Launch Shortcut for Superalgos + Path=${__dirname} + Exec=gnome-terminal -e ${__dirname}/launch-linux-mac.sh + Terminal=true + Icon=${icon} + Categories=Application;`, + ); + + // Set shortcut as executable + fs.chmodSync( `${name}.desktop`, "775" ); + + // Place shortcut in proper folders + let command = `cp ${name}.desktop ~/Desktop/${name}.desktop & cp ${name}.desktop ~/.local/share/applications/${name}.desktop` + exec( command, + function ( error, stdout ){ + if (error) { + console.log(''); + console.log("There was an error installing a shortcut: "); + console.log(''); + console.log( error ); + return; + } else { + console.log(''); + console.log("Shortcuts added successfully!"); + } + // Remove temporary .desktop file + fs.unlinkSync( `${name}.desktop` ) + }); + + } else { + console.log( "Automatic shortcut creation is not yet supported on your flavor of linux. If you would like to see this feature add, message @harrellbm on telegram or discord to ask how you can help!") + } + +// Mac Shortcuts +} else if (os.platform() == "darwin") { + console.log( "Automatic shortcut creation is not yet supported on Mac. If you would like to see this feature add, message @harrellbm on telegram or discord to ask how you can help!") + +// Misc Operating System +} else { + console.log("Automatic shortcut creation is not currently supported on your operating system. If you would like to see your operating system added please reachout on discord or telegram to let the devs know.") +} \ No newline at end of file diff --git a/Launch-Scripts/launch-linux-mac.sh b/Launch-Scripts/launch-linux-mac.sh new file mode 100755 index 000000000..d67c15fd6 --- /dev/null +++ b/Launch-Scripts/launch-linux-mac.sh @@ -0,0 +1,4 @@ +#!/bin/sh +cd .. +node run +"$SHELL" \ No newline at end of file diff --git a/Launch-Scripts/launch-linux.sh b/Launch-Scripts/launch-linux.sh deleted file mode 100755 index cdbe490aa..000000000 --- a/Launch-Scripts/launch-linux.sh +++ /dev/null @@ -1 +0,0 @@ -x-terminal-emulator -e "cd .. && node run && $SHELL" \ No newline at end of file diff --git a/Launch-Scripts/uninstall-shortcut-windows.bat b/Launch-Scripts/uninstall-shortcut-windows.bat deleted file mode 100644 index 8067f9130..000000000 --- a/Launch-Scripts/uninstall-shortcut-windows.bat +++ /dev/null @@ -1,5 +0,0 @@ -del "%USERPROFILE%\Desktop\Superalgos.lnk" -del "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Superalgos.lnk" - -REM Keep terminal open for debug -REM cmd /k echo "keep open" \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/launch-scripts-001-launch-scripts.json b/Projects/Superalgos/Schemas/Docs-Topics/launch-scripts-001-launch-scripts.json index fdafba90b..9e00fae18 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/launch-scripts-001-launch-scripts.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/launch-scripts-001-launch-scripts.json @@ -1,10 +1,10 @@ { "topic": "Launch Scripts", "pageNumber": "1", - "type": "Launch Scripts", + "type": "Launch Scripts and Shortcuts", "definition": { - "text": "There are a number of scripts to help make lauching Superalgos easier and feel more native. The eventual goal is to make Superalgos feel like any other program installed on an operating system.", - "updated": 1620052836275 + "text": "There are a number of scripts to help make launching Superalgos easier and feel more native. The eventual goal is to make Superalgos feel like any other program installed on an operating system.", + "updated": 1621801562983 }, "paragraphs": [ { @@ -24,8 +24,8 @@ }, { "style": "Text", - "text": "Due to the nature of scripts, there are different scripts for each type of operating system. The following page includes a description of each script and what it accomplishes.", - "updated": 1620052862888 + "text": "The following page includes a description of each script and what it accomplishes.", + "updated": 1621801618461 }, { "style": "Note", @@ -55,24 +55,18 @@ }, { "style": "Subtitle", - "text": "Linux" + "text": "Linux and Mac", + "updated": 1621801647118 }, { "style": "Json", - "text": "launch-linux.sh" + "text": "launch-linux-mac.sh", + "updated": 1621801639324 }, { "style": "Text", - "text": "This script uses the x-terminal-emulator command for maximum compatiblity across linux flavors." - }, - { - "style": "Subtitle", - "text": "Mac" - }, - { - "style": "Important", - "text": "Collaborator needed.", - "updated": 1620052924921 + "text": "This script uses basic shell commands to be compatible with both Linux and OSX systems.", + "updated": 1621801760692 }, { "style": "Subtitle", @@ -80,58 +74,90 @@ }, { "style": "Title", - "text": "Desktop/Launcher Shortcut Scripts", - "updated": 1620052680945 + "text": "Create Desktop/Launcher Shortcuts", + "updated": 1621802101953 + }, + { + "style": "Json", + "text": "create-shortcut.js", + "updated": 1621802056957 }, { "style": "Text", - "text": "These scripts automatically create and place shortcuts to the launch scripts. They can be run from the command line or file browser.", - "updated": 1620504518909 + "text": "There is one unifed script to automatically create and place shortcuts to the appropriate launch script. This script is automatically run during the \"node setup\" command. It can also be run individual as follows.", + "updated": 1621802202684 + }, + { + "style": "Callout", + "text": "In a terminal or command prompt, navigate to the Launch-Scripts file and type:", + "updated": 1621802248464 + }, + { + "style": "Json", + "text": "node create-shortcut" + }, + { + "style": "Text", + "text": "This will place shortcuts within your Start Menu/Launcher as well as on your Desktop. In Windows the start menu shortcut is also searchable using the start menu search bar.", + "updated": 1621802356143 }, { "style": "Subtitle", + "text": "Shortcut Locations" + }, + { + "style": "Text", + "text": "Depending on your operating system, shortcuts will be placed within different directories. Listed below are the locations by operating system.", + "updated": 1621802761147 + }, + { + "style": "Text", "text": "Windows" }, { - "style": "Json", - "text": "create-shortcut-windows.bat", - "updated": 1620053219653 + "style": "List", + "text": "Users\\[Your Name]\\Desktop" + }, + { + "style": "List", + "text": "Users\\[Your Name]\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs", + "updated": 1621802654652 }, { "style": "Text", - "text": "This script places shortcuts within the user's start menu and desktop. The start menu shortcut is also searchable using the start menu search bar.", - "updated": 1620789169171 + "text": "Ubuntu" + }, + { + "style": "List", + "text": "~/Desktop", + "updated": 1621803704659 + }, + { + "style": "List", + "text": "~/.local/share/applications", + "updated": 1621803711854 + }, + { + "style": "Text", + "text": "Mac" + }, + { + "style": "Important", + "text": "Currently unhandled collaborator needed.", + "updated": 1621802848597 }, { "style": "Subtitle", - "text": "Ubuntu", - "updated": 1620053330166 - }, - { - "style": "Json", - "text": "create-shortcut-ubuntu.sh", - "updated": 1620504490683 + "text": "Additional set up needed on Ubuntu", + "updated": 1621802397032 }, { "style": "Text", - "text": "This script places shortcuts within the user's launcher and desktop. Shortcuts are placed in the following locations:", - "updated": 1620504828523 + "text": "Most shortcuts will work out of the box. Ubuntu desktop shortcuts, however, take a few additional steps to set up. The following section will walk you through these steps.", + "updated": 1621802969207 }, { - "style": "List", - "text": "~/Desktop/Superalgos.desktop" - }, - { - "style": "List", - "text": "~/.local/share/applications/Superalgos.desktop" - }, - { - "style": "Note", - "text": "After running create-shortcut-ubuntu.sh the launcher shortcut will work out of the box. There are a few additional steps to set up the desktop shortcut. The following section will walk you through these steps.", - "updated": 1620505700097 - }, - { - "style": "Text", + "style": "Callout", "text": "First, desktop icons need to be enabled within the Tweaks app.", "updated": 1620505123531 }, @@ -157,7 +183,8 @@ }, { "style": "List", - "text": "Under extensions turn on Desktop Icons" + "text": "Under extensions turn on Desktop Icons.", + "updated": 1621803788239 }, { "style": "Gif", @@ -169,7 +196,7 @@ "updated": 1620505754854 }, { - "style": "Text", + "style": "Callout", "text": "Finally, you will need to enable the desktop shortcut.", "updated": 1620505790748 }, @@ -183,49 +210,19 @@ "text": "GIFs/Superalgos/Docs/launch-scripts/allow-launching.gif", "updated": 1620505894840 }, - { - "style": "Subtitle", - "text": "Mac" - }, - { - "style": "Important", - "text": "Collaborator needed." - }, { "style": "Title", "text": "Uninstall Shortcuts", "updated": 1620789208012 }, - { - "style": "Subtitle", - "text": "Windows", - "updated": 1620789368194 - }, { "style": "Text", - "text": "Open a file browser and navigate to the Superalgos directory." - }, - { - "style": "Text", - "text": "Under the folder titled Launch-Scripts double-click the script:", - "updated": 1620789459938 + "text": "There is one unifed script to automatically uninstall shortcuts. To ese it open a command prompt or terminal. Then navigate to your Superalgos directory and type the following command:", + "updated": 1621804036052 }, { "style": "Json", - "text": "uninstall-shortcut-windows.bat", - "updated": 1620789508304 - }, - { - "style": "Subtitle", - "text": "Ubuntu" - }, - { - "style": "Text", - "text": "Open a terminal and run the following command:" - }, - { - "style": "Javascript", - "text": "rm ~/Desktop/Superalgos.desktop && rm ~/.local/share/applications/Superalgos.desktop" + "text": "node uninstall" } ] } \ No newline at end of file diff --git a/README.md b/README.md index e7ef08ce4..36a7d11ac 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ It is also required to install the Node Package Manager for dependancy managemen ``` sudo apt install npm ``` -You may also type the following to verify the Node.js and NPM installation and version. +You may also type the following to verify Node.js and NPM installation and version. ``` node -v ``` @@ -134,12 +134,26 @@ node setup Then wait until you are able to type within the terminal again. -This command will install and configure all additional dependencies needed by Superalgos. +This command will install and configure all additional dependencies needed by Superalgos. It will also install desktop and start menu shortcuts. + +**NOTE FOR USERS INSTALLING MULTIPLE INSTANCES OF SUPERALGOS ON THE SAME MACHINE:** In order to avoid name conflicts between shortcuts, make sure to rename your main directory before running `node setup`. Congratulations your installation is complete! > **The Usage section below explains how to run the app.** +