Skip to content

Commit 7e43b77

Browse files
committed
Switch qlview over to a full macOS app.
This stops building `qlview` as a command-line application and makes it a normal app instead. As an app, it now supports a new URL scheme `qlview:/path/to/file` that allows opening documents from the command-line simply via `open`. The advantage of that approach is that we no longer end up start up separate `qlview` instances for each document being opened. We also switch from distributing a ZIP file to a more standard DMG.
1 parent 37ea1aa commit 7e43b77

File tree

31 files changed

+405
-294
lines changed

31 files changed

+405
-294
lines changed

.github/workflows/main.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@ name: CI pipeline
33
on: push
44

55
jobs:
6-
adhoc:
7-
runs-on: macos-14
6+
build:
7+
runs-on: macos-15
88

99
steps:
1010
- uses: actions/checkout@v4
1111

1212
- name: Build code
13-
run: make adhoc
13+
run: make build
1414

15-
release:
16-
runs-on: macos-14
15+
dist:
16+
if: github.ref == 'refs/heads/main'
17+
runs-on: macos-15
1718
environment: release-macos
1819

1920
steps:
@@ -52,13 +53,10 @@ jobs:
5253
xcrun notarytool store-credentials -k "${APP_STORE_KEY_PATH}" -d "${APP_STORE_KEY_ID}" -i "${APP_STORE_ISSUER_ID}" --keychain "${KEYCHAIN_PATH}" --no-validate "App Store Connect - Notarization API Key"
5354
rm "${APP_STORE_KEY_PATH}"
5455
55-
- name: Build code
56-
run: make release
57-
5856
- name: Build and notarize distribution
5957
run: |
6058
make dist
61-
(cd build && echo "DIST=$(echo *.zip)" >>$GITHUB_ENV)
59+
(cd build && echo "DIST=$(echo *.dmg)" >>$GITHUB_ENV)
6260
6361
- uses: actions/upload-artifact@v4
6462
with:
@@ -71,13 +69,13 @@ jobs:
7169
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db
7270
rm -f $RUNNER_TEMP/key.p8
7371
74-
publish_release:
72+
publish:
7573
permissions:
7674
contents: write
7775

