Skip to content

Commit

Permalink
rewrite winIconLauncher in c++
Browse files Browse the repository at this point in the history
  • Loading branch information
axellse committed Aug 31, 2024
1 parent 8b82592 commit c01a196
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 74 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.associations": {
"filesystem": "cpp"
}
}
23 changes: 0 additions & 23 deletions bin/iconhost.deps.json

This file was deleted.

Binary file removed bin/iconhost.exe
Binary file not shown.
Binary file removed bin/iconhost.pdb
Binary file not shown.
12 changes: 0 additions & 12 deletions bin/iconhost.runtimeconfig.json

This file was deleted.

3 changes: 2 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"idlingImageStyle": "nostalgia-1",
"alwaysFullReload": false,
"searchEngine": "youtube",
"discordRpcEnabled": true
"discordRpcEnabled": true,
"useWic" : true
}
20 changes: 4 additions & 16 deletions helpers/core/commandProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,23 +120,11 @@ export async function processCommand(command) {
killAudioProcesses()
process.exit()
break;
case 'about':
const useWinIconLauncher = (() => {
if (process.platform === 'win32') {
try {
const dotNetInfo = execSync('dotnet --info')
if (dotNetInfo.toString().includes('8.')) {
return true
}
} catch (e) {}
}
return false
})()

if (useWinIconLauncher) {
spawn(`${getCrossPlatformString("new-terminal-window")} iconhost.exe about`, [], {
case 'about':
if (config['useWic']) {
spawn(`${getCrossPlatformString("new-terminal-window")} winIconLauncher.exe about`, [], {
shell: true,
cwd: path.join(path.dirname(fileURLToPath(import.meta.url)), '../', '../', 'bin')
cwd: path.join(path.dirname(fileURLToPath(import.meta.url)), '../', '../', 'wic')
})
} else {
spawn(`${getCrossPlatformString("new-terminal-window")} node ${directory} about`, [], {shell: true})
Expand Down
Binary file renamed bin/iconhost.dll → images/icon.ico
Binary file not shown.
26 changes: 4 additions & 22 deletions launch/launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { fileURLToPath } from 'url';
import path from 'path';
import { Green, Magenta, PastelGreen, PastelRed, Red, Reset, Yellow } from '../helpers/misc/colorCodes.js';
import { checkForUpdates } from '../helpers/startup/updateChecker.js'
import { config } from '../snippets/config.js';

const directory = path.join(path.dirname(fileURLToPath(import.meta.url)), '../', 'termusic.js')

Expand Down Expand Up @@ -36,31 +37,12 @@ export async function startLauncher() {
} else {
console.log(`[${PastelGreen}DONE${Reset}]`)
}

const useWinIconLauncher = (() => {
if (process.platform === 'win32') {
process.stdout.write('Checking whether winIconLauncher can be used ')
try {
const dotNetInfo = execSync('dotnet --info')

if (dotNetInfo.toString().includes('8.')) {
console.log(`[${PastelGreen}DONE${Reset}]`)
return true
} else {
console.log(`[${PastelRed}.NET 8.0 NOT FOUND${Reset}]`)
}
} catch (e) {
console.log(`[${PastelRed}NO .NET RUNTIMES FOUND${Reset}]`)
}
}
return false
})()
process.stdout.write('Launching termusic in a seperate window ')

if (useWinIconLauncher) {
spawn(`${getCrossPlatformString("new-terminal-window")} iconhost.exe launch`, [], {
if (config['useWic']) {
spawn(`${getCrossPlatformString("new-terminal-window")} winIconLauncher.exe launch`, [], {
shell: true,
cwd: path.join(path.dirname(fileURLToPath(import.meta.url)), '../', 'bin')
cwd: path.join(path.dirname(fileURLToPath(import.meta.url)), '../', 'wic')
})
} else {
spawn(`${getCrossPlatformString("new-terminal-window")} node ${directory} launch`, [], {shell: true})
Expand Down
1 change: 1 addition & 0 deletions wic/readme
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
simply compile the file winIconLauncher.cpp in your favourite compiler. The program icon is added afterwards using resource hacker and the icon file located at ./images/icon.ico
12 changes: 12 additions & 0 deletions wic/winIconLauncher.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <iostream>
#include <string>
#include <cstdlib>
#include <filesystem>

int main(int argc, char* argv[]) {
std::string path = std::filesystem::current_path().parent_path().string();
std::string command = "cmd.exe /c node " + path + "\\termusic.js " + (argc > 1 ? argv[1] : "");
system(command.c_str());
return 0;
}

Binary file added wic/winIconLauncher.exe
Binary file not shown.

0 comments on commit c01a196

Please sign in to comment.