Skip to content

Commit 75ab576

Browse files
committed
feat: streamlines config, removes shadow from window
1 parent ca42a68 commit 75ab576

File tree

3 files changed

+30
-49
lines changed

3 files changed

+30
-49
lines changed

camera/camera.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,12 @@ const video = document.querySelector('#preview');
55

66
ipcRenderer.on('data', (_, {
77
videoDeviceName,
8-
hoverOpacity,
98
borderRadius
109
}) => {
1110
const css = `
1211
video {
1312
border-radius: ${borderRadius};
1413
}
15-
16-
video:hover {
17-
opacity: ${hoverOpacity};
18-
}
1914
`;
2015

2116
const style = document.createElement('style');

index.js

Lines changed: 24 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -20,45 +20,27 @@ try {
2020
} catch { }
2121

2222
const config = {
23-
deviceName: {
23+
device: {
2424
title: 'Device',
25-
description: 'Which device to display.',
25+
description: 'Select a camera to display.',
2626
enum: devices,
2727
required: true,
2828
default: 'Default'
2929
},
30-
borderRadius: {
31-
title: 'Border Radius',
32-
description: 'Any valid `border-radius` value, like `10px` or `50%`.',
33-
type: 'string',
30+
rounded: {
31+
title: 'Corners',
32+
description: 'Corners of your camera overlay.',
33+
enum: ['Circle', 'Rounded', 'Square'],
3434
required: true,
35-
default: '50%'
35+
default: 'Circle'
3636
},
37-
hoverOpacity: {
38-
title: 'Hover Opacity',
39-
description: 'Opacity of the window on when moused over.',
40-
type: 'number',
41-
minimum: 0,
42-
maximum: 1,
43-
default: 0.6,
44-
required: true
45-
},
46-
width: {
47-
title: 'Width',
48-
description: 'Width of the window.',
49-
type: 'number',
50-
minimum: 0,
51-
default: 128,
52-
required: true
37+
size: {
38+
title: 'Size',
39+
description: 'How large should the preview be?',
40+
enum: ['Small', 'Medium', 'Large'],
41+
required: true,
42+
default: 'Medium'
5343
},
54-
height: {
55-
title: 'Height',
56-
description: 'Height of the window.',
57-
type: 'number',
58-
minimum: 0,
59-
default: 128,
60-
required: true
61-
}
6244
};
6345

6446
const getBounds = (cropArea, screenBounds, { width, height }) => {
@@ -80,21 +62,25 @@ const willStartRecording = async ({ state, config, apertureOptions: { screenId,
8062
const screens = screen.getAllDisplays();
8163
const { bounds } = screens.find(s => s.id === screenId) || {};
8264

65+
const size = config.get('size') === "Small" ? 180 : config.get('size') === "Medium" ? 300 : 500
66+
8367
const position = getBounds(cropArea, bounds, {
84-
width: config.get('width'),
85-
height: config.get('height')
68+
width: size,
69+
height: size
8670
});
8771

8872
state.window = new BrowserWindow({
8973
...position,
9074
closable: false,
9175
minimizable: false,
9276
maximizable: false,
77+
fullscreenable: false,
9378
alwaysOnTop: true,
9479
frame: false,
9580
transparent: true,
9681
visualEffectState: 'inactive',
9782
titleBarStyle: 'customButtonsOnHover',
83+
hasShadow: false,
9884
webPreferences: {
9985
nodeIntegration: true,
10086
contextIsolation: false,
@@ -108,9 +94,8 @@ const willStartRecording = async ({ state, config, apertureOptions: { screenId,
10894

10995
state.window.webContents.on('did-finish-load', () => {
11096
state.window.webContents.send('data', {
111-
videoDeviceName: config.get('deviceName'),
112-
hoverOpacity: config.get('hoverOpacity'),
113-
borderRadius: config.get('borderRadius')
97+
videoDeviceName: config.get('device'),
98+
borderRadius: config.get('rounded') === "Circle" ? "50%" : config.get("rounded") === "Rounded" ? "16px" : "0px"
11499
});
115100
});
116101

@@ -126,12 +111,7 @@ const didStopRecording = ({ state }) => {
126111
}
127112
};
128113

129-
const configDescription =
130-
`Create a window showing the selected camera on the bottom-left corner of the recording.
131-
The window is click-through and its hover opacity and size can be adjusted.
132-
133-
To move the window, hold Command before you hover over it, then click and drag it anywhere on the screen.
134-
`;
114+
const configDescription = `Create a window showing the selected camera on your recording`;
135115

136116
const openSystemPreferences = path => shell.openExternal(`x-apple.systempreferences:com.apple.preference.security?${path}`);
137117

@@ -154,8 +134,8 @@ const ensureCameraPermission = async () => {
154134
type: 'warning',
155135
buttons: ['Open System Preferences', 'Cancel'],
156136
defaultId: 0,
157-
message: 'kap-camera cannot access the camera.',
158-
detail: 'kap-camera requires camera access to be able to show the contents of the webcam. You can grant this in the System Preferences. Afterwards, launch Kap for the changes to take effect.',
137+
message: 'kap-cam cannot access the camera.',
138+
detail: 'kap-cam needs camera access to work correctly. You can grant this in the System Preferences. Relaunch Kap for the changes to take effect.',
159139
cancelId: 1
160140
});
161141

readme.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,9 @@ This plugin creates an overlay window showing the selected camera on the bottom-
2121
## Misc
2222

2323
This is based off of [kap-camera](https://github.com/karaggeorge/kap-camera/) by [@karaggeorge's](https://github.com/karaggeorge). I wanted a more Loom-like flavour to the UI of this plugin and decided to fork my own.
24+
25+
### TODOs
26+
27+
- [x] remove active window frame on macOS
28+
- [x] consolidate camera shape and size options
29+
- [ ] show camera even when recording is not started (?)

0 commit comments

Comments
 (0)