7876
runs-on: macos-14
7977
if: (startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-dev'))
80-
needs: [release]
78+
needs: [dist]
8179

8280
steps:
8381
- name: Checkout code
@@ -107,4 +105,4 @@ jobs:
107105
name: ${{ env.release_name }}
108106
body_path: ${{ runner.temp }}/release-msg
109107
files: |
110-
artifacts/*/*.zip
108+
artifacts/*/*.dmg

.pre-commit-config.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,21 @@ repos:
99
entry: swift-format format -i
1010
language: system
1111
types: ["swift"]
12-
stages: ["commit"]
12+
stages: ["pre-commit"]
1313

1414
- repo: https://github.com/pre-commit/pre-commit-hooks
1515
rev: v4.0.1
1616
hooks:
1717
- id: trailing-whitespace
18+
exclude: '\.pxd$'
1819
- id: end-of-file-fixer
20+
exclude: '\.pxd$'
1921
- id: check-added-large-files
22+
23+
- repo: local
24+
hooks:
25+
- id: update-version
26+
name: Update version number in Xcode project
27+
entry: ./update-version
28+
language: script
29+
pass_filenames: false

.update-changes.cfg

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,8 @@
22

33
new_commit_msg="Update CHANGES."
44
show_authors=0
5-
new_version_hook=replace_version_in_info_plist
65
git_msg=git_msg_with_issue
76

8-
function replace_version_in_info_plist {
9-
version=$1
10-
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${version}" qlview/Info.plist
11-
git add -u qlview/Info.plist
12-
git commit --amend --no-edit
13-
}
14-
157
function git_msg_with_issue {
168
git show -s --pretty=format:%B $1 | gawk 'match($0, "([Ii]ssue|[Gg][Hh]|#)[ _-]?([0-9]+)", x) { issues[x[2]] = 1} { msg = msg $0 "\n"; } END { for ( i in issues ) printf("GH-%s: ", i); print msg; }'
179
}
18-
19-
function new_version_hook {
20-
replace_version_in_info_plist $@
21-
}

Makefile

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,43 @@
11

22
VERSION=$(shell cat VERSION)
33
NOTARIZATION_PROFILE="App Store Connect - Notarization API Key"
4+
CODESIGN_IDENTITY="Developer ID Application: Robin Sommer (4UJK727T59)"
45

5-
all: adhoc
6+
DMG="build/qlview-$(VERSION).dmg"
67

7-
adhoc:
8-
xcodebuild -quiet -target qlview-adhoc -configuration Release
8+
all: build
99

10-
release:
11-
xcodebuild -quiet -target qlview-signed -configuration Release
12-
codesign --verify --verbose build/Release/qlview
10+
build:
11+
xcodebuild -quiet -target qlview -configuration Release
1312

14-
check:
15-
16-
zip:
13+
dmg:
14+
rm -f $(DMG)
1715
rm -rf build/dist
1816
mkdir -p build/dist
19-
cp -R build/Release/qlview build/dist
20-
cp -R mutt build/dist
21-
cd build/dist && zip -r ../qlview-$(VERSION).zip *
22-
ls build/*.zip | sed 's/^/> /'
17+
cp -a build/Release/qlview.app build/dist
18+
cp -a mutt build/dist
19+
cp -a resources/DS_Store build/dist/.DS_Store
20+
ln -s /Applications/ build/dist/Applications
21+
codesign -f --timestamp -o runtime -s $(CODESIGN_IDENTITY) build/dist/qlview.app
22+
hdiutil create -volname "qlview $(VERSION)" -srcFolder build/dist -o $(DMG)
23+
codesign --timestamp -s $(CODESIGN_IDENTITY) $(DMG)
24+
codesign --verify --verbose $(DMG)
2325

2426
notarize:
25-
xcrun notarytool submit --keychain-profile $(NOTARIZATION_PROFILE) --wait --timeout 10m build/qlview-$(VERSION).zip
27+
xcrun notarytool submit --keychain-profile $(NOTARIZATION_PROFILE) --wait --timeout 10m $(DMG)
28+
xcrun stapler staple $(DMG)
2629

27-
dist: zip notarize
30+
check:
31+
@echo
32+
syspolicy_check distribution $(DMG)
33+
34+
dist: build dmg notarize check
35+
@echo
36+
ls build/*.dmg | sed 's/^/> /'
2837

2938
clean:
3039
rm -rf build
40+
41+
icons:
42+
# github.com:abeintopalo/AppIconSetGen.git
43+
appiconsetgen resources/icon.png --output qlview/Assets.xcassets --macOS

README.md

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,45 @@
22

33
This is a standalone document previewer based on macOS's built-in
44
Quick Look engine——imagine a nicer `qlmanage`. It's particularly
5-
useful as a quick command-line viewer for terminal applications, like
6-
[mutt](http://www.mutt.org).
5+
useful for using from the command line or inside terminal
6+
applications, like [mutt](http://www.mutt.org).
77

88
![Screenshot](screenshot.png "Screenshot")
99

1010
## Installation
1111

1212
You can either download a [pre-built
1313
release](https://github.com/rsmmr/qlview/releases), or build it
14-
yourself. Either way, you then probably want to copy the executable
15-
into your `PATH`.
14+
yourself.
1615

17-
When getting the current release, you'll find the executable inside
18-
the ZIP file you downloaded. While it's codesigned and notarized,
19-
please note that you still cannot just double-click to run it, as it
20-
is not an app but a command line application.
16+
When getting the current release, install it like any other
17+
application: open the disk image and drag the app to your
18+
`Applications` folder.
2119

2220
When building it yourself, make sure you have Xcode installed. Either
2321
use that to open and build the project, or just run `make` from the
24-
command line. You will then find the executable in
25-
`build/Release/qlview`.
22+
command line. You will then find the application in
23+
`build/Release/qlview.app`.
2624

2725
## Usage
2826

29-
Run it from the command line:
27+
You can start `qlview` from the Finder, and it'll open an empty window
28+
where you can drag a document into. More usefully, you can open
29+
documents from the command line through a custom URL scheme:
3030

3131
```
32-
# qlview <file>
32+
# open qlview:/path/to/file
3333
```
3434

35-
If you execute `qlview` without any arguments, it'll open an empty
36-
window where you can drag a document into.
37-
3835
## Mutt integration
3936

4037
To use `qlview` with [mutt](http://www.mutt.org), there's a helper
4138
script
4239
[mutt-qlview](https://github.com/rsmmr/qlview/blob/main/mutt/mutt-qlview)
43-
coming with the distribution. Put both that script and `qlview` itself
44-
into your `PATH` and then add [these mailcap
40+
coming with the distribution. Put that script into your `PATH` and
41+
then add [these mailcap
4542
entries](https://github.com/rsmmr/qlview/blob/main/mutt/mailcap) to
46-
your mutt configuration; see [mutt's
43+
your mutt configuration. See [mutt's
4744
manual](http://www.mutt.org/doc/manual/#mailcap) for more on that.
4845

4946
You can also add the following to your `.muttrc` to quickly open the

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.4
1+
0.5

mutt/mutt-qlview

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ error() {
2020
qlview="$(cd "$(dirname "$0")" && pwd)/qlview"
2121
test -f "${qlview}" -a -x "${qlview}" || qlview="$(command -v qlview 2>/dev/null)"
2222

23-
test -n "${qlview}" || error "qlview not found"
24-
(test $# -eq 1 || test $# -eq 2) || usage
25-
2623
file="$1"
2724
test -f "${file}" || error "no file '${file}'"
2825

@@ -40,4 +37,4 @@ else
4037
cp -f "${file}" "${tmpfile}"
4138
fi
4239

43-
nohup "${qlview}" "${tmpfile}" >/dev/null 2>&1 </dev/null &
40+
open qlview:${tmpfile}

0 commit comments

Comments
 (0)