Skip to content

Commit b2e6e2e

Browse files
initial commit
0 parents  commit b2e6e2e

File tree

12 files changed

+868
-0
lines changed

12 files changed

+868
-0
lines changed

.github/workflows/build.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- '**' # Run on all branch pushes
7+
pull_request:
8+
branches:
9+
- '**' # Run on all pull requests
10+
11+
env:
12+
GO_VERSION: '1.24'
13+
APP_NAME: 'touch-block'
14+
15+
jobs:
16+
build:
17+
name: Build for ${{ matrix.os }}-${{ matrix.arch }}
18+
runs-on: ubuntu-latest
19+
strategy:
20+
fail-fast: true # Stop all builds if one fails
21+
matrix:
22+
include:
23+
- os: linux
24+
arch: amd64
25+
output-name: linux-x64
26+
- os: linux
27+
arch: '386'
28+
output-name: linux-x86
29+
- os: linux
30+
arch: arm64
31+
output-name: linux-arm64
32+
- os: linux
33+
arch: arm
34+
arm-version: '7' # ARMv7 for 32-bit ARM
35+
output-name: linux-arm32
36+
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@v4
40+
41+
- name: Set up Go
42+
uses: actions/setup-go@v5
43+
with:
44+
go-version: ${{ env.GO_VERSION }}
45+
46+
- name: Cache Go modules
47+
uses: actions/cache@v4
48+
with:
49+
path: |
50+
~/.cache/go-build
51+
~/go/pkg/mod
52+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
53+
restore-keys: |
54+
${{ runner.os }}-go-
55+
56+
- name: Download dependencies
57+
run: go mod download
58+
59+
- name: Build binary
60+
env:
61+
GOOS: ${{ matrix.os }}
62+
GOARCH: ${{ matrix.arch }}
63+
GOARM: ${{ matrix.arm-version }}
64+
run: |
65+
# Build the binary with optimizations
66+
go build -v -ldflags="-s -w -X main.version=${{ github.ref_name }}" \
67+
-o ${{ env.APP_NAME }}-${{ matrix.output-name }} .
68+
69+
# Make it executable
70+
chmod +x ${{ env.APP_NAME }}-${{ matrix.output-name }}
71+
72+
# Show file info for verification
73+
ls -lh ${{ env.APP_NAME }}-${{ matrix.output-name }}
74+
file ${{ env.APP_NAME }}-${{ matrix.output-name }}
75+
76+
- name: Upload build artifact
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: ${{ env.APP_NAME }}-${{ matrix.output-name }}
80+
path: ${{ env.APP_NAME }}-${{ matrix.output-name }}
81+
retention-days: 90

.github/workflows/release.yml

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'release-v*.*.*'
7+
8+
env:
9+
GO_VERSION: '1.24'
10+
APP_NAME: 'touch-block'
11+
12+
jobs:
13+
build:
14+
name: Build for ${{ matrix.os }}-${{ matrix.arch }}
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: true # Stop all builds if one fails
18+
matrix:
19+
include:
20+
- os: linux
21+
arch: amd64
22+
output-name: linux-x64
23+
- os: linux
24+
arch: '386'
25+
output-name: linux-x86
26+
- os: linux
27+
arch: arm64
28+
output-name: linux-arm64
29+
- os: linux
30+
arch: arm
31+
arm-version: '7' # ARMv7 for 32-bit ARM
32+
output-name: linux-arm32
33+
34+
steps:
35+
- name: Checkout code
36+
uses: actions/checkout@v4
37+
38+
- name: Set up Go
39+
uses: actions/setup-go@v5
40+
with:
41+
go-version: ${{ env.GO_VERSION }}
42+
43+
- name: Cache Go modules
44+
uses: actions/cache@v4
45+
with:
46+
path: |
47+
~/.cache/go-build
48+
~/go/pkg/mod
49+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
50+
restore-keys: |
51+
${{ runner.os }}-go-
52+
53+
- name: Download dependencies
54+
run: go mod download
55+
56+
- name: Build binary
57+
env:
58+
GOOS: ${{ matrix.os }}
59+
GOARCH: ${{ matrix.arch }}
60+
GOARM: ${{ matrix.arm-version }}
61+
run: |
62+
# Build the binary with optimizations
63+
go build -v -ldflags="-s -w -X main.version=${{ github.ref_name }}" \
64+
-o ${{ env.APP_NAME }}-${{ matrix.output-name }} .
65+
66+
# Make it executable
67+
chmod +x ${{ env.APP_NAME }}-${{ matrix.output-name }}
68+
69+
# Show file info for verification
70+
ls -lh ${{ env.APP_NAME }}-${{ matrix.output-name }}
71+
file ${{ env.APP_NAME }}-${{ matrix.output-name }}
72+
73+
- name: Upload build artifact
74+
uses: actions/upload-artifact@v4
75+
with:
76+
name: ${{ env.APP_NAME }}-${{ matrix.output-name }}
77+
path: ${{ env.APP_NAME }}-${{ matrix.output-name }}
78+
retention-days: 1 # Short retention for release builds
79+
80+
release:
81+
name: Create Release
82+
needs: build # Only run if all builds succeed
83+
runs-on: ubuntu-latest
84+
permissions:
85+
contents: write # Required for creating releases
86+
87+
steps:
88+
- name: Checkout code
89+
uses: actions/checkout@v4
90+
91+
- name: Download all artifacts
92+
uses: actions/download-artifact@v4
93+
with:
94+
path: artifacts
95+
96+
- name: Prepare release assets
97+
run: |
98+
mkdir -p release-assets
99+
100+
# Move all binaries to release-assets
101+
for dir in artifacts/*; do
102+
if [ -d "$dir" ]; then
103+
mv "$dir"/* release-assets/
104+
fi
105+
done
106+
107+
# Create checksums
108+
cd release-assets
109+
sha256sum * > checksums.txt
110+
111+
# List all assets for verification
112+
ls -la
113+
114+
- name: Extract version from tag
115+
id: version
116+
run: |
117+
VERSION=${GITHUB_REF_NAME#release-}
118+
echo "version=$VERSION" >> $GITHUB_OUTPUT
119+
echo "Version: $VERSION"
120+
121+
- name: Generate release notes
122+
id: release_notes
123+
run: |
124+
cat << EOF > release_notes.md
125+
## Release ${{ steps.version.outputs.version }}
126+
127+
### 📦 Available Binaries
128+
129+
| Platform | Architecture | Binary |
130+
|----------|-------------|--------|
131+
| Linux | x64 (amd64) | \`${{ env.APP_NAME }}-linux-x64\` |
132+
| Linux | x86 (386) | \`${{ env.APP_NAME }}-linux-x86\` |
133+
| Linux | ARM64 | \`${{ env.APP_NAME }}-linux-arm64\` |
134+
| Linux | ARM32 (ARMv7) | \`${{ env.APP_NAME }}-linux-arm32\` |
135+
136+
### 📝 Checksums
137+
138+
SHA256 checksums are available in \`checksums.txt\`
139+
140+
### 💻 Usage
141+
142+
Download the appropriate binary for your architecture and make it executable:
143+
144+
\`\`\`bash
145+
chmod +x ${{ env.APP_NAME }}-linux-*
146+
./${{ env.APP_NAME }}-linux-*
147+
\`\`\`
148+
149+
### 🚀 What's Changed
150+
151+
<!-- Auto-generated notes will be added below -->
152+
EOF
153+
154+
- name: Create GitHub Release
155+
uses: softprops/action-gh-release@v2
156+
with:
157+
name: ${{ steps.version.outputs.version }}
158+
tag_name: ${{ github.ref_name }}
159+
body_path: release_notes.md
160+
draft: false
161+
prerelease: false
162+
generate_release_notes: true # Append auto-generated notes
163+
files: |
164+
release-assets/${{ env.APP_NAME }}-linux-x64
165+
release-assets/${{ env.APP_NAME }}-linux-x86
166+
release-assets/${{ env.APP_NAME }}-linux-arm64
167+
release-assets/${{ env.APP_NAME }}-linux-arm32
168+
release-assets/checksums.txt
169+
fail_on_unmatched_files: true
170+
171+
- name: Cleanup artifacts
172+
uses: geekyeggo/delete-artifact@v5
173+
if: always()
174+
with:
175+
name: |
176+
${{ env.APP_NAME }}-linux-x64
177+
${{ env.APP_NAME }}-linux-x86
178+
${{ env.APP_NAME }}-linux-arm64
179+
${{ env.APP_NAME }}-linux-arm32

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea
2+
touch-block

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 features-not-bugs
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Touch-Block
2+
An application created to prevent touch input on my wall mounted home assistant kiosks when the display is asleep. This became an issue as the displays I use take approx 2 seconds to wake up and during that time the user could be tapping on switches without realising.
3+
4+
## Usage
5+
By default, this application will poll the DPMS extension in x11 every 50ms to check if the display is awake or asleep, on a transition it will then show a full screen X11 window overlay that will prevent all touch input (right now this also captures any form of cursor input rather than just touch).
6+
7+
`--dpms=false` Switches to using xrandr as the source for testing whether the display is on or off, although it's a mess and I have no idea if it even works correctly...
8+
9+
`--delay=<TIME_IN_MS>` Adds an additional delay in milliseconds before removing the touch blocking, tweak this to your display, each display has a different amount of time it takes to wake up.
10+
11+
`--dpms-poll=<TIME_IN_MS>` Changes the interval in milliseconds between each check of DPMS to test whether the display is on or off, has no effect if xrandr is being used.
12+
13+
```
14+
touch-block --dpms=true --delay=500 --dpms-poll=50
15+
```

0 commit comments

Comments
 (0)