Compare commits
13 Commits
msys
...
ini-comman
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
541efef81b | ||
|
|
f91905f6bb | ||
|
|
58b5c72ead | ||
|
|
1a1c5866e0 | ||
|
|
a05668dffc | ||
|
|
551bb174b0 | ||
|
|
afa868fd7b | ||
|
|
619f3830af | ||
|
|
174fc35707 | ||
|
|
292186be44 | ||
|
|
2c0e3b8e0c | ||
|
|
ee4a2d0fe9 | ||
|
|
6a011ed295 |
7
.gitignore
vendored
7
.gitignore
vendored
@@ -1,6 +1,13 @@
|
|||||||
/mingw32.exe
|
/mingw32.exe
|
||||||
/mingw32.res
|
/mingw32.res
|
||||||
|
/mingw32.ini
|
||||||
/mingw64.exe
|
/mingw64.exe
|
||||||
/mingw64.res
|
/mingw64.res
|
||||||
|
/mingw64.ini
|
||||||
/msys2.exe
|
/msys2.exe
|
||||||
/msys2.res
|
/msys2.res
|
||||||
|
/msys2.ini
|
||||||
|
/pkg/
|
||||||
|
/src/
|
||||||
|
/*.pkg.tar.xz
|
||||||
|
/*.pkg.tar.xz.sig
|
||||||
|
|||||||
30
Makefile
30
Makefile
@@ -1,19 +1,29 @@
|
|||||||
all: msys2.exe mingw32.exe mingw64.exe
|
PREFIX=
|
||||||
|
|
||||||
|
all: msys2.exe msys2.ini mingw32.exe mingw32.ini mingw64.exe mingw64.ini
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
|
||||||
|
msys2.ini: launcher.ini
|
||||||
|
cp -f $^ $@
|
||||||
|
echo MSYSTEM=MSYS>> $@
|
||||||
msys2.res: launcher.rc msys2.ico
|
msys2.res: launcher.rc msys2.ico
|
||||||
windres -O COFF -o $@ $< -DMSYSTEM=MSYS -DICONFILE=msys2.ico
|
$(PREFIX)windres -O COFF -o $@ $< -DMSYSTEM=MSYS -DICONFILE=msys2.ico
|
||||||
msys2.exe: launcher.c msys2.res
|
msys2.exe: launcher.c msys2.res
|
||||||
gcc -Wall -Wextra -static -mwindows -o $@ $^ -luuid -lshlwapi -lpsapi -DMSYSTEM=MSYS
|
$(PREFIX)gcc -std=c11 -Wall -Wextra -Werror -static -municode -mwindows -o $@ $^
|
||||||
strip $@
|
|
||||||
|
|
||||||
|
mingw32.ini: launcher.ini
|
||||||
|
cp -f $^ $@
|
||||||
|
echo MSYSTEM=MINGW32>> $@
|
||||||
mingw32.res: launcher.rc mingw32.ico
|
mingw32.res: launcher.rc mingw32.ico
|
||||||
windres -O COFF -o $@ $< -DMSYSTEM=MINGW32 -DICONFILE=mingw32.ico
|
$(PREFIX)windres -O COFF -o $@ $< -DMSYSTEM=MINGW32 -DICONFILE=mingw32.ico
|
||||||
mingw32.exe: launcher.c mingw32.res
|
mingw32.exe: launcher.c mingw32.res
|
||||||
gcc -Wall -Wextra -static -mwindows -o $@ $^ -luuid -lshlwapi -lpsapi -DMSYSTEM=MINGW32
|
$(PREFIX)gcc -std=c11 -Wall -Wextra -Werror -static -municode -mwindows -o $@ $^
|
||||||
strip $@
|
|
||||||
|
|
||||||
|
mingw64.ini: launcher.ini
|
||||||
|
cp -f $^ $@
|
||||||
|
echo MSYSTEM=MINGW64>> $@
|
||||||
mingw64.res: launcher.rc mingw64.ico
|
mingw64.res: launcher.rc mingw64.ico
|
||||||
windres -O COFF -o $@ $< -DMSYSTEM=MINGW64 -DICONFILE=mingw64.ico
|
$(PREFIX)windres -O COFF -o $@ $< -DMSYSTEM=MINGW64 -DICONFILE=mingw64.ico
|
||||||
mingw64.exe: launcher.c mingw64.res
|
mingw64.exe: launcher.c mingw64.res
|
||||||
gcc -Wall -Wextra -static -mwindows -o $@ $^ -luuid -lshlwapi -lpsapi -DMSYSTEM=MINGW64
|
$(PREFIX)gcc -std=c11 -Wall -Wextra -Werror -static -municode -mwindows -o $@ $^
|
||||||
strip $@
|
|
||||||
|
|||||||
36
PKGBUILD
Normal file
36
PKGBUILD
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
_realname="msys2-launcher"
|
||||||
|
pkgname=("${_realname}-git")
|
||||||
|
pkgver=0.3.17.1a1c586
|
||||||
|
pkgrel=1
|
||||||
|
pkgdesc="Helper for launching MSYS2 shells"
|
||||||
|
arch=('x86_64' 'i686')
|
||||||
|
license=('MIT')
|
||||||
|
backup=({mingw32,mingw64,msys2}.ini)
|
||||||
|
provides=("${_realname}")
|
||||||
|
conflicts=("${_realname}")
|
||||||
|
depends=("mintty>=2.2.1")
|
||||||
|
makedepends=('mingw-w64-cross-gcc')
|
||||||
|
source=(launcher.{c,ini,rc} {macros,version}.h Makefile {mingw32,mingw64,msys2}.ico)
|
||||||
|
md5sums=('e21db11d21f95aab30966a8c528efd9b'
|
||||||
|
'7ab96cb34fef046e4839e270f9397a32'
|
||||||
|
'3a3c9fd8d083716e5efd759641eb4f31'
|
||||||
|
'57a40ae9972dac94df0830a1ab480895'
|
||||||
|
'fef245f65b6826502b953b81fb397d97'
|
||||||
|
'8d3fa1f8eb06343a13b72299c164f6cd'
|
||||||
|
'797a8ea3012b22705caadcb17b1291c2'
|
||||||
|
'0237b204a9d09dcadc955b435cefd311'
|
||||||
|
'292ad5cdd78abac9d694cc06819a96fc')
|
||||||
|
|
||||||
|
pkgver() {
|
||||||
|
local _major=$(cat version.h | grep -F 'VER_MAJOR' | head -1 | sed -e 's/.* //')
|
||||||
|
local _minor=$(cat version.h | grep -F 'VER_MINOR' | head -1 | sed -e 's/.* //')
|
||||||
|
printf "%s.%s.%s.%s" "${_major}" "${_minor}" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
|
||||||
|
}
|
||||||
|
|
||||||
|
build() {
|
||||||
|
make PREFIX=/opt/bin/${CARCH}-w64-mingw32-
|
||||||
|
}
|
||||||
|
|
||||||
|
package() {
|
||||||
|
cp {mingw32,mingw64,msys2}.{exe,ini} "${pkgdir}"
|
||||||
|
}
|
||||||
@@ -6,4 +6,4 @@ A helper for launching MSYS2 shells. Features blink-less launching and correct t
|
|||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
|
|
||||||
Just `make` and put the executables inside your MSYS2 root.
|
Just `make` and put the executables inside your MSYS2 root. Needs mintty v2.1.6 or newer (unreleased at the time of writing).
|
||||||
|
|||||||
340
launcher.c
340
launcher.c
@@ -1,15 +1,8 @@
|
|||||||
|
#define _UNICODE
|
||||||
#define _WIN32_WINNT 0x0601
|
#define _WIN32_WINNT 0x0601
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#define PSAPI_VERSION 1
|
#define PSAPI_VERSION 1
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <objbase.h>
|
|
||||||
#include <propvarutil.h>
|
|
||||||
#include <shobjidl.h>
|
|
||||||
#include <shellapi.h>
|
|
||||||
#include <propsys.h>
|
|
||||||
#include <propkey.h>
|
|
||||||
#include <processthreadsapi.h>
|
|
||||||
#include <psapi.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -17,25 +10,34 @@
|
|||||||
|
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
|
|
||||||
static void ShowError(const char* desc, const char* err, const long code) {
|
// if any of the properties change, it's best to use a brand new AppID
|
||||||
char msg[1024];
|
#define APPID_REVISION 9
|
||||||
|
|
||||||
sprintf(msg, "%s. Reason: %s (0x%lx)", desc, err, code);
|
static void ShowError(const wchar_t* desc, const wchar_t* err, const long code) {
|
||||||
MessageBox(NULL, msg, "Launcher error", MB_ICONEXCLAMATION | MB_OK);
|
wchar_t msg[1024];
|
||||||
|
|
||||||
|
swprintf(msg, 1024, L"%s. Reason: %s (0x%lx)", desc, err, code);
|
||||||
|
MessageBox(NULL, msg, L"Launcher error", MB_ICONEXCLAMATION | MB_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ShowLastError(const char* desc) {
|
static void ShowLastError(const wchar_t* desc) {
|
||||||
DWORD code;
|
DWORD code;
|
||||||
char* err;
|
wchar_t* err;
|
||||||
|
|
||||||
code = GetLastError();
|
code = GetLastError();
|
||||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&err, 0, NULL);
|
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&err, 0, NULL);
|
||||||
ShowError(desc, err, code);
|
ShowError(desc, err, code);
|
||||||
LocalFree(err);
|
LocalFree(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ShowErrno(const wchar_t* desc) {
|
||||||
|
wchar_t* err;
|
||||||
|
|
||||||
PROCESS_INFORMATION StartChild(const wchar_t* cmdline) {
|
err = _wcserror(errno);
|
||||||
|
ShowError(desc, err, errno);
|
||||||
|
}
|
||||||
|
|
||||||
|
static PROCESS_INFORMATION StartChild(wchar_t* cmdline) {
|
||||||
STARTUPINFOW si;
|
STARTUPINFOW si;
|
||||||
PROCESS_INFORMATION pi;
|
PROCESS_INFORMATION pi;
|
||||||
DWORD code;
|
DWORD code;
|
||||||
@@ -44,126 +46,203 @@ PROCESS_INFORMATION StartChild(const wchar_t* cmdline) {
|
|||||||
si.cb = sizeof(si);
|
si.cb = sizeof(si);
|
||||||
ZeroMemory(&pi, sizeof(pi));
|
ZeroMemory(&pi, sizeof(pi));
|
||||||
SetLastError(0);
|
SetLastError(0);
|
||||||
code = CreateProcessW(NULL, (wchar_t*)cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
|
code = CreateProcess(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
ShowLastError("Could not start the shell");
|
ShowLastError(L"Could not start the shell");
|
||||||
|
ShowError(L"The command was", cmdline, 0);
|
||||||
return pi;
|
return pi;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pi;
|
return pi;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SetEnv(const char* msystem) {
|
static wchar_t* SetEnv(wchar_t* conffile, wchar_t** command) {
|
||||||
int code;
|
int code;
|
||||||
char* env;
|
size_t buflen;
|
||||||
const char* err;
|
size_t expandedlen;
|
||||||
const char prefix[] = "MSYSTEM=";
|
wchar_t* tmp;
|
||||||
|
wchar_t* buf;
|
||||||
|
wchar_t* expanded;
|
||||||
|
wchar_t* msystem;
|
||||||
|
FILE* handle;
|
||||||
|
bool specialvar;
|
||||||
|
|
||||||
env = (char*)alloca(strlen(prefix) + strlen(msystem) + 1);
|
*command = NULL;
|
||||||
strcpy(env, prefix);
|
msystem = NULL;
|
||||||
strcat(env, msystem);
|
|
||||||
code = putenv(env);
|
handle = _wfopen(conffile, L"rt");
|
||||||
|
if (handle == NULL) {
|
||||||
|
ShowErrno(L"Could not open configuration file");
|
||||||
|
return msystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
buflen = 512;
|
||||||
|
buf = (wchar_t*)malloc(buflen * sizeof(wchar_t));
|
||||||
|
*buf = L'\0';
|
||||||
|
expandedlen = 2 * buflen;
|
||||||
|
expanded = (wchar_t*)malloc(expandedlen * sizeof(wchar_t));
|
||||||
|
while (true) {
|
||||||
|
tmp = fgetws(buf + wcslen(buf), buflen - wcslen(buf), handle);
|
||||||
|
if (tmp == NULL && !feof(handle)) {
|
||||||
|
ShowErrno(L"Could not read from configuration file");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp = buf + wcslen(buf) - 1;
|
||||||
|
if (!feof(handle) && *tmp != L'\n') {
|
||||||
|
buflen *= 2;
|
||||||
|
buf = (wchar_t*)realloc(buf, buflen * sizeof(wchar_t));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!feof(handle)) {
|
||||||
|
*tmp = L'\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*buf != L'\0' && *buf != L'#') {
|
||||||
|
specialvar = *buf == L'=';
|
||||||
|
if (specialvar) {
|
||||||
|
++buf;
|
||||||
|
}
|
||||||
|
tmp = wcschr(buf, L'=');
|
||||||
|
if (tmp != NULL) {
|
||||||
|
*tmp++ = L'\0';
|
||||||
|
while (expandedlen < 32768) {
|
||||||
|
code = ExpandEnvironmentStrings(tmp, expanded, expandedlen);
|
||||||
|
if ((size_t)code <= expandedlen) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
expandedlen *= 2;
|
||||||
|
expanded = (wchar_t*)realloc(expanded, expandedlen * sizeof(wchar_t));
|
||||||
|
}
|
||||||
|
if ((*tmp != L'\0' && code == 0) || (size_t)code > expandedlen) {
|
||||||
|
ShowLastError(L"Could not expand string");
|
||||||
|
}
|
||||||
|
if (0 == wcscmp(L"MSYSTEM", buf)) {
|
||||||
|
msystem = _wcsdup(expanded);
|
||||||
|
if (msystem == NULL) {
|
||||||
|
ShowError(L"Could not duplicate string", expanded, 0);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (specialvar) {
|
||||||
|
if (0 == wcsicmp(L"command", buf)) {
|
||||||
|
*command = _wcsdup(expanded);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
code = SetEnvironmentVariable(buf, expanded);
|
||||||
|
if (code == 0) {
|
||||||
|
ShowLastError(L"Could not set environment variable");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ShowError(L"Could not parse environment line", buf, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*buf = L'\0';
|
||||||
|
if (feof(handle)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
code = fclose(handle);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
err = strerror(errno);
|
ShowErrno(L"Could not close configuration file");
|
||||||
ShowError("Could not set MSYSTEM", err, errno);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return msystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct handle_data {
|
int wmain(int argc, wchar_t* argv[]) {
|
||||||
unsigned long process_id;
|
|
||||||
HWND best_handle;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
BOOL is_main_window(HWND handle)
|
|
||||||
{
|
|
||||||
return GetWindow(handle, GW_OWNER) == (HWND)0 && IsWindowVisible(handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BOOL CALLBACK enum_windows_callback(HWND handle, LPARAM lParam)
|
|
||||||
{
|
|
||||||
struct handle_data* data = (struct handle_data*)lParam;
|
|
||||||
unsigned long process_id = 0;
|
|
||||||
GetWindowThreadProcessId(handle, &process_id);
|
|
||||||
if (data->process_id != process_id || !is_main_window(handle)) {
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
data->best_handle = handle;
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
HWND find_main_window(unsigned long process_id)
|
|
||||||
{
|
|
||||||
struct handle_data data;
|
|
||||||
data.process_id = process_id;
|
|
||||||
data.best_handle = 0;
|
|
||||||
EnumWindows(enum_windows_callback, (LPARAM)&data);
|
|
||||||
return data.best_handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HRESULT SetAppUserModelProperty(IPropertyStore* store, const PROPERTYKEY* key, LPCWSTR value) {
|
|
||||||
PROPVARIANT propVariant;
|
|
||||||
HRESULT hr;
|
|
||||||
|
|
||||||
propVariant.vt = VT_LPWSTR;
|
|
||||||
hr = SHStrDupW(value, &propVariant.pwszVal);
|
|
||||||
if (FAILED(hr)) {
|
|
||||||
return hr;
|
|
||||||
}
|
|
||||||
|
|
||||||
hr = store->lpVtbl->SetValue(store, key, &propVariant);
|
|
||||||
if (FAILED(hr)) {
|
|
||||||
return hr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
|
||||||
PROCESS_INFORMATION child;
|
PROCESS_INFORMATION child;
|
||||||
DWORD code;
|
int code;
|
||||||
int res;
|
|
||||||
HWND window;
|
|
||||||
IPropertyStore* store;
|
|
||||||
HRESULT hr;
|
|
||||||
size_t buflen;
|
size_t buflen;
|
||||||
wchar_t* buf;
|
wchar_t* buf;
|
||||||
wchar_t msysdir[PATH_MAX], exepath[PATH_MAX];
|
wchar_t* tmp;
|
||||||
int delay = 10;
|
wchar_t* args;
|
||||||
|
wchar_t* msystem;
|
||||||
|
wchar_t msysdir[PATH_MAX];
|
||||||
|
wchar_t exepath[PATH_MAX];
|
||||||
|
wchar_t confpath[PATH_MAX];
|
||||||
|
|
||||||
UNUSED(argc);
|
code = GetModuleFileName(NULL, exepath, sizeof(exepath) / sizeof(exepath[0]));
|
||||||
UNUSED(argv);
|
|
||||||
|
|
||||||
code = GetModuleFileNameW(NULL, exepath, sizeof(exepath) / sizeof(exepath[0]));
|
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
ShowLastError("Could not determine executable path");
|
ShowLastError(L"Could not determine executable path");
|
||||||
return __LINE__;
|
return __LINE__;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (wcschr(exepath, L'\\') != NULL) {
|
tmp = exepath;
|
||||||
wcschr(exepath, L'\\')[0] = L'/';
|
while (true) {
|
||||||
|
tmp = wcschr(tmp, L'/');
|
||||||
|
if (tmp == NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
*tmp = L'\\';
|
||||||
}
|
}
|
||||||
|
|
||||||
wcscpy(msysdir, exepath);
|
wcscpy(msysdir, exepath);
|
||||||
if (wcsrchr(msysdir, L'/') != NULL) {
|
tmp = wcsrchr(msysdir, L'\\');
|
||||||
wcsrchr(msysdir, L'/')[0] = L'\0';
|
if (tmp == NULL) {
|
||||||
|
ShowError(L"Could not find root directory", msysdir, 0);
|
||||||
|
return __LINE__;
|
||||||
}
|
}
|
||||||
buflen = wcslen(msysdir) + 1000;
|
*tmp = L'\0';
|
||||||
buf = (wchar_t*)alloca(buflen * sizeof(wchar_t));
|
|
||||||
|
|
||||||
code = SetEnv(STRINGIFY_A(MSYSTEM));
|
wcscpy(confpath, exepath);
|
||||||
if (code == 0) {
|
tmp = confpath + wcslen(confpath) - 4;
|
||||||
|
if (0 != wcsicmp(L".exe", tmp)) {
|
||||||
|
ShowError(L"Could not find configuration file", confpath, 0);
|
||||||
|
return __LINE__;
|
||||||
|
}
|
||||||
|
*tmp++ = L'.';
|
||||||
|
*tmp++ = L'i';
|
||||||
|
*tmp++ = L'n';
|
||||||
|
*tmp++ = L'i';
|
||||||
|
|
||||||
|
if (argc > 1) {
|
||||||
|
code = SetEnvironmentVariable(L"CHERE_INVOKING", L"1");
|
||||||
|
if (code == 0) {
|
||||||
|
ShowLastError(L"Could not set environment variable");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
msystem = SetEnv(confpath, &args);
|
||||||
|
if (msystem == NULL) {
|
||||||
|
ShowError(L"Did not find the MSYSTEM variable", confpath, 0);
|
||||||
return __LINE__;
|
return __LINE__;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = swprintf(buf, buflen, L"%s/usr/bin/mintty.exe -i '%s' /usr/bin/bash --login -i", msysdir, exepath);
|
code = SetEnvironmentVariable(L"MSYSCON", L"mintty.exe");
|
||||||
if (res < 0) {
|
if (code == 0) {
|
||||||
|
ShowLastError(L"Could not set environment variable");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc > 1) {
|
||||||
|
// can break, but hopefully won't for most use cases
|
||||||
|
args = GetCommandLine();
|
||||||
|
if (*args == L'"') {
|
||||||
|
args++;
|
||||||
|
}
|
||||||
|
args += wcslen(argv[0]);
|
||||||
|
if (*args == L'"') {
|
||||||
|
args++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
code = -1;
|
||||||
|
buf = NULL;
|
||||||
|
buflen = 1024;
|
||||||
|
while (code < 0 && buflen < 8192) {
|
||||||
|
buf = (wchar_t*)realloc(buf, buflen * sizeof(wchar_t));
|
||||||
|
if (buf == NULL) {
|
||||||
|
ShowError(L"Could not allocate memory", L"", 0);
|
||||||
|
return __LINE__;
|
||||||
|
}
|
||||||
|
code = swprintf(buf, buflen, L"%s\\usr\\bin\\mintty.exe -i '%s' -o 'AppLaunchCmd=%s' -o 'AppID=MSYS2.Shell.%s.%d' -o 'AppName=MSYS2 %s Shell' --store-taskbar-properties -- /usr/bin/bash --login %s %s", msysdir, exepath, exepath, msystem, APPID_REVISION, msystem, args != NULL ? L"-c '$0 \"$@\"'" : L"-i" , args != NULL ? args : L"");
|
||||||
|
buflen *= 2;
|
||||||
|
}
|
||||||
|
if (code < 0) {
|
||||||
|
ShowErrno(L"Could not write to buffer");
|
||||||
return __LINE__;
|
return __LINE__;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,51 +251,8 @@ int main(int argc, char* argv[]) {
|
|||||||
return __LINE__;
|
return __LINE__;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
free(buf);
|
||||||
Sleep(delay);
|
buf = NULL;
|
||||||
window = find_main_window(GetProcessId(child.hProcess));
|
|
||||||
if (!window) {
|
|
||||||
delay *= 2;
|
|
||||||
if (delay > 60000) {
|
|
||||||
return __LINE__;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
hr = SHGetPropertyStoreForWindow(window, &IID_IPropertyStore, (void**)&store);
|
|
||||||
if (FAILED(hr)) {
|
|
||||||
return __LINE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
hr = SetAppUserModelProperty(store, &PKEY_AppUserModel_ID, L"MSYS2.Shell." STRINGIFY_W(MSYSTEM) L".7");
|
|
||||||
if (FAILED(hr)) {
|
|
||||||
return __LINE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
hr = SetAppUserModelProperty(store, &PKEY_AppUserModel_RelaunchDisplayNameResource, L"MSYS2 " STRINGIFY_W(MSYSTEM) L" shell");
|
|
||||||
if (FAILED(hr)) {
|
|
||||||
return __LINE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
hr = SetAppUserModelProperty(store, &PKEY_AppUserModel_RelaunchCommand, exepath);
|
|
||||||
if (FAILED(hr)) {
|
|
||||||
return __LINE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
hr = SetAppUserModelProperty(store, &PKEY_AppUserModel_RelaunchIconResource, exepath);
|
|
||||||
if (FAILED(hr)) {
|
|
||||||
return __LINE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
hr = store->lpVtbl->Commit(store);
|
|
||||||
if (FAILED(hr)) {
|
|
||||||
return __LINE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
store->lpVtbl->Release(store);
|
|
||||||
store = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
4
launcher.ini
Normal file
4
launcher.ini
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#MSYS=winsymlinks:nativestrict
|
||||||
|
#MSYS=error_start:mingw64/bin/qtcreator.exe|-debug|<process-id>
|
||||||
|
#CHERE_INVOKING=1
|
||||||
|
#PATH=%SystemRoot%\System32;%SystemRoot%;%SystemRoot%\System32\Wbem
|
||||||
@@ -1,15 +1,16 @@
|
|||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
1 VERSIONINFO
|
1 VERSIONINFO
|
||||||
FILEVERSION 0,1,0,0
|
FILEVERSION VER_MAJOR,VER_MINOR,0,0
|
||||||
BEGIN
|
BEGIN
|
||||||
BLOCK "StringFileInfo"
|
BLOCK "StringFileInfo"
|
||||||
BEGIN
|
BEGIN
|
||||||
BLOCK "040904E4"
|
BLOCK "040904E4"
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "ProductName", "MSYS2"
|
VALUE "ProductName", "MSYS2"
|
||||||
VALUE "FileDescription", "MSYS2/" STRINGIFY_A(MSYSTEM) " shell launcher"
|
VALUE "FileDescription", "MSYS2 " STRINGIFY_A(MSYSTEM) " shell launcher"
|
||||||
VALUE "FileVersion", "0.1"
|
VALUE "FileVersion", STRINGIFY_A(VER_MAJOR) "." STRINGIFY_A(VER_MINOR)
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|||||||
5
macros.h
5
macros.h
@@ -1,3 +1,6 @@
|
|||||||
|
#ifndef M2L_MACROS_H
|
||||||
|
#define M2L_MACROS_H
|
||||||
|
|
||||||
#define UNUSED(x) ((void)(x))
|
#define UNUSED(x) ((void)(x))
|
||||||
|
|
||||||
#define STRINGIFY_A_(x) #x
|
#define STRINGIFY_A_(x) #x
|
||||||
@@ -5,3 +8,5 @@
|
|||||||
|
|
||||||
#define STRINGIFY_W_(x) L ## #x
|
#define STRINGIFY_W_(x) L ## #x
|
||||||
#define STRINGIFY_W(x) STRINGIFY_W_(x)
|
#define STRINGIFY_W(x) STRINGIFY_W_(x)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
BIN
mingw32.ico
BIN
mingw32.ico
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 25 KiB |
BIN
mingw32.pdn
BIN
mingw32.pdn
Binary file not shown.
BIN
mingw64.ico
BIN
mingw64.ico
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 25 KiB |
BIN
mingw64.pdn
BIN
mingw64.pdn
Binary file not shown.
Reference in New Issue
Block a user