Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1f61267a80 | ||
|
|
63d9db698d | ||
|
|
4db021b108 | ||
|
|
c48fc7a171 | ||
|
|
ca3dab79a1 | ||
|
|
1817f53cae | ||
|
|
49787dc7b0 | ||
|
|
ff1f8ff198 | ||
|
|
cf1a24cc86 | ||
|
|
e6513f6bfc | ||
|
|
926eb2aca2 | ||
|
|
80b13a5633 | ||
|
|
829d0a3519 | ||
|
|
55e038fd95 | ||
|
|
758fb5ca69 | ||
|
|
2620c586e7 | ||
|
|
ec64a722c1 | ||
|
|
f810bdba12 | ||
|
|
40250566fa |
2
.gitattributes
vendored
@@ -1,2 +1,2 @@
|
||||
# Declare files that always have LF line endings on checkout
|
||||
* text eol=lf
|
||||
PKGBUILD text eol=lf
|
||||
8
.github/workflows/test.yml
vendored
@@ -15,15 +15,17 @@ jobs:
|
||||
with:
|
||||
msystem: MSYS
|
||||
update: true
|
||||
install: msys2-devel base-devel
|
||||
install: msys2-devel base-devel mingw-w64-cross-gcc
|
||||
|
||||
- name: Build
|
||||
shell: msys2 {0}
|
||||
run: |
|
||||
makepkg -Csfri --noconfirm --nocheck
|
||||
make PREFIX=/opt/bin/x86_64-w64-mingw32-
|
||||
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: package
|
||||
path: '*.pkg.tar.*'
|
||||
path: |
|
||||
*.exe
|
||||
*.ini
|
||||
|
||||
18
Makefile
@@ -1,6 +1,6 @@
|
||||
PREFIX=
|
||||
|
||||
all: msys2.exe msys2.ini mingw32.exe mingw32.ini mingw64.exe mingw64.ini ucrt64.exe ucrt64.ini clang64.exe clang64.ini
|
||||
all: msys2.exe msys2.ini mingw32.exe mingw32.ini mingw64.exe mingw64.ini ucrt64.exe ucrt64.ini clang64.exe clang64.ini clang32.exe clang32.ini clangarm64.exe clangarm64.ini
|
||||
|
||||
.PHONY: all
|
||||
|
||||
@@ -43,3 +43,19 @@ clang64.res: launcher.rc clang64.ico
|
||||
$(PREFIX)windres -O COFF -o $@ $< -DMSYSTEM=CLANG64 -DICONFILE=clang64.ico
|
||||
clang64.exe: launcher.c clang64.res
|
||||
$(PREFIX)gcc -std=c11 -Wall -Wextra -Werror -static -municode -mwindows -o $@ $^
|
||||
|
||||
clang32.ini: launcher.ini
|
||||
cp -f $^ $@
|
||||
echo MSYSTEM=CLANG32>> $@
|
||||
clang32.res: launcher.rc clang32.ico
|
||||
$(PREFIX)windres -O COFF -o $@ $< -DMSYSTEM=CLANG32 -DICONFILE=clang32.ico
|
||||
clang32.exe: launcher.c clang32.res
|
||||
$(PREFIX)gcc -std=c11 -Wall -Wextra -Werror -static -municode -mwindows -o $@ $^
|
||||
|
||||
clangarm64.ini: launcher.ini
|
||||
cp -f $^ $@
|
||||
echo MSYSTEM=CLANGARM64>> $@
|
||||
clangarm64.res: launcher.rc clangarm64.ico
|
||||
$(PREFIX)windres -O COFF -o $@ $< -DMSYSTEM=CLANGARM64 -DICONFILE=clangarm64.ico
|
||||
clangarm64.exe: launcher.c clangarm64.res
|
||||
$(PREFIX)gcc -std=c11 -Wall -Wextra -Werror -static -municode -mwindows -o $@ $^
|
||||
|
||||
26
PKGBUILD
@@ -1,27 +1,29 @@
|
||||
_realname="msys2-launcher"
|
||||
pkgname=("${_realname}-git")
|
||||
pkgver=1.1
|
||||
pkgver=1.5
|
||||
pkgrel=1
|
||||
pkgdesc="Helper for launching MSYS2 shells"
|
||||
arch=('x86_64' 'i686')
|
||||
license=('MIT')
|
||||
backup=({mingw32,mingw64,msys2}.ini)
|
||||
backup=({msys2,mingw32,mingw64,ucrt64,clang64}.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,ucrt64,clang64}.ico)
|
||||
sha512sums=('eac22e62609e06a49931f70b12abaf0f1a412a98bcf349a2b6a0738b511d05ed7ce7731d2e30f9510926c3175d3521d0164e25cd70e9b18ba33aeb887deef11e'
|
||||
source=(launcher.{c,ini,rc} {macros,version}.h Makefile {msys2,mingw32,mingw64,ucrt64,clang64,clang32,clangarm64}.ico)
|
||||
sha512sums=('ed2937084cc7d176bb9f06af96121dbf4433a05cfc8fa260918a5f96ed5e8c4201fa2b45aa196a858ece0c8a86f7ffc617a8330b57b7231a4ea4ab23d75920b0'
|
||||
'5ed8a2e9997d9d2c1e17940292d68542f897e2716b274741d8a3ba7c8f46235c175b7e0a1252a879ba3c79b571504d25de2a8d6b004aedd117d263195bc2b185'
|
||||
'cf257f1f5b7fc69a32c63fe5bf5299db078621850b1e12358654d71da7777a94a0668d657c1834be308db099cad9d48a42fa7877ad58dfdbd576248150913a12'
|
||||
'6019ca0d67375c1261dda0d54d45fc411b02244c51b71d5c57d2613e9edfb4e8f9000754e5c7d632ed0101005c01cd0a98c3961d5b5f51c94d83eceba4296d35'
|
||||
'07ef013bddc4241408c14c094311b408627b9ba773716fa64389188a1d38bb5089ca4f36c59d71bef816c8fc3381adff6db455a58a13735239e96972426a48a6'
|
||||
'a8f7568ae878481641422a8e9c1d19e84b3d33815f179af179fa9c83ebac9fb5834a939b97b38b5b5c53f9f86753daf06d1e1551019764d3f8305571e6fe32d5'
|
||||
'a591e978af84a5deec5dfd28e421ba165d8d3d23b5e58a828346edadbdaecf8f6c847862b318af3e04f3fdf8531b3e7344e7f38e757ca208ec175822be132f51'
|
||||
'88940f62af67685894bfe897fe6a1b8bce439708e18d0c0c1d065c44e8a5e3ce414e65c66c5f572f1ffd6f713d1ab8810a5f7e737ecaa0f5b9ff567a86589c33'
|
||||
'29a9d80f338eaa6e39e6ed0b8941d579e9483de8db4499ccb4723c1cce4bce03dee07e9fda54a21d39d5de13c979395cfaf43bea91f50fc930dfc30a13dbcae6'
|
||||
'f1729c410b8027587c8865afa04113a667214761fd82748e896b7b53dfe93186537898edc87d12add9e4be208bfe45333fcb1824655c5c46b1e71ec048d83739'
|
||||
'2a7925862864ad350f334e84ebe0da2160532b08faa1bd9923bb6848ccc6541054d027ffa6ccfd6861170afd06e126c33fcb0d89d4a08d694ef5ead53ff0dc96')
|
||||
'972d366b7e4bffeafbd624cea89c2f5d7cf7ee6f14b3534c39e42711b9257b76054578b23c41d6fe1d10d0d848fbc2c32b86ea611f98ffa22f60be7067a44edc'
|
||||
'76fc9b0fc5931d748f02d8b726f2e461e04c8e31aaac309c8ed349f303f3c976cb2972c89913b0192ebfcfe13bf5b1c1ffd1ea11439e2a2c6d819207eead89ad'
|
||||
'b0eb5a71d4611fd79a681e89ce1c915a12858c7be4d64740b9d127576d39cba352696a594cfb8392aaf00dad0f12c40c78e8fd2019b15c88507286efa0171e0d'
|
||||
'24e05f79df6aa51ca85fee43f1d10eeace85739d60ab5b2bfc82b2b6edd3040e6ae0355fdd3f4455eb7adb83e3c6269457b2462552fd3b5d5a5e14c0771c3437'
|
||||
'7749d962dd19b4e93bf74ca339fd1c06fd457dd92ea501d4a19b34973ce2b0ddd9c9ed09921c26bea3adc7dfbbd821042b467ffc6d4050b6301c025d4f0c844d'
|
||||
'e77d67d33fb364d84416a727d24a5fabdedc4b42ddccffd296ac6c2049cbdc8b7df700a492f386a812867924c8dc2a34b0c858bc1a252957db06e9f1869d7ff2'
|
||||
'a1fcffd0b7fe7f3e2c18d03206909aba830e983925a85ef69dc165606e543e53eb17164a089d84a40cc53d6a626cce2302071aec8519b7e44f001b2d4602d5e2'
|
||||
'13118938dc6a084a005d723f329fffa3364284254d9167fe04e93c0ca870b7b3bef1e9a5f0b5b2a7df14f3f1af9a589fc2709d1593231fa3615174b062e62d70'
|
||||
'29f607099a6f1aab35bec2e4a78701ba2b7c4adf2385e5a2da4167b89b1f46cde2070a01182271a8fbde03c4bb8c7e29a6cb4c4d8308c3be9c503ad84f986ba3')
|
||||
|
||||
pkgver() {
|
||||
local _major=$(cat version.h | grep -F 'VER_MAJOR' | head -1 | sed -e 's/.* //')
|
||||
@@ -34,5 +36,5 @@ build() {
|
||||
}
|
||||
|
||||
package() {
|
||||
cp {mingw32,mingw64,ucrt64,clang64,msys2}.{exe,ini} "${pkgdir}"
|
||||
cp {msys2,mingw32,mingw64,ucrt64,clang64,clang32,clangarm64}.{exe,ini} "${pkgdir}"
|
||||
}
|
||||
|
||||
14
README.md
@@ -1,23 +1,25 @@
|
||||
MSYS2 launcher
|
||||
==============
|
||||
|
||||
A helper for launching MSYS2 shells. Features 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 .exe and .ini files inside your MSYS2 root. Needs mintty v2.1.6 or newer.
|
||||
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).
|
||||
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), evaluated from top to bottom. By default, only `MSYSTEM` is set and the rest is inherited from the outside environment, but some common options are prepared and commented out in the files:
|
||||
|
||||
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).
|
||||
- `MSYS=...`: configures runtime behavior
|
||||
- `CHERE_INVOKING=1`: prevent the login scripts from changing the working directory to the user's home directory
|
||||
- `MSYS2_PATH_TYPE=strict|minimal|inherit`: configures how the login scripts set up `PATH`
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
BIN
clang32.ico
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
clang64.ico
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 30 KiB |
BIN
clangarm64.ico
Normal file
|
After Width: | Height: | Size: 30 KiB |
@@ -1,4 +1,4 @@
|
||||
all: ../msys2.ico ../mingw32.ico ../mingw64.ico ../clang64.ico ../ucrt64.ico
|
||||
all: ../msys2.ico ../mingw32.ico ../mingw64.ico ../ucrt64.ico ../clang64.ico ../clang32.ico ../clangarm64.ico
|
||||
|
||||
sources=icon-large.svg icon-medium.svg icon-small.svg
|
||||
|
||||
@@ -11,8 +11,14 @@ sources=icon-large.svg icon-medium.svg icon-small.svg
|
||||
../mingw64.ico: $(sources)
|
||||
./build.sh '#276597' $@
|
||||
|
||||
../ucrt64.ico: $(sources)
|
||||
./build.sh '#8b7b16' $@
|
||||
|
||||
../clang64.ico: $(sources)
|
||||
./build.sh '#be643e' $@
|
||||
|
||||
../ucrt64.ico: $(sources)
|
||||
./build.sh '#8b7b16' $@
|
||||
../clang32.ico: $(sources)
|
||||
./build.sh '#d49b63' $@
|
||||
|
||||
../clangarm64.ico: $(sources)
|
||||
./build.sh '#238423' $@
|
||||
|
||||
@@ -12,6 +12,7 @@ rsvg-convert temp-small.svg -w 16 -h 16 --output temp-16.png
|
||||
rsvg-convert temp-small.svg -w 32 -h 32 --output temp-32.png
|
||||
rsvg-convert temp-medium.svg -w 48 -h 48 --output temp-48.png
|
||||
rsvg-convert temp-large.svg -w 64 -h 64 --output temp-64.png
|
||||
rsvg-convert temp-large.svg -w 128 -h 128 --output temp-128.png
|
||||
convert temp-16.png temp-32.png temp-48.png temp-64.png temp-128.png +dither -colors 255 "$2"
|
||||
rsvg-convert temp-large.svg -w 96 -h 96 --output temp-96.png
|
||||
rsvg-convert temp-large.svg -w 256 -h 256 --output temp-256.png
|
||||
convert temp-16.png temp-32.png temp-48.png temp-64.png temp-96.png temp-256.png +dither -colors 255 "$2"
|
||||
rm temp-*.png temp-*.svg
|
||||
|
||||
65
launcher.c
@@ -1,3 +1,4 @@
|
||||
#define __USE_MINGW_ANSI_STDIO 1
|
||||
#define _UNICODE
|
||||
#define _WIN32_WINNT 0x0601
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
@@ -17,7 +18,7 @@ int _CRT_glob = 0;
|
||||
static void ShowError(const wchar_t* desc, const wchar_t* err, const long code) {
|
||||
wchar_t msg[1024];
|
||||
|
||||
swprintf(msg, 1024, L"%s. Reason: %s (0x%lx)", desc, err, code);
|
||||
swprintf(msg, 1024, L"%ls. Reason: %ls (0x%lx)", desc, err, code);
|
||||
MessageBox(NULL, msg, L"Launcher error", MB_ICONEXCLAMATION | MB_OK);
|
||||
}
|
||||
|
||||
@@ -38,6 +39,22 @@ static void ShowErrno(const wchar_t* desc) {
|
||||
ShowError(desc, err, errno);
|
||||
}
|
||||
|
||||
// adapted from http://www.partow.net/programming/hashfunctions/index.html
|
||||
// MIT licensed
|
||||
static unsigned int APHash(const wchar_t* str, size_t length) {
|
||||
unsigned int hash = 0xAAAAAAAA;
|
||||
size_t i = 0;
|
||||
|
||||
for (i = 0; i < length; ++str, ++i) {
|
||||
hash ^= ((i & 1) == 0)
|
||||
? ((hash << 7) ^ (*str) * (hash >> 3))
|
||||
: (~((hash << 11) + ((*str) ^ (hash >> 5))))
|
||||
;
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
static PROCESS_INFORMATION StartChild(wchar_t* cmdline) {
|
||||
STARTUPINFOW si;
|
||||
PROCESS_INFORMATION pi;
|
||||
@@ -150,22 +167,19 @@ int wmain(int argc, wchar_t* argv[]) {
|
||||
wchar_t* tmp;
|
||||
wchar_t* args;
|
||||
wchar_t* msystem;
|
||||
wchar_t* msysdirhash;
|
||||
wchar_t msysdir[PATH_MAX];
|
||||
wchar_t exepath[PATH_MAX];
|
||||
wchar_t confpath[PATH_MAX];
|
||||
|
||||
code = GetModuleFileName(NULL, exepath, sizeof(exepath) / sizeof(exepath[0]));
|
||||
code = GetModuleFileName(NULL, exepath, sizeof(exepath) / sizeof(*exepath));
|
||||
if (code == 0) {
|
||||
ShowLastError(L"Could not determine executable path");
|
||||
return __LINE__;
|
||||
}
|
||||
|
||||
tmp = exepath;
|
||||
while (true) {
|
||||
tmp = wcschr(tmp, L'/');
|
||||
if (tmp == NULL) {
|
||||
break;
|
||||
}
|
||||
while ((tmp = wcschr(tmp, L'/')) != NULL) {
|
||||
*tmp = L'\\';
|
||||
}
|
||||
|
||||
@@ -177,9 +191,24 @@ int wmain(int argc, wchar_t* argv[]) {
|
||||
}
|
||||
*tmp = L'\0';
|
||||
|
||||
msysdirhash = (wchar_t*)alloca(10 * sizeof(wchar_t)); // dot + unsigned int as %x + null
|
||||
if (msysdirhash == NULL) {
|
||||
ShowError(L"Could not allocate memory", L"", 0);
|
||||
return __LINE__;
|
||||
}
|
||||
if (wcsicmp(msysdir, L"C:\\msys64") == 0) {
|
||||
code = swprintf(msysdirhash, 10, L""); // no change in AppID for default installations
|
||||
} else {
|
||||
code = swprintf(msysdirhash, 10, L".%8x", APHash(msysdir, wcslen(msysdir)));
|
||||
}
|
||||
if (code < 0) {
|
||||
ShowErrno(L"Could not write to buffer");
|
||||
return __LINE__;
|
||||
}
|
||||
|
||||
wcscpy(confpath, exepath);
|
||||
tmp = confpath + wcslen(confpath) - 4;
|
||||
if (0 != wcsicmp(L".exe", tmp)) {
|
||||
if (wcsicmp(L".exe", tmp) != 0) {
|
||||
ShowError(L"Could not find configuration file", confpath, 0);
|
||||
return __LINE__;
|
||||
}
|
||||
@@ -206,13 +235,23 @@ int wmain(int argc, wchar_t* argv[]) {
|
||||
ShowLastError(L"Could not set environment variable");
|
||||
}
|
||||
|
||||
// can break, but hopefully won't for most use cases
|
||||
args = GetCommandLine();
|
||||
if (args[0] == L'"') {
|
||||
tmp = argv[0];
|
||||
while (*tmp != L'\0') {
|
||||
if (*args == *tmp) {
|
||||
args++;
|
||||
tmp++;
|
||||
} else if (*args == L'"') {
|
||||
args++;
|
||||
} else {
|
||||
ShowError(L"Could not parse command name", argv[0], 0);
|
||||
return __LINE__;
|
||||
}
|
||||
}
|
||||
while (*args == L'"') {
|
||||
args++;
|
||||
}
|
||||
args += wcslen(argv[0]);
|
||||
if (args[0] == L'"') {
|
||||
while (*args == L' ') {
|
||||
args++;
|
||||
}
|
||||
|
||||
@@ -225,7 +264,7 @@ int wmain(int argc, wchar_t* argv[]) {
|
||||
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' -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);
|
||||
code = swprintf(buf, buflen, L"%ls\\usr\\bin\\mintty.exe -i '%ls' -o 'AppLaunchCmd=%ls' -o 'AppID=MSYS2.Shell.%ls.%d%ls' -o 'AppName=MSYS2 %ls Shell' -t 'MSYS2 %ls Shell' --store-taskbar-properties -- %ls %ls", msysdir, exepath, exepath, msystem, APPID_REVISION, msysdirhash, msystem, msystem, argc == 1 ? L"-" : L"/usr/bin/sh -lc '\"$@\"' sh", args);
|
||||
buflen *= 2;
|
||||
}
|
||||
if (code < 0) {
|
||||
|
||||
BIN
mingw32.ico
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 30 KiB |
BIN
mingw64.ico
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 30 KiB |
BIN
msys2.ico
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 38 KiB |
BIN
ucrt64.ico
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 30 KiB |