26 Commits
msys ... v1.0

Author SHA1 Message Date
David Macek
71fc2d43b7 Release v1.0 2020-05-30 09:42:51 +02:00
David Macek
56c2ba79fc Set mintty window title (especially nice when a custom command is executed) 2016-08-01 20:50:12 +02:00
David Macek
f3d1abf153 Finally fix command execution 2016-08-01 20:49:14 +02:00
David Macek
d8c2c9eb69 Document the pinning procedure 2016-06-06 16:34:19 +02:00
David Macek
4028b6cae0 Replace PATH line with MSYS2_PATH_TYPE line in example config 2016-05-21 22:28:33 +02:00
David Macek
860c495002 Add entry for PowerShell to PATH
To match MSYS2 recent `/etc/profile` changes, an entry for PowerShell is added
to the `PATH` line in `launcher.ini`.
2016-03-30 14:56:50 +02:00
David Macek
b71e7e3674 Respect the user's login shell (fixes #3)
The launcher only specifies "-" as the command and mintty automatically
launches the login shell correctly. This can't work if the launcher needs to
pass additional arguments to the shell (such as `-c "shell command"`), so `sh`
is used as a fallback in that case.
2016-03-19 18:46:53 +01:00
David Macek
6f75d2b3e9 Turn off mingw globbing
I don't see any real effect it had on the launcher's functions, but turning it
off seems more correct.
2016-03-19 18:32:58 +01:00
David Macek
3bb62c7089 Simplify and generalize .gitignore 2016-03-19 17:58:14 +01:00
David Macek
bc7e470429 Fill in copyright information in LICENSE.md 2016-03-19 17:58:14 +01:00
David Macek
92cb91db1b Switch to SHA512 in PKGBUILD 2016-03-19 17:58:14 +01:00
David Macek
2716832118 Fix formatting in launcher.rc 2016-03-19 17:58:14 +01:00
Liam Bowen
b81f4dd5e3 Add .editorconfig to use tabs 2016-03-19 17:58:14 +01:00
David Macek
e09bbea607 Update README.md to mention .ini files; remove note about unreleased mintty (fixes #2) 2016-03-19 17:58:13 +01:00
David Macek
430f154584 Replace icons with prettier ones 2016-03-19 17:50:26 +01:00
David Macek
58b5c72ead Add .ini files to backup field of PKGBUILD; Enable expansion of .ini files contents; Add a clean PATH template 2015-11-09 23:46:10 +01:00
David Macek
1a1c5866e0 Fixed indentation 2015-11-04 12:15:25 +01:00
David Macek
a05668dffc Fixed bad value of "Start in" field after pinning; plus various fixed:
- version information consolidated into version.h
- removed strip from Makefile
- updated PKGBUILD
- fixed minor things in launcher.c
- added header guards
2015-11-04 12:11:00 +01:00
David Macek
551bb174b0 Fix MSYSTEM variable detection 2015-10-29 18:09:58 +01:00
David Macek
afa868fd7b Add PKGBUILD 2015-10-28 23:35:42 +01:00
David Macek
619f3830af Set CHERE_INVOKING and MSYSCON 2015-10-28 23:17:14 +01:00
David Macek
174fc35707 Bump version to 0.2 2015-10-28 23:00:55 +01:00
David Macek
292186be44 Refactored path handling; environment is now read from a file 2015-10-28 23:00:42 +01:00
David Macek
2c0e3b8e0c Allow passing arguments in order to launch a command 2015-10-28 22:00:55 +01:00
David Macek
ee4a2d0fe9 Switch to C11; refactor error reporting; switch to dynamic buffer allocation 2015-10-28 21:19:26 +01:00
David Macek
6a011ed295 Switch to unicode; make launcher compatible with new mintty 2015-10-28 20:49:37 +01:00
15 changed files with 100 additions and 173 deletions

View File

@@ -1,4 +1,4 @@
root = true
[*.{c,h}]
[*.{c,h,rc}]
indent_style = tab

13
.gitignore vendored
View File

@@ -1,6 +1,7 @@
/msys.exe
/msys.res
/msys.ini
/mingw.exe
/mingw.res
/mingw.ini
/*.exe
/*.res
/*.ini
/*.pkg.tar.xz
/*.pkg.tar.xz.sig
/pkg/
/src/

View File

@@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) <year> <copyright holders>
Copyright (c) 2015 David Macek
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,22 +1,29 @@
PREFIX=
msys: msys.exe msys.ini mingw.exe mingw.ini
all: msys
all: msys2.exe msys2.ini mingw32.exe mingw32.ini mingw64.exe mingw64.ini
.PHONY: all msys
.PHONY: all
msys.ini: launcher.ini
msys2.ini: launcher.ini
cp -f $^ $@
echo MSYSTEM=MSYS>> $@
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
msys2.res: launcher.rc msys2.ico
$(PREFIX)windres -O COFF -o $@ $< -DMSYSTEM=MSYS -DICONFILE=msys2.ico
msys2.exe: launcher.c msys2.res
$(PREFIX)gcc -std=c11 -Wall -Wextra -Werror -static -municode -mwindows -o $@ $^
mingw.ini: launcher.ini
mingw32.ini: launcher.ini
cp -f $^ $@
echo MSYSTEM=MINGW32>> $@
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
mingw32.res: launcher.rc mingw32.ico
$(PREFIX)windres -O COFF -o $@ $< -DMSYSTEM=MINGW32 -DICONFILE=mingw32.ico
mingw32.exe: launcher.c mingw32.res
$(PREFIX)gcc -std=c11 -Wall -Wextra -Werror -static -municode -mwindows -o $@ $^
mingw64.ini: launcher.ini
cp -f $^ $@
echo MSYSTEM=MINGW64>> $@
mingw64.res: launcher.rc mingw64.ico
$(PREFIX)windres -O COFF -o $@ $< -DMSYSTEM=MINGW64 -DICONFILE=mingw64.ico
mingw64.exe: launcher.c mingw64.res
$(PREFIX)gcc -std=c11 -Wall -Wextra -Werror -static -municode -mwindows -o $@ $^

36
PKGBUILD Normal file
View File

@@ -0,0 +1,36 @@
_realname="msys2-launcher"
pkgname=("${_realname}-git")
pkgver=1.0
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)
sha512sums=('eac22e62609e06a49931f70b12abaf0f1a412a98bcf349a2b6a0738b511d05ed7ce7731d2e30f9510926c3175d3521d0164e25cd70e9b18ba33aeb887deef11e'
'5ed8a2e9997d9d2c1e17940292d68542f897e2716b274741d8a3ba7c8f46235c175b7e0a1252a879ba3c79b571504d25de2a8d6b004aedd117d263195bc2b185'
'cf257f1f5b7fc69a32c63fe5bf5299db078621850b1e12358654d71da7777a94a0668d657c1834be308db099cad9d48a42fa7877ad58dfdbd576248150913a12'
'6019ca0d67375c1261dda0d54d45fc411b02244c51b71d5c57d2613e9edfb4e8f9000754e5c7d632ed0101005c01cd0a98c3961d5b5f51c94d83eceba4296d35'
'2e2669db2e8ef54ff6859f4e9a2657f867aef89094f29386da6df6a39931b55927bd16f92a5058fb4aecc5705a2bf3a867172740bc53bca560b98820790ad3c9'
'270db9d92b944754cc71523053532473d8a477241725e7aded02dc34d35895a33cf135be7a87692c0f9d2204731e345b8ae82d33f15a1a197e73357552c564e0'
'27b9591fa286a15b0eb76a381191f025184d545359285215b9958632a5bce99484de0130296ff4b285e38cec9d88299c09b2ce1fe4b4957b4ef295d31a620817'
'b1ecd3def00a023a9e88806ff9bbb1bbd73086fbf7554799eb5fe8adb16bf96ed1a7da375bb2b9f9268fcf08e25dab4414bb4888e1ee6eff4587ee0973374f6f'
'7f369b102391eba9ab56e1fb2157f820ecce41434b7232137da32b924b2d53840731e18ef80916703effc6770e862d1fee2986e66c1d03a8c8bb3feef4f08d58')
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}"
}

View File

@@ -1,9 +1,23 @@
Msys launcher
MSYS2 launcher
==============
A helper for launching Msys shells, adapted from the MSYS2 launcher. Features almost blink-less launching and correct taskbar/start pinning.
A helper for launching MSYS2 shells. Features blink-less launching and correct taskbar/start pinning.
Installation
------------
Just `make` and put the executables inside your Msys root.
Just `make` and put the .exe and .ini files inside your MSYS2 root. Needs mintty v2.1.6 or newer.
Configuration
-------------
All three default launchers are the same (except for embedded icons and descriptions) and are configured by corresponding .ini files. The .ini file has to be in the same directory as the .exe file and have the same filename (except for the `.exe` -> `.ini` change).
By default, only `MSYSTEM` is set, but options for inheriting `PATH` and tweaking `MSYS` are prepared, as well as `CHERE_INVOKING` for the shell to stay in the current working directory (instead of changing to the home directory).
The .ini file contains environment variables, each on a separate line, in the usual `VAR=val` format. Lines starting with `#` are ignored. The values are expanded using the current environment (use Windows `%var%` syntax).
Pinning
-------
As with many other applications, the correct way to pin a shortcut to the taskbar is by right-clicking the button of a running MSYS2 shell (started by this launcher) on the taskbar and choosing "Pin this program to taskbar". Pinning the `.exe` file itself won't create the shortcut correctly. There are tools to diagnose and fix such a situation (7+ Taskbar Tweaker and Win7AppId) in case re-pinning is not preferred.

View File

@@ -3,29 +3,17 @@
#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>
#include <wchar.h>
int _CRT_glob = 0;
#include "macros.h"
// 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];
@@ -154,54 +142,9 @@ 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;
@@ -210,24 +153,6 @@ 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) {
@@ -300,7 +225,7 @@ int wmain(int argc, wchar_t* argv[]) {
ShowError(L"Could not allocate memory", L"", 0);
return __LINE__;
}
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);
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' -t 'MSYS2 %s Shell' --store-taskbar-properties -- %s %s", msysdir, exepath, exepath, msystem, APPID_REVISION, msystem, msystem, argc == 1 ? L"-" : L"/usr/bin/sh -lc '\"$@\"' sh", args);
buflen *= 2;
}
if (code < 0) {
@@ -316,61 +241,5 @@ 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;
}

View File

@@ -1,4 +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
#MSYS2_PATH_TYPE=inherit

View File

@@ -4,20 +4,20 @@
1 VERSIONINFO
FILEVERSION VER_MAJOR,VER_MINOR,0,0
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "ProductName", "Msys"
VALUE "FileDescription", "Msys " STRINGIFY_A(MSYSTEM) " shell launcher"
VALUE "FileVersion", STRINGIFY_A(VER_MAJOR) "." STRINGIFY_A(VER_MINOR)
END
END
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "ProductName", "MSYS2"
VALUE "FileDescription", "MSYS2 " STRINGIFY_A(MSYSTEM) " shell launcher"
VALUE "FileVersion", STRINGIFY_A(VER_MAJOR) "." STRINGIFY_A(VER_MINOR)
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
id ICON STRINGIFY_A(ICONFILE)

BIN
mingw.ico

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

BIN
mingw32.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
mingw64.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
msys.ico

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

BIN
msys2.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@@ -1,7 +1,7 @@
#ifndef M2L_VERSION_H
#define M2L_VERSION_H
#define VER_MAJOR 0
#define VER_MINOR 1
#define VER_MAJOR 1
#define VER_MINOR 0
#endif