Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a858280c5d | ||
|
|
8ea0ca32a3 |
4
.editorconfig
Normal file
4
.editorconfig
Normal file
@@ -0,0 +1,4 @@
|
||||
root = true
|
||||
|
||||
[*.{c,h}]
|
||||
indent_style = tab
|
||||
22
.gitignore
vendored
22
.gitignore
vendored
@@ -1,16 +1,6 @@
|
||||
/mingw32.exe
|
||||
/mingw32.res
|
||||
/mingw32.ini
|
||||
/mingw64.exe
|
||||
/mingw64.res
|
||||
/mingw64.ini
|
||||
/msys2.exe
|
||||
/msys2.res
|
||||
/msys2.ini
|
||||
/cygwin.exe
|
||||
/cygwin.res
|
||||
/cygwin.ini
|
||||
/pkg/
|
||||
/src/
|
||||
/*.pkg.tar.xz
|
||||
/*.pkg.tar.xz.sig
|
||||
/msys.exe
|
||||
/msys.res
|
||||
/msys.ini
|
||||
/mingw.exe
|
||||
/mingw.res
|
||||
/mingw.ini
|
||||
|
||||
43
Makefile
43
Makefile
@@ -1,39 +1,22 @@
|
||||
PREFIX=
|
||||
|
||||
msys2: msys2.exe msys2.ini mingw32.exe mingw32.ini mingw64.exe mingw64.ini
|
||||
cygwin: cygwin.exe cygwin.ini
|
||||
all: msys2 cygwin
|
||||
msys: msys.exe msys.ini mingw.exe mingw.ini
|
||||
all: msys
|
||||
|
||||
.PHONY: all msys2 cygwin
|
||||
.PHONY: all msys
|
||||
|
||||
msys2.ini: launcher.ini
|
||||
msys.ini: launcher.ini
|
||||
cp -f $^ $@
|
||||
echo MSYSTEM=MSYS>> $@
|
||||
msys2.res: launcher.rc msys2.ico
|
||||
$(PREFIX)windres -O COFF -o $@ $< -DPRODUCT=MSYS2 -DMSYSTEM=MSYS -DICONFILE=msys2.ico
|
||||
msys2.exe: launcher.c msys2.res
|
||||
$(PREFIX)gcc -std=c11 -Wall -Wextra -Werror -static -municode -mwindows -o $@ $^ -DPRODUCT=MSYS2 -DSHELLPATH='usr\\bin\\mintty.exe'
|
||||
msys.res: launcher.rc msys.ico
|
||||
$(PREFIX)windres -O COFF -o $@ $< -DMSYSTEM=MSYS -DICONFILE=msys.ico
|
||||
msys.exe: launcher.c msys.res
|
||||
$(PREFIX)gcc -std=c11 -Wall -Wextra -Werror -municode -mwindows -o $@ $^ -luuid -lshlwapi -lpsapi
|
||||
|
||||
mingw32.ini: launcher.ini
|
||||
mingw.ini: launcher.ini
|
||||
cp -f $^ $@
|
||||
echo MSYSTEM=MINGW32>> $@
|
||||
mingw32.res: launcher.rc mingw32.ico
|
||||
$(PREFIX)windres -O COFF -o $@ $< -DPRODUCT=MSYS2 -DMSYSTEM=MINGW32 -DICONFILE=mingw32.ico
|
||||
mingw32.exe: launcher.c mingw32.res
|
||||
$(PREFIX)gcc -std=c11 -Wall -Wextra -Werror -static -municode -mwindows -o $@ $^ -DPRODUCT=MSYS2 -DSHELLPATH='usr\\bin\\mintty.exe'
|
||||
|
||||
mingw64.ini: launcher.ini
|
||||
cp -f $^ $@
|
||||
echo MSYSTEM=MINGW64>> $@
|
||||
mingw64.res: launcher.rc mingw64.ico
|
||||
$(PREFIX)windres -O COFF -o $@ $< -DPRODUCT=MSYS2 -DMSYSTEM=MINGW64 -DICONFILE=mingw64.ico
|
||||
mingw64.exe: launcher.c mingw64.res
|
||||
$(PREFIX)gcc -std=c11 -Wall -Wextra -Werror -static -municode -mwindows -o $@ $^ -DPRODUCT=MSYS2 -DSHELLPATH='usr\\bin\\mintty.exe'
|
||||
|
||||
cygwin.ini: launcher.ini
|
||||
cp -f $^ $@
|
||||
echo MSYSTEM=CYGWIN>> $@
|
||||
cygwin.res: launcher.rc cygwin.ico
|
||||
$(PREFIX)windres -O COFF -o $@ $< -DPRODUCT=Cygwin -DMSYSTEM=CYGWIN -DICONFILE=cygwin.ico
|
||||
cygwin.exe: launcher.c cygwin.res
|
||||
$(PREFIX)gcc -std=c11 -Wall -Wextra -Werror -static -municode -mwindows -o $@ $^ -DPRODUCT=Cygwin -DSHELLPATH='bin\\mintty.exe'
|
||||
mingw.res: launcher.rc mingw.ico
|
||||
$(PREFIX)windres -O COFF -o $@ $< -DMSYSTEM=MINGW32 -DICONFILE=mingw.ico
|
||||
mingw.exe: launcher.c mingw.res
|
||||
$(PREFIX)gcc -std=c11 -Wall -Wextra -Werror -municode -mwindows -o $@ $^ -luuid -lshlwapi -lpsapi
|
||||
|
||||
36
PKGBUILD
36
PKGBUILD
@@ -1,36 +0,0 @@
|
||||
_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}"
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
MSYS2 launcher
|
||||
Msys launcher
|
||||
==============
|
||||
|
||||
A helper for launching MSYS2 shells. Features blink-less launching and correct taskbar/start pinning.
|
||||
A helper for launching Msys shells, adapted from the MSYS2 launcher. Features almost blink-less launching and correct taskbar/start pinning.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Just `make` and put the executables inside your MSYS2 root. Needs mintty v2.1.6 or newer (unreleased at the time of writing).
|
||||
Just `make` and put the executables inside your Msys root.
|
||||
|
||||
BIN
cygwin.ico
BIN
cygwin.ico
Binary file not shown.
|
Before Width: | Height: | Size: 153 KiB |
134
launcher.c
134
launcher.c
@@ -3,6 +3,14 @@
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define PSAPI_VERSION 1
|
||||
#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 <stdbool.h>
|
||||
#include <stdio.h>
|
||||
@@ -13,6 +21,11 @@
|
||||
// if any of the properties change, it's best to use a brand new AppID
|
||||
#define APPID_REVISION 9
|
||||
|
||||
struct MainWindow {
|
||||
DWORD pid;
|
||||
HWND handle;
|
||||
};
|
||||
|
||||
static void ShowError(const wchar_t* desc, const wchar_t* err, const long code) {
|
||||
wchar_t msg[1024];
|
||||
|
||||
@@ -141,9 +154,54 @@ static wchar_t* SetEnv(wchar_t* conffile) {
|
||||
return msystem;
|
||||
}
|
||||
|
||||
static bool IsMainWindow(HWND handle) {
|
||||
return GetWindow(handle, GW_OWNER) == (HWND)0 && IsWindowVisible(handle);
|
||||
}
|
||||
|
||||
static BOOL CALLBACK CheckWindow(HWND handle, LPARAM lParam) {
|
||||
struct MainWindow* data = (struct MainWindow*)lParam;
|
||||
DWORD pid = 0;
|
||||
GetWindowThreadProcessId(handle, &pid);
|
||||
if (data->pid != pid || !IsMainWindow(handle)) {
|
||||
return TRUE;
|
||||
}
|
||||
data->handle = handle;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static HWND FindMainWindow(DWORD pid) {
|
||||
struct MainWindow data;
|
||||
data.pid = pid;
|
||||
data.handle = 0;
|
||||
EnumWindows(CheckWindow, (LPARAM)&data);
|
||||
return data.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 wmain(int argc, wchar_t* argv[]) {
|
||||
PROCESS_INFORMATION child;
|
||||
int code;
|
||||
int delay = 10;
|
||||
HWND window;
|
||||
IPropertyStore* store;
|
||||
HRESULT hr;
|
||||
size_t buflen;
|
||||
wchar_t* buf;
|
||||
wchar_t* tmp;
|
||||
@@ -152,6 +210,24 @@ int wmain(int argc, wchar_t* argv[]) {
|
||||
wchar_t msysdir[PATH_MAX];
|
||||
wchar_t exepath[PATH_MAX];
|
||||
wchar_t confpath[PATH_MAX];
|
||||
wchar_t wdpath[PATH_MAX];
|
||||
const size_t proplen = 100;
|
||||
wchar_t prop[proplen];
|
||||
|
||||
code = GetCurrentDirectory(PATH_MAX, wdpath);
|
||||
if (code == 0 || code > PATH_MAX) {
|
||||
ShowErrno(L"Could not determine working directory");
|
||||
return __LINE__;
|
||||
}
|
||||
|
||||
tmp = wdpath;
|
||||
while (true) {
|
||||
tmp = wcschr(tmp, L'\\');
|
||||
if (tmp == NULL) {
|
||||
break;
|
||||
}
|
||||
*tmp = L'/';
|
||||
}
|
||||
|
||||
code = GetModuleFileName(NULL, exepath, sizeof(exepath) / sizeof(exepath[0]));
|
||||
if (code == 0) {
|
||||
@@ -224,7 +300,7 @@ int wmain(int argc, wchar_t* argv[]) {
|
||||
ShowError(L"Could not allocate memory", L"", 0);
|
||||
return __LINE__;
|
||||
}
|
||||
code = swprintf(buf, buflen, L"%s\\%s -i '%s' -o 'AppLaunchCmd=%s' -o 'AppID=%s.Shell.%s.%d' -o 'AppName=%s %s Shell' --store-taskbar-properties -- /usr/bin/bash --login %s %s", msysdir, STRINGIFY_W(SHELLPATH), exepath, exepath, STRINGIFY_W(PRODUCT), msystem, APPID_REVISION, STRINGIFY_W(PRODUCT), msystem, argc == 1 ? L"-i" : L"-c '$0 \"$@\"'", args);
|
||||
code = swprintf(buf, buflen, L"%s\\bin\\mintty.exe -i '%s' -- /bin/bash --login -c 'cd \\'%s\\'; exec %s'", msysdir, exepath, wdpath, argc == 1 ? L"/bin/bash -i" : args);
|
||||
buflen *= 2;
|
||||
}
|
||||
if (code < 0) {
|
||||
@@ -240,5 +316,61 @@ int wmain(int argc, wchar_t* argv[]) {
|
||||
free(buf);
|
||||
buf = NULL;
|
||||
|
||||
while (true) {
|
||||
Sleep(delay);
|
||||
window = FindMainWindow(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__;
|
||||
}
|
||||
|
||||
code = swprintf(prop, proplen, L"Msys.Shell.%s.%d", msystem, APPID_REVISION);
|
||||
if (code < 0) {
|
||||
ShowErrno(L"Could not write to buffer");
|
||||
return __LINE__;
|
||||
}
|
||||
hr = SetAppUserModelProperty(store, &PKEY_AppUserModel_ID, prop);
|
||||
if (FAILED(hr)) {
|
||||
return __LINE__;
|
||||
}
|
||||
|
||||
code = swprintf(prop, proplen, L"Msys %s Shell", msystem);
|
||||
if (code < 0) {
|
||||
ShowErrno(L"Could not write to buffer");
|
||||
return __LINE__;
|
||||
}
|
||||
hr = SetAppUserModelProperty(store, &PKEY_AppUserModel_RelaunchDisplayNameResource, prop);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ BEGIN
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "ProductName", STRINGIFY_A(PRODUCT)
|
||||
VALUE "FileDescription", STRINGIFY_A(PRODUCT) " " STRINGIFY_A(MSYSTEM) " shell launcher"
|
||||
VALUE "ProductName", "Msys"
|
||||
VALUE "FileDescription", "Msys " STRINGIFY_A(MSYSTEM) " shell launcher"
|
||||
VALUE "FileVersion", STRINGIFY_A(VER_MAJOR) "." STRINGIFY_A(VER_MINOR)
|
||||
END
|
||||
END
|
||||
|
||||
BIN
mingw32.ico
BIN
mingw32.ico
Binary file not shown.
|
Before Width: | Height: | Size: 25 KiB |
BIN
mingw64.ico
BIN
mingw64.ico
Binary file not shown.
|
Before Width: | Height: | Size: 25 KiB |
Reference in New Issue
Block a user