Skip to content

Commit 9e98b7d

Browse files
author
TeaRex-coder
committed
update ui
1 parent 957426c commit 9e98b7d

33 files changed

+3057
-162
lines changed

ui/README.md

Lines changed: 16 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,40 @@
11
# User Interface
22

3-
HardwareDDC's goal is to provide and easy and convenient way to adjust monitor settings. Therefore, I prioritized an efficient macro-based UX and have not yet released a first-party GUI.
4-
5-
Currently, HardwareDDC is controlled with hotkeys sending API requests.
3+
HardwareDDC's goal is to provide and easy and convenient way to adjust monitor settings. Currently, HardwareDDC is controlled through an efficient macro-based UI.
64

75
## macOS
86

9-
### Lunar
10-
11-
Lunar, _the defacto app for controlling monitors_, can be used as HardwareDDC's interface instead of Hammerspoon for those preferring a GUI.
7+
Lunar, _the defacto app for controlling monitors_, is used as HardwareDDC's macOS GUI.
128

139
1. Install [Lunar](https://static.lunar.fyi/releases/Lunar.dmg)
1410
2. Disable all controls aside from _Network (Raspberry Pi)_
1511
3. Reset _Network Control_
1612

17-
### Hammerspoon
18-
19-
1. Install [Hammerspoon](https://www.hammerspoon.org)
20-
2. Add [hardware-ddc.lua](./macos/hardware-ddc.lua) to your Hammerspoon config `~/.hammerspoon/init.lua`
21-
22-
```lua
23-
local env = require("hardware-ddc")
24-
```
25-
26-
### Hotkeys
27-
28-
_Edit macros in [hardware-ddc.lua](./macos/hardware-ddc.lua)_
29-
30-
**Brightness:**
31-
32-
- ^⌘5 = 0%
33-
- ^⌘1 = 25%
34-
- ^⌘2 = 50%
35-
- ^⌘3 = 75%
36-
- ^⌘4 = 100%
37-
38-
<p></p>
39-
40-
- fn + F1 = -6%
41-
- fn + F2 = +6%
42-
43-
**Input Source:**
44-
45-
- ^⌘h1 HDMI 1
46-
- ^⌘h2 HDMI 2
47-
- ^⌘d1 DisplayPort 1
48-
- ^⌘d2 DisplayPort 2
49-
5013
## Windows
5114

52-
1. Install [AutoHotkey](https://www.autohotkey.com)
53-
2. Create [hardware-ddc.ahk](./windows/hardware-ddc.ahk) shortcut to run at startup in `%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup`
15+
1. Install [hardwareddc-amd64-installer.exe](https://github.com/TeaRex-coder/hardwareddc/releases) from the latest GitHub release
5416

5517
### Hotkeys
5618

57-
_Edit macros in [hardware-ddc.ahk](./windows/hardware-ddc.ahk)_
19+
_User-modifiable hotkeys to come_
5820

5921
**Brightness:**
6022

61-
- ^⌥1 = 25%
62-
- ^⌥2 = 50%
63-
- ^⌥3 = 75%
64-
- ^⌥4 = 100%
65-
- ^⌥5 = 0%
23+
- ⌥⇧- = +10%
24+
- ⌥⇧= = +10%
25+
26+
- ⌥⇧1 = 25%
27+
- ⌥⇧2 = 50%
28+
- ⌥⇧3 = 75%
29+
- ⌥⇧4 = 100%
30+
- ⌥⇧5 = 0%
6631

6732
**Input Source:**
6833

69-
- ^⌥h1 HDMI 1
70-
- ^⌥h2 HDMI 2
71-
- ^⌥d1 DisplayPort 1
72-
- ^⌥d2 DisplayPort 2
34+
- ⌥⇧d1 = DisplayPort 1
35+
- ⌥⇧d2 = DisplayPort 2
36+
- ⌥⇧h1 = HDMI 1
37+
- ⌥⇧h2 = HDMI 2
7338

7439
## Linux
7540

ui/macos/hardware-ddc.lua

Lines changed: 0 additions & 85 deletions
This file was deleted.

ui/windows/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# README
2+
3+
## About
4+
5+
This is the official Wails React template.
6+
7+
You can configure the project by editing `wails.json`. More information about the project settings can be found
8+
here: https://wails.io/docs/reference/project-config
9+
10+
## Live Development
11+
12+
To run in live development mode, run `wails dev` in the project directory. This will run a Vite development
13+
server that will provide very fast hot reload of your frontend changes. If you want to develop in a browser
14+
and have access to your Go methods, there is also a dev server that runs on http://localhost:34115. Connect
15+
to this in your browser, and you can call your Go code from devtools.
16+
17+
## Building
18+
19+
To build a redistributable, production mode package, use `wails build`.

ui/windows/app.go

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"io"
7+
"net/http"
8+
"strconv"
9+
10+
hook "github.com/robotn/gohook"
11+
)
12+
13+
type App struct {
14+
ctx context.Context
15+
}
16+
17+
func NewApp() *App {
18+
return &App{}
19+
}
20+
21+
func (a *App) startup(ctx context.Context) {
22+
a.ctx = ctx
23+
go a.startKeyListener()
24+
}
25+
26+
func (a *App) startKeyListener() {
27+
// Brightness
28+
hook.Register(hook.KeyDown, []string{"alt", "shift", "1"}, func(e hook.Event) {
29+
a.setBrightness(25)
30+
})
31+
32+
hook.Register(hook.KeyDown, []string{"alt", "shift", "2"}, func(e hook.Event) {
33+
a.setBrightness(50)
34+
})
35+
36+
hook.Register(hook.KeyDown, []string{"alt", "shift", "3"}, func(e hook.Event) {
37+
a.setBrightness(75)
38+
})
39+
40+
hook.Register(hook.KeyDown, []string{"alt", "shift", "4"}, func(e hook.Event) {
41+
a.setBrightness(100)
42+
})
43+
44+
hook.Register(hook.KeyDown, []string{"alt", "shift", "5"}, func(e hook.Event) {
45+
a.setBrightness(0)
46+
})
47+
48+
hook.Register(hook.KeyDown, []string{"alt", "shift", "-"}, func(e hook.Event) {
49+
currentBrightness := a.getBrightness()
50+
newBrightness := currentBrightness - 10
51+
if newBrightness < 0 {
52+
newBrightness = 0
53+
}
54+
a.setBrightness(newBrightness)
55+
})
56+
57+
hook.Register(hook.KeyDown, []string{"alt", "shift", "="}, func(e hook.Event) {
58+
currentBrightness := a.getBrightness()
59+
newBrightness := currentBrightness + 10
60+
if newBrightness > 100 {
61+
newBrightness = 100
62+
}
63+
a.setBrightness(newBrightness)
64+
})
65+
66+
// Input sources
67+
hook.Register(hook.KeyDown, []string{"alt", "shift", "d", "1"}, func(e hook.Event) {
68+
a.setSource("0x0f")
69+
})
70+
71+
hook.Register(hook.KeyDown, []string{"alt", "shift", "d", "2"}, func(e hook.Event) {
72+
a.setSource("0x10")
73+
})
74+
75+
hook.Register(hook.KeyDown, []string{"alt", "shift", "h", "1"}, func(e hook.Event) {
76+
a.setSource("0x11")
77+
})
78+
79+
hook.Register(hook.KeyDown, []string{"alt", "shift", "h", "2"}, func(e hook.Event) {
80+
a.setSource("0x12")
81+
})
82+
83+
s := hook.Start()
84+
for range hook.Process(s) {
85+
}
86+
}
87+
88+
func (a *App) setBrightness(level int) {
89+
url := fmt.Sprintf("http://ddcutil.local:3485/1/brightness/%d", level)
90+
http.Get(url)
91+
}
92+
93+
func (a *App) getBrightness() int {
94+
resp, _ := http.Get("http://ddcutil.local:3485/1/brightness")
95+
body, _ := io.ReadAll(resp.Body)
96+
brightness, _ := strconv.Atoi(string(body))
97+
return brightness
98+
}
99+
100+
func (a *App) setSource(source string) {
101+
url := fmt.Sprintf("http://ddcutil.local:3485/1/input_source/%s", source)
102+
http.Get(url)
103+
}

ui/windows/build/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Build Directory
2+
3+
The build directory is used to house all the build files and assets for your application.
4+
5+
The structure is:
6+
7+
* bin - Output directory
8+
* darwin - macOS specific files
9+
* windows - Windows specific files
10+
11+
## Mac
12+
13+
The `darwin` directory holds files specific to Mac builds.
14+
These may be customised and used as part of the build. To return these files to the default state, simply delete them
15+
and
16+
build with `wails build`.
17+
18+
The directory contains the following files:
19+
20+
- `Info.plist` - the main plist file used for Mac builds. It is used when building using `wails build`.
21+
- `Info.dev.plist` - same as the main plist file but used when building using `wails dev`.
22+
23+
## Windows
24+
25+
The `windows` directory contains the manifest and rc files used when building with `wails build`.
26+
These may be customised for your application. To return these files to the default state, simply delete them and
27+
build with `wails build`.
28+
29+
- `icon.ico` - The icon used for the application. This is used when building using `wails build`. If you wish to
30+
use a different icon, simply replace this file with your own. If it is missing, a new `icon.ico` file
31+
will be created using the `appicon.png` file in the build directory.
32+
- `installer/*` - The files used to create the Windows installer. These are used when building using `wails build`.
33+
- `info.json` - Application details used for Windows builds. The data here will be used by the Windows installer,
34+
as well as the application itself (right click the exe -> properties -> details)
35+
- `wails.exe.manifest` - The main application manifest file.

ui/windows/build/appicon.png

130 KB
Loading

0 commit comments

Comments
 (0)