Skip to content

Commit

Permalink
fix: add missing dependency to libgl1 (#1)
Browse files Browse the repository at this point in the history
* fix: add missing dependency to libgl1

* ci: run tests and lint on pull-requests

* chore: remove unnecessary print

* docs: add screenshot and update README.md

* chore: add same ldflags to local build as used in CI/CD
  • Loading branch information
Strobotti authored Feb 22, 2024
1 parent f67918f commit ca8b16b
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 24 deletions.
File renamed without changes.
38 changes: 31 additions & 7 deletions .github/workflows/golangci-lint.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
name: golangci-lint
on:
push:
branches:
- master
- main
pull_request:

permissions:
Expand All @@ -21,10 +17,9 @@ jobs:
sudo apt-get update
sudo apt-get install -y gcc libgl1-mesa-dev xorg-dev
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: '1.21'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
Expand Down Expand Up @@ -57,4 +52,33 @@ jobs:
# skip-build-cache: true

# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
# install-mode: "goinstall"
# install-mode: "goinstall"

test:
name: test
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: '1.21'

- name: Install some build dependencies
run: |
sudo apt-get update
sudo apt-get install -y gcc libgl1-mesa-dev xorg-dev
curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
- name: Install Task
uses: arduino/setup-task@v2
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Run Tests
run: task test
2 changes: 2 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ nfpms:
- rpm
bindir: /usr/bin
priority: optional
dependencies:
- libgl1
contents:
- src: package/linux
dst: /
Expand Down
47 changes: 44 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,50 @@
<img style="float: left; margin-right: 10px" src="Icon.png" width="142" height="142" alt="Linkquisition" />

# Linkquisition

...nobody expects the Linkquisition!
Linkquisition is a fast, configurable browser-picker for Linux desktop written in Go.

...as nobody expects the Linkquisition!

![screenshot](screenshot.png)

## What is it?

Motivation behind this project is:
1. I needed a fast browser-picker for Linux desktop that is configurable to automatically choose a browser based on different rules
2. I have written a lot of server-side code in Go and wanted to see how easy it is to write a desktop app in Go

## Features

- Fast
- Configurable
- Automatically chooses a browser based on different rules
- domain (e.g. `example.com`)
- site (e.g. `www.example.com`)
- regular expression (e.g. `.*\.example\.com`)
- Hide a browser from the list
- Manually add a browser to the list (for example, to open a URL in a different profile)
- keyboard-shortcuts
- `Enter` to open the URL in the default browser
- `Ctrl+C` to just copy the URL to clipboard and close the window
- Number keys (1-9) to select a browser

## Development

I am using Ubuntu Linux for development, so the instructions are tailored for that. However, the code should work on any
Freedesktop.org-compliant Linux distribution, although I have not tested it. Also, I have limited the architecture to
amd64, as I do not have time/access to other architectures for testing easily.

### Requirements

- Go 1.21 (https://go.dev/doc/install)
- Taskfile (https://taskfile.dev/#/installation)
- Build-dependencies:
```shell
sudo apt-get update && sudo apt-get install -y gcc libgl1-mesa-dev xorg-dev
```


### Building
### Building locally

The following command will build a binary in the `bin` directory:

Expand All @@ -28,3 +57,15 @@ To run in watch mode:
```bash
task build --watch # results in bin/linkquisition-linux-amd64 (rebuilds on any relevant file change)
```

### Packaging locally

Packaging locally is for testing purposes only, actual packaging should be done in a CI/CD pipeline,
which currently is Github.com Actions.

The following command will build a `.deb` package in the `dist` directory:

```bash
# export VERSION=0.1.0-dev # optional, if not set, defaults to 0.0.0
task package:deb # results in dist/linkquisition_0.0.0_amd64.deb
```
2 changes: 1 addition & 1 deletion Taskfile.build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tasks:
sh: echo ${VERSION:-v0.0.0}
OPTIONS: '{{default "" .DEVOPTIONS}}'
cmds:
- CGO_ENABLED=1 GOOS={{.TARGET}} go build -tags release -ldflags '-X main.version={{.VERSION}} -X main.BuildTimestamp={{now | unixEpoch}}' {{.OPTIONS}} -o bin/{{.OUTPUT}}{{exeExt}} cmd/*.go
- CGO_ENABLED=1 GOOS={{.TARGET}} go build -tags release -ldflags '-s -w -X main.version={{.VERSION}} -X main.BuildTimestamp={{now | unixEpoch}}' {{.OPTIONS}} -o bin/{{.OUTPUT}}{{exeExt}} cmd/*.go
- echo "bin/{{.OUTPUT}}{{exeExt}} created successfully"
sources:
- ./**/*.go
Expand Down
24 changes: 14 additions & 10 deletions Taskfile.package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,25 @@ vars:
sh: echo ${VERSION:-0.0.0}

tasks:
clean:
cmds:
- rm -rfv dist package

linux:
cmds:
- mkdir -p package/linux/usr/share/applications package/linux/usr/share/pixmaps
- cp Icon.png package/linux/usr/share/pixmaps/linkquisition.png
- cp templates/linkquisition.desktop package/linux/usr/share/applications/linkquisition.desktop

debian-amd64:
deb:
description: "Builds a Debian package for local testing"
cmds:
- task build:linux-amd64
- task build
- task package:linux
- mkdir -p dist
- mkdir -p package/debian-amd64/usr/bin package/debian-amd64/DEBIAN package/debian-amd64/usr/share/applications package/debian-amd64/usr/share/pixmaps
- cp bin/linkquisition-linux-amd64 package/debian-amd64/usr/bin/linkquisition
- cp templates/DEBIAN/control.tpl package/debian-amd64/DEBIAN/control
- cp templates/linkquisition.desktop package/debian-amd64/usr/share/applications/linkquisition.desktop
- cp Icon.png package/debian-amd64/usr/share/pixmaps/linkquisition.png
- sed -i 's/{{ "{{" }}VERSION{{ "}}" }}/{{.VERSION}}/g' package/debian-amd64/DEBIAN/control
- sed -i 's/{{ "{{" }}ARCH{{ "}}" }}/amd64/g' package/debian-amd64/DEBIAN/control
- dpkg-deb --build package/debian-amd64 dist/linkquisition-amd64.deb
- mkdir -p package/linux/DEBIAN package/linux/usr/bin
- cp bin/linkquisition-linux-amd64 package/linux/usr/bin/linkquisition
- cp templates/DEBIAN/control.tpl package/linux/DEBIAN/control
- sed -i 's/{{ "{{" }}VERSION{{ "}}" }}/{{.VERSION}}/g' package/linux/DEBIAN/control
- sed -i 's/{{ "{{" }}ARCH{{ "}}" }}/amd64/g' package/linux/DEBIAN/control
- dpkg-deb --build package/linux dist/linkquisition_{{.VERSION}}_linux_amd64.deb
1 change: 0 additions & 1 deletion cmd/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ func (a *Application) Run(_ context.Context) error {
}
}
browsers = a.SettingsService.GetSettings().GetSelectableBrowsers()
fmt.Printf("found %d browsers configured to be selected\n", len(browsers))
} else if browsers, err = a.BrowserService.GetAvailableBrowsers(); err != nil {
return err
} else {
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
module github.com/strobotti/linkquisition

go 1.21.6
go 1.21

require (
fyne.io/fyne/v2 v2.4.3
github.com/stretchr/testify v1.8.4
golang.org/x/net v0.17.0
gopkg.in/alessio/shellescape.v1 v1.0.0-20170105083845-52074bc9df61
gopkg.in/ini.v1 v1.67.0
)
Expand Down Expand Up @@ -32,7 +33,6 @@ require (
github.com/yuin/goldmark v1.5.5 // indirect
golang.org/x/image v0.11.0 // indirect
golang.org/x/mobile v0.0.0-20230531173138-3c911d8e3eda // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Binary file added screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions templates/DEBIAN/control.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ Maintainer: Juha Jantunen <[email protected]>
Architecture: {{ARCH}}
Priority: optional
Description: Linkquisition is a browser-picker tool for opening links in a specific browser.
Depends: libgl1

0 comments on commit ca8b16b

Please sign in to comment.