Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Individual display adjustment #152

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "display-dj",
"private": true,
"version": "1.11.6",
"version": "1.11.7",
"description": "A cross platform desktop application that supports brightness adjustment for integrated laptop monitor as well as external monitors and dark mode toggle supporting Windows and MacOSX at the moment.",
"scripts": {
"clean-dist": "rimraf dist",
Expand Down
7 changes: 5 additions & 2 deletions src/renderer/components/MonitorBrightnessSetting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function MonitorBrightnessSetting(props: MonitorBrightnessSettingProps) {
const { monitor } = props;
const { mutateAsync: updateMonitor } = useUpdateMonitor();
const [disabled, setDisabled] = useState(false);
const [brightness, setBrightness] = useState(monitor.brightness);
const isLaptop = monitor.type === 'laptop_monitor';

const onChange = async (brightness: number) => {
Expand All @@ -33,12 +34,14 @@ export function MonitorBrightnessSetting(props: MonitorBrightnessSettingProps) {
};

const onMinAndMaxBrightness = () => {
if (monitor.brightness === 0) {
if (brightness === 0) {
// maximize brightness
onChange(100);
setBrightness(100);
} else {
// minimize brightness
onChange(0);
setBrightness(0);
}
};

Expand All @@ -59,7 +62,7 @@ export function MonitorBrightnessSetting(props: MonitorBrightnessSettingProps) {
<Slider
className='field__value'
placeholder='brightness'
value={monitor.brightness}
value={brightness}
onInput={onChange}
disabled={disabled}
/>
Expand Down
6 changes: 5 additions & 1 deletion src/renderer/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ export function Home(props: HomeProps) {
return (
<>
<Header configs={configs} preference={preference} />
<AllMonitorBrightnessSetting monitors={configs.monitors} />
{preference.showIndividualDisplays ? (
<MonitorBrightnessSettingForm monitors={configs.monitors} />
) : (
<AllMonitorBrightnessSetting monitors={configs.monitors} />
)}
<DarkModeSettingForm darkMode={configs.darkMode} />
</>
);
Expand Down