Added the ability to assign shortcuts to all bar modules. (#278)
This commit is contained in:
@@ -4,9 +4,10 @@ import { openMenu } from '../utils.js';
|
||||
import options from 'options';
|
||||
import { BarBoxChild } from 'lib/types/bar.js';
|
||||
import Button from 'types/widgets/button.js';
|
||||
import { Child } from 'lib/types/widget.js';
|
||||
import { Attribute, Child } from 'lib/types/widget.js';
|
||||
import { runAsyncCommand, throttledScrollHandler } from 'customModules/utils.js';
|
||||
|
||||
const { label: show_label } = options.bar.battery;
|
||||
const { label: show_label, rightClick, middleClick, scrollUp, scrollDown } = options.bar.battery;
|
||||
|
||||
const BatteryLabel = (): BarBoxChild => {
|
||||
const isVis = Variable(battery.available);
|
||||
@@ -92,7 +93,25 @@ const BatteryLabel = (): BarBoxChild => {
|
||||
isVis,
|
||||
boxClass: 'battery',
|
||||
props: {
|
||||
on_primary_click: (clicked: Button<Child, Child>, event: Gdk.Event): void => {
|
||||
setup: (self: Button<Child, Attribute>): void => {
|
||||
self.hook(options.bar.scrollSpeed, () => {
|
||||
const throttledHandler = throttledScrollHandler(options.bar.scrollSpeed.value);
|
||||
|
||||
self.on_secondary_click = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
runAsyncCommand(rightClick.value, { clicked, event });
|
||||
};
|
||||
self.on_middle_click = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
runAsyncCommand(middleClick.value, { clicked, event });
|
||||
};
|
||||
self.on_scroll_up = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
throttledHandler(scrollUp.value, { clicked, event });
|
||||
};
|
||||
self.on_scroll_down = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
throttledHandler(scrollDown.value, { clicked, event });
|
||||
};
|
||||
});
|
||||
},
|
||||
onPrimaryClick: (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
openMenu(clicked, event, 'energymenu');
|
||||
},
|
||||
},
|
||||
|
||||
@@ -4,9 +4,10 @@ import options from 'options';
|
||||
import { openMenu } from '../utils.js';
|
||||
import { BarBoxChild } from 'lib/types/bar.js';
|
||||
import Button from 'types/widgets/button.js';
|
||||
import { Child } from 'lib/types/widget.js';
|
||||
import { Attribute, Child } from 'lib/types/widget.js';
|
||||
import { runAsyncCommand, throttledScrollHandler } from 'customModules/utils.js';
|
||||
|
||||
const { label } = options.bar.bluetooth;
|
||||
const { label, rightClick, middleClick, scrollDown, scrollUp } = options.bar.bluetooth;
|
||||
|
||||
const Bluetooth = (): BarBoxChild => {
|
||||
const btIcon = Widget.Label({
|
||||
@@ -45,7 +46,25 @@ const Bluetooth = (): BarBoxChild => {
|
||||
isVisible: true,
|
||||
boxClass: 'bluetooth',
|
||||
props: {
|
||||
on_primary_click: (clicked: Button<Child, Child>, event: Gdk.Event): void => {
|
||||
setup: (self: Button<Child, Attribute>): void => {
|
||||
self.hook(options.bar.scrollSpeed, () => {
|
||||
const throttledHandler = throttledScrollHandler(options.bar.scrollSpeed.value);
|
||||
|
||||
self.on_secondary_click = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
runAsyncCommand(rightClick.value, { clicked, event });
|
||||
};
|
||||
self.on_middle_click = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
runAsyncCommand(middleClick.value, { clicked, event });
|
||||
};
|
||||
self.on_scroll_up = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
throttledHandler(scrollUp.value, { clicked, event });
|
||||
};
|
||||
self.on_scroll_down = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
throttledHandler(scrollDown.value, { clicked, event });
|
||||
};
|
||||
});
|
||||
},
|
||||
on_primary_click: (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
openMenu(clicked, event, 'bluetoothmenu');
|
||||
},
|
||||
},
|
||||
|
||||
@@ -5,8 +5,10 @@ import options from 'options';
|
||||
import { DateTime } from 'types/@girs/glib-2.0/glib-2.0.cjs';
|
||||
import { BarBoxChild } from 'lib/types/bar.js';
|
||||
import Button from 'types/widgets/button.js';
|
||||
import { Child } from 'lib/types/widget.js';
|
||||
const { format, icon, showIcon, showTime } = options.bar.clock;
|
||||
import { Attribute, Child } from 'lib/types/widget.js';
|
||||
import { runAsyncCommand, throttledScrollHandler } from 'customModules/utils.js';
|
||||
|
||||
const { format, icon, showIcon, showTime, rightClick, middleClick, scrollUp, scrollDown } = options.bar.clock;
|
||||
const { style } = options.theme.bar.buttons;
|
||||
|
||||
const date = Variable(GLib.DateTime.new_now_local(), {
|
||||
@@ -53,7 +55,25 @@ const Clock = (): BarBoxChild => {
|
||||
isVisible: true,
|
||||
boxClass: 'clock',
|
||||
props: {
|
||||
on_primary_click: (clicked: Button<Child, Child>, event: Gdk.Event): void => {
|
||||
setup: (self: Button<Child, Attribute>): void => {
|
||||
self.hook(options.bar.scrollSpeed, () => {
|
||||
const throttledHandler = throttledScrollHandler(options.bar.scrollSpeed.value);
|
||||
|
||||
self.on_secondary_click = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
runAsyncCommand(rightClick.value, { clicked, event });
|
||||
};
|
||||
self.on_middle_click = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
runAsyncCommand(middleClick.value, { clicked, event });
|
||||
};
|
||||
self.on_scroll_up = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
throttledHandler(scrollUp.value, { clicked, event });
|
||||
};
|
||||
self.on_scroll_down = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
throttledHandler(scrollDown.value, { clicked, event });
|
||||
};
|
||||
});
|
||||
},
|
||||
on_primary_click: (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
openMenu(clicked, event, 'calendarmenu');
|
||||
},
|
||||
},
|
||||
|
||||
@@ -5,9 +5,11 @@ import options from 'options';
|
||||
import { getCurrentPlayer } from 'lib/shared/media.js';
|
||||
import { BarBoxChild } from 'lib/types/bar.js';
|
||||
import Button from 'types/widgets/button.js';
|
||||
import { Child } from 'lib/types/widget.js';
|
||||
import { Attribute, Child } from 'lib/types/widget.js';
|
||||
import { runAsyncCommand } from 'customModules/utils.js';
|
||||
|
||||
const { show_artist, truncation, truncation_size, show_label, show_active_only } = options.bar.media;
|
||||
const { show_artist, truncation, truncation_size, show_label, show_active_only, rightClick, middleClick } =
|
||||
options.bar.media;
|
||||
|
||||
const Media = (): BarBoxChild => {
|
||||
const activePlayer = Variable(mpris.players[0]);
|
||||
@@ -92,13 +94,18 @@ const Media = (): BarBoxChild => {
|
||||
}),
|
||||
isVis,
|
||||
boxClass: 'media',
|
||||
name: 'media',
|
||||
props: {
|
||||
on_scroll_up: () => activePlayer.value?.next(),
|
||||
on_scroll_down: () => activePlayer.value?.previous(),
|
||||
on_primary_click: (clicked: Button<Child, Child>, event: Gdk.Event): void => {
|
||||
on_primary_click: (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
openMenu(clicked, event, 'mediamenu');
|
||||
},
|
||||
onSecondaryClick: (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
runAsyncCommand(rightClick.value, { clicked, event });
|
||||
},
|
||||
onMiddleClick: (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
runAsyncCommand(middleClick.value, { clicked, event });
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -3,7 +3,10 @@ import { openMenu } from '../utils.js';
|
||||
import options from 'options';
|
||||
import { BarBoxChild } from 'lib/types/bar.js';
|
||||
import Button from 'types/widgets/button.js';
|
||||
import { Child } from 'lib/types/widget.js';
|
||||
import { Attribute, Child } from 'lib/types/widget.js';
|
||||
import { runAsyncCommand, throttledScrollHandler } from 'customModules/utils.js';
|
||||
|
||||
const { rightClick, middleClick, scrollUp, scrollDown } = options.bar.launcher;
|
||||
|
||||
const Menu = (): BarBoxChild => {
|
||||
return {
|
||||
@@ -25,9 +28,27 @@ const Menu = (): BarBoxChild => {
|
||||
isVisible: true,
|
||||
boxClass: 'dashboard',
|
||||
props: {
|
||||
on_primary_click: (clicked: Button<Child, Child>, event: Gdk.Event): void => {
|
||||
on_primary_click: (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
openMenu(clicked, event, 'dashboardmenu');
|
||||
},
|
||||
setup: (self: Button<Child, Attribute>): void => {
|
||||
self.hook(options.bar.scrollSpeed, () => {
|
||||
const throttledHandler = throttledScrollHandler(options.bar.scrollSpeed.value);
|
||||
|
||||
self.on_secondary_click = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
runAsyncCommand(rightClick.value, { clicked, event });
|
||||
};
|
||||
self.on_middle_click = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
runAsyncCommand(middleClick.value, { clicked, event });
|
||||
};
|
||||
self.on_scroll_up = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
throttledHandler(scrollUp.value, { clicked, event });
|
||||
};
|
||||
self.on_scroll_down = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
throttledHandler(scrollDown.value, { clicked, event });
|
||||
};
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -4,9 +4,18 @@ import options from 'options';
|
||||
import { openMenu } from '../utils.js';
|
||||
import { BarBoxChild } from 'lib/types/bar.js';
|
||||
import Button from 'types/widgets/button.js';
|
||||
import { Child } from 'lib/types/widget.js';
|
||||
import { Attribute, Child } from 'lib/types/widget.js';
|
||||
import { runAsyncCommand, throttledScrollHandler } from 'customModules/utils.js';
|
||||
|
||||
const { label: networkLabel, truncation, truncation_size } = options.bar.network;
|
||||
const {
|
||||
label: networkLabel,
|
||||
truncation,
|
||||
truncation_size,
|
||||
rightClick,
|
||||
middleClick,
|
||||
scrollDown,
|
||||
scrollUp,
|
||||
} = options.bar.network;
|
||||
|
||||
const Network = (): BarBoxChild => {
|
||||
return {
|
||||
@@ -70,9 +79,27 @@ const Network = (): BarBoxChild => {
|
||||
isVisible: true,
|
||||
boxClass: 'network',
|
||||
props: {
|
||||
on_primary_click: (clicked: Button<Child, Child>, event: Gdk.Event): void => {
|
||||
on_primary_click: (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
openMenu(clicked, event, 'networkmenu');
|
||||
},
|
||||
setup: (self: Button<Child, Attribute>): void => {
|
||||
self.hook(options.bar.scrollSpeed, () => {
|
||||
const throttledHandler = throttledScrollHandler(options.bar.scrollSpeed.value);
|
||||
|
||||
self.on_secondary_click = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
runAsyncCommand(rightClick.value, { clicked, event });
|
||||
};
|
||||
self.on_middle_click = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
runAsyncCommand(middleClick.value, { clicked, event });
|
||||
};
|
||||
self.on_scroll_up = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
throttledHandler(scrollUp.value, { clicked, event });
|
||||
};
|
||||
self.on_scroll_down = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
throttledHandler(scrollDown.value, { clicked, event });
|
||||
};
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -4,9 +4,10 @@ import options from 'options';
|
||||
import { filterNotifications } from 'lib/shared/notifications.js';
|
||||
import { BarBoxChild } from 'lib/types/bar.js';
|
||||
import Button from 'types/widgets/button.js';
|
||||
import { Child } from 'lib/types/widget.js';
|
||||
import { Attribute, Child } from 'lib/types/widget.js';
|
||||
import { runAsyncCommand, throttledScrollHandler } from 'customModules/utils.js';
|
||||
|
||||
const { show_total } = options.bar.notifications;
|
||||
const { show_total, rightClick, middleClick, scrollUp, scrollDown } = options.bar.notifications;
|
||||
const { ignore } = options.notifications;
|
||||
|
||||
const notifs = await Service.import('notifications');
|
||||
@@ -58,9 +59,27 @@ export const Notifications = (): BarBoxChild => {
|
||||
isVisible: true,
|
||||
boxClass: 'notifications',
|
||||
props: {
|
||||
on_primary_click: (clicked: Button<Child, Child>, event: Gdk.Event): void => {
|
||||
on_primary_click: (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
openMenu(clicked, event, 'notificationsmenu');
|
||||
},
|
||||
setup: (self: Button<Child, Attribute>): void => {
|
||||
self.hook(options.bar.scrollSpeed, () => {
|
||||
const throttledHandler = throttledScrollHandler(options.bar.scrollSpeed.value);
|
||||
|
||||
self.on_secondary_click = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
runAsyncCommand(rightClick.value, { clicked, event });
|
||||
};
|
||||
self.on_middle_click = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
runAsyncCommand(middleClick.value, { clicked, event });
|
||||
};
|
||||
self.on_scroll_up = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
throttledHandler(scrollUp.value, { clicked, event });
|
||||
};
|
||||
self.on_scroll_down = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
throttledHandler(scrollDown.value, { clicked, event });
|
||||
};
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Gdk from 'gi://Gdk?version=3.0';
|
||||
import { Child } from 'lib/types/widget';
|
||||
import { Attribute, Child } from 'lib/types/widget';
|
||||
import Button from 'types/widgets/button';
|
||||
|
||||
export const closeAllMenus = (): void => {
|
||||
@@ -20,7 +20,7 @@ export const closeAllMenus = (): void => {
|
||||
});
|
||||
};
|
||||
|
||||
export const openMenu = (clicked: Button<Child, Child>, event: Gdk.Event, window: string): void => {
|
||||
export const openMenu = (clicked: Button<Child, Attribute>, event: Gdk.Event, window: string): void => {
|
||||
/*
|
||||
* NOTE: We have to make some adjustments so the menu pops up relatively
|
||||
* to the center of the button clicked. We don't want the menu to spawn
|
||||
|
||||
@@ -7,7 +7,10 @@ import { VolumeIcons } from 'lib/types/volume.js';
|
||||
import { BarBoxChild } from 'lib/types/bar.js';
|
||||
import { Bind } from 'lib/types/variable.js';
|
||||
import Button from 'types/widgets/button.js';
|
||||
import { Child } from 'lib/types/widget.js';
|
||||
import { Attribute, Child } from 'lib/types/widget.js';
|
||||
import { runAsyncCommand, throttledScrollHandler } from 'customModules/utils.js';
|
||||
|
||||
const { rightClick, middleClick, scrollUp, scrollDown } = options.bar.volume;
|
||||
|
||||
const Volume = (): BarBoxChild => {
|
||||
const icons: VolumeIcons = {
|
||||
@@ -75,9 +78,27 @@ const Volume = (): BarBoxChild => {
|
||||
isVisible: true,
|
||||
boxClass: 'volume',
|
||||
props: {
|
||||
on_primary_click: (clicked: Button<Child, Child>, event: Gdk.Event): void => {
|
||||
onPrimaryClick: (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
openMenu(clicked, event, 'audiomenu');
|
||||
},
|
||||
setup: (self: Button<Child, Attribute>): void => {
|
||||
self.hook(options.bar.scrollSpeed, () => {
|
||||
const throttledHandler = throttledScrollHandler(options.bar.scrollSpeed.value);
|
||||
|
||||
self.on_secondary_click = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
runAsyncCommand(rightClick.value, { clicked, event });
|
||||
};
|
||||
self.on_middle_click = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
runAsyncCommand(middleClick.value, { clicked, event });
|
||||
};
|
||||
self.on_scroll_up = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
throttledHandler(scrollUp.value, { clicked, event });
|
||||
};
|
||||
self.on_scroll_down = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
throttledHandler(scrollDown.value, { clicked, event });
|
||||
};
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
const hyprland = await Service.import('hyprland');
|
||||
import { BarBoxChild } from 'lib/types/bar';
|
||||
import options from 'options';
|
||||
import { Child } from 'lib/types/widget';
|
||||
import { Attribute, Child } from 'lib/types/widget';
|
||||
import { ActiveClient } from 'types/service/hyprland';
|
||||
import Label from 'types/widgets/label';
|
||||
import { runAsyncCommand, throttledScrollHandler } from 'customModules/utils';
|
||||
import Button from 'types/widgets/button';
|
||||
import Gdk from 'types/@girs/gdk-3.0/gdk-3.0';
|
||||
|
||||
const { leftClick, rightClick, middleClick, scrollDown, scrollUp } = options.bar.windowtitle;
|
||||
|
||||
const filterTitle = (windowtitle: ActiveClient): Record<string, string> => {
|
||||
const windowTitleMap = [
|
||||
@@ -207,7 +212,29 @@ const ClientTitle = (): BarBoxChild => {
|
||||
}),
|
||||
isVisible: true,
|
||||
boxClass: 'windowtitle',
|
||||
props: {},
|
||||
props: {
|
||||
setup: (self: Button<Child, Attribute>): void => {
|
||||
self.hook(options.bar.scrollSpeed, () => {
|
||||
const throttledHandler = throttledScrollHandler(options.bar.scrollSpeed.value);
|
||||
|
||||
self.on_primary_click = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
runAsyncCommand(leftClick.value, { clicked, event });
|
||||
};
|
||||
self.on_secondary_click = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
runAsyncCommand(rightClick.value, { clicked, event });
|
||||
};
|
||||
self.on_middle_click = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
runAsyncCommand(middleClick.value, { clicked, event });
|
||||
};
|
||||
self.on_scroll_up = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
throttledHandler(scrollUp.value, { clicked, event });
|
||||
};
|
||||
self.on_scroll_down = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
throttledHandler(scrollDown.value, { clicked, event });
|
||||
};
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
const audio = await Service.import('audio');
|
||||
import { BarBoxChild } from 'lib/types/bar.js';
|
||||
import { getIcon } from '../utils.js';
|
||||
import Box from 'types/widgets/box.js';
|
||||
import { Attribute, Child } from 'lib/types/widget.js';
|
||||
|
||||
const renderActiveInput = (): BarBoxChild => {
|
||||
const renderActiveInput = (): Box<Child, Attribute>[] => {
|
||||
return [
|
||||
Widget.Box({
|
||||
class_name: 'menu-slider-container input',
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
const audio = await Service.import('audio');
|
||||
import { BarBoxChild } from 'lib/types/bar.js';
|
||||
import { getIcon } from '../utils.js';
|
||||
import Box from 'types/widgets/box.js';
|
||||
import { Attribute, Child } from 'lib/types/widget.js';
|
||||
|
||||
const renderActivePlayback = (): BarBoxChild => {
|
||||
const renderActivePlayback = (): Box<Child, Attribute>[] => {
|
||||
return [
|
||||
Widget.Box({
|
||||
class_name: 'menu-slider-container playback',
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { BarBoxChild } from 'lib/types/bar.js';
|
||||
import { renderActiveInput } from './SelectedInput.js';
|
||||
import { renderActivePlayback } from './SelectedPlayback.js';
|
||||
import Box from 'types/widgets/box.js';
|
||||
import { Attribute, Child } from 'lib/types/widget.js';
|
||||
|
||||
const activeDevices = (): BarBoxChild => {
|
||||
const activeDevices = (): Box<Child, Attribute> => {
|
||||
return Widget.Box({
|
||||
class_name: 'menu-section-container volume',
|
||||
vertical: true,
|
||||
|
||||
Reference in New Issue
Block a user