Added configurable scaling priorities in options. (#277)
This commit is contained in:
2
lib/types/options.d.ts
vendored
2
lib/types/options.d.ts
vendored
@@ -213,3 +213,5 @@ type MatugenTheme = 'light' | 'dark';
|
|||||||
|
|
||||||
export type ColorMapKey = keyof typeof defaultColorMap;
|
export type ColorMapKey = keyof typeof defaultColorMap;
|
||||||
export type ColorMapValue = (typeof defaultColorMap)[ColorMapKey];
|
export type ColorMapValue = (typeof defaultColorMap)[ColorMapKey];
|
||||||
|
|
||||||
|
export type ScalingPriority = 'gdk' | 'hyprland' | 'both';
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
const hyprland = await Service.import('hyprland');
|
const hyprland = await Service.import('hyprland');
|
||||||
|
|
||||||
|
import options from 'options';
|
||||||
import { bash } from 'lib/utils';
|
import { bash } from 'lib/utils';
|
||||||
import { Widget as TWidget } from 'types/@girs/gtk-3.0/gtk-3.0.cjs';
|
import { Widget as TWidget } from 'types/@girs/gtk-3.0/gtk-3.0.cjs';
|
||||||
import { Monitor } from 'types/service/hyprland';
|
import { Monitor } from 'types/service/hyprland';
|
||||||
@@ -12,6 +13,7 @@ type NestedBox = Box<NestedRevealer, unknown>;
|
|||||||
type NestedEventBox = EventBox<NestedBox, unknown>;
|
type NestedEventBox = EventBox<NestedBox, unknown>;
|
||||||
|
|
||||||
const { location } = options.theme.bar;
|
const { location } = options.theme.bar;
|
||||||
|
const { scalingPriority } = options;
|
||||||
|
|
||||||
export const moveBoxToCursor = <T extends NestedEventBox>(self: T, fixed: boolean): void => {
|
export const moveBoxToCursor = <T extends NestedEventBox>(self: T, fixed: boolean): void => {
|
||||||
if (fixed) {
|
if (fixed) {
|
||||||
@@ -49,7 +51,14 @@ export const moveBoxToCursor = <T extends NestedEventBox>(self: T, fixed: boolea
|
|||||||
// end of the monitor is the 1430th pixel.
|
// end of the monitor is the 1430th pixel.
|
||||||
const gdkScale = Utils.exec('bash -c "echo $GDK_SCALE"');
|
const gdkScale = Utils.exec('bash -c "echo $GDK_SCALE"');
|
||||||
|
|
||||||
if (/^\d+(.\d+)?$/.test(gdkScale)) {
|
if (scalingPriority.value === 'both') {
|
||||||
|
const scale = parseFloat(gdkScale);
|
||||||
|
monWidth = monWidth / scale;
|
||||||
|
monHeight = monHeight / scale;
|
||||||
|
|
||||||
|
monWidth = monWidth / hyprScaling;
|
||||||
|
monHeight = monHeight / hyprScaling;
|
||||||
|
} else if (/^\d+(.\d+)?$/.test(gdkScale) && scalingPriority.value === 'gdk') {
|
||||||
const scale = parseFloat(gdkScale);
|
const scale = parseFloat(gdkScale);
|
||||||
monWidth = monWidth / scale;
|
monWidth = monWidth / scale;
|
||||||
monHeight = monHeight / scale;
|
monHeight = monHeight / scale;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import {
|
|||||||
NotificationAnchor,
|
NotificationAnchor,
|
||||||
OSDAnchor,
|
OSDAnchor,
|
||||||
OSDOrientation,
|
OSDOrientation,
|
||||||
|
ScalingPriority,
|
||||||
WindowLayer,
|
WindowLayer,
|
||||||
} from 'lib/types/options';
|
} from 'lib/types/options';
|
||||||
import { MatugenScheme, MatugenTheme, MatugenVariations } from 'lib/types/options';
|
import { MatugenScheme, MatugenTheme, MatugenVariations } from 'lib/types/options';
|
||||||
@@ -1053,6 +1054,8 @@ const options = mkOptions(OPTIONS, {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
scalingPriority: opt<ScalingPriority>('gdk'),
|
||||||
|
|
||||||
terminal: opt('kitty'),
|
terminal: opt('kitty'),
|
||||||
|
|
||||||
tear: opt(false),
|
tear: opt(false),
|
||||||
|
|||||||
@@ -50,6 +50,12 @@ export const BarGeneral = (): Scrollable<Child, Attribute> => {
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
Header('Scaling'),
|
Header('Scaling'),
|
||||||
|
Option({
|
||||||
|
opt: options.scalingPriority,
|
||||||
|
title: 'Scaling Priority',
|
||||||
|
type: 'enum',
|
||||||
|
enums: ['both', 'gdk', 'hyprland'],
|
||||||
|
}),
|
||||||
Option({
|
Option({
|
||||||
opt: options.theme.bar.scaling,
|
opt: options.theme.bar.scaling,
|
||||||
title: 'Bar',
|
title: 'Bar',
|
||||||
|
|||||||
Reference in New Issue
Block a user