forked from Shinonome/dots-hyprland
user config round 1 (#271)
This commit is contained in:
@@ -9,22 +9,14 @@ import { MaterialIcon } from '../../.commonwidgets/materialicon.js';
|
||||
import { AnimatedCircProg } from "../../.commonwidgets/cairo_circularprogress.js";
|
||||
import { WWO_CODE, WEATHER_SYMBOL, NIGHT_WEATHER_SYMBOL } from '../../.commondata/weather.js';
|
||||
|
||||
const BATTERY_LOW = 20;
|
||||
const WEATHER_CACHE_FOLDER = `${GLib.get_user_cache_dir()}/ags/weather`;
|
||||
Utils.exec(`mkdir -p ${WEATHER_CACHE_FOLDER}`);
|
||||
|
||||
let WEATHER_CITY = '';
|
||||
try {
|
||||
WEATHER_CITY = GLib.getenv('AGS_WEATHER_CITY');
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
|
||||
const BatBatteryProgress = () => {
|
||||
const _updateProgress = (circprog) => { // Set circular progress value
|
||||
circprog.css = `font-size: ${Math.abs(Battery.percent)}px;`
|
||||
|
||||
circprog.toggleClassName('bar-batt-circprog-low', Battery.percent <= BATTERY_LOW);
|
||||
circprog.toggleClassName('bar-batt-circprog-low', Battery.percent <= userOptions.battery.low);
|
||||
circprog.toggleClassName('bar-batt-circprog-full', Battery.charged);
|
||||
}
|
||||
return AnimatedCircProg({
|
||||
@@ -119,7 +111,7 @@ const BarBattery = () => Box({
|
||||
MaterialIcon('settings_heart', 'small'),
|
||||
],
|
||||
setup: (self) => self.hook(Battery, box => {
|
||||
box.toggleClassName('bar-batt-low', Battery.percent <= BATTERY_LOW);
|
||||
box.toggleClassName('bar-batt-low', Battery.percent <= userOptions.battery.low);
|
||||
box.toggleClassName('bar-batt-full', Battery.charged);
|
||||
}),
|
||||
}),
|
||||
@@ -192,8 +184,8 @@ const BatteryModule = () => Stack({
|
||||
print(err);
|
||||
}
|
||||
});
|
||||
if (WEATHER_CITY != '' && WEATHER_CITY != null) {
|
||||
updateWeatherForCity(WEATHER_CITY);
|
||||
if (userOptions.weather.city != '' && userOptions.weather.city != null) {
|
||||
updateWeatherForCity(userOptions.weather.city);
|
||||
}
|
||||
else {
|
||||
Utils.execAsync('curl ipinfo.io')
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
const { Gtk } = imports.gi;
|
||||
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
|
||||
import SystemTray from 'resource:///com/github/Aylur/ags/service/systemtray.js';
|
||||
const { Box, Icon, Button, Revealer } = Widget;
|
||||
@@ -23,52 +22,6 @@ const SysTrayItem = (item) => Button({
|
||||
export const Tray = (props = {}) => {
|
||||
const trayContent = Box({
|
||||
className: 'margin-right-5 spacing-h-15',
|
||||
// attribute: {
|
||||
// items: new Map(),
|
||||
// addItem: (box, item) => {
|
||||
// if (!item) return;
|
||||
// console.log('init item:', item)
|
||||
|
||||
// item.menu.className = 'menu';
|
||||
// if (box.attribute.items.has(item.id) || !item)
|
||||
// return;
|
||||
// const widget = SysTrayItem(item);
|
||||
// box.attribute.items.set(item.id, widget);
|
||||
// box.add(widget);
|
||||
// box.show_all();
|
||||
// },
|
||||
// onAdded: (box, id) => {
|
||||
// console.log('supposed to add', id)
|
||||
// const item = SystemTray.getItem(id);
|
||||
// if (!item) return;
|
||||
// console.log('which is', box.attribute.items.get(id))
|
||||
|
||||
// item.menu.className = 'menu';
|
||||
// if (box.attribute.items.has(id) || !item)
|
||||
// return;
|
||||
// const widget = SysTrayItem(item);
|
||||
// box.attribute.items.set(id, widget);
|
||||
// box.add(widget);
|
||||
// box.show_all();
|
||||
// },
|
||||
// onRemoved: (box, id) => {
|
||||
// console.log('supposed to remove', id)
|
||||
// if (!box.attribute.items.has(id)) return;
|
||||
// console.log('which is', box.attribute.items.get(id))
|
||||
// box.attribute.items.get(id).destroy();
|
||||
// box.attribute.items.delete(id);
|
||||
// },
|
||||
// },
|
||||
// setup: (self) => {
|
||||
// // self.hook(SystemTray, (box, id) => box.attribute.onAdded(box, id), 'added')
|
||||
// // .hook(SystemTray, (box, id) => box.attribute.onRemoved(box, id), 'removed');
|
||||
// // SystemTray.items.forEach(item => self.attribute.addItem(self, item));
|
||||
// // self.chidren = SystemTray.items.map(item => SysTrayItem(item));
|
||||
// console.log(SystemTray.items.map(item => SysTrayItem(item)))
|
||||
// self.chidren = SystemTray.items.map(item => SysTrayItem(item));
|
||||
|
||||
// self.show_all();
|
||||
// },
|
||||
setup: (self) => self
|
||||
.hook(SystemTray, (self) => {
|
||||
self.children = SystemTray.items.map(SysTrayItem);
|
||||
|
||||
@@ -9,7 +9,6 @@ import Widget from 'resource:///com/github/Aylur/ags/widget.js';
|
||||
const { Box, DrawingArea, EventBox } = Widget;
|
||||
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
||||
|
||||
const NUM_OF_WORKSPACES_SHOWN = 10; // Limit = 53 I think
|
||||
const dummyWs = Box({ className: 'bar-ws' }); // Not shown. Only for getting size props
|
||||
const dummyActiveWs = Box({ className: 'bar-ws bar-ws-active' }); // Not shown. Only for getting size props
|
||||
const dummyOccupiedWs = Box({ className: 'bar-ws bar-ws-occupied' }); // Not shown. Only for getting size props
|
||||
@@ -23,7 +22,7 @@ const WorkspaceContents = (count = 10) => {
|
||||
workspaceMask: 0,
|
||||
workspaceGroup: 0,
|
||||
updateMask: (self) => {
|
||||
const offset = Math.floor((Hyprland.active.workspace.id - 1) / count) * NUM_OF_WORKSPACES_SHOWN;
|
||||
const offset = Math.floor((Hyprland.active.workspace.id - 1) / count) * userOptions.workspaces.shown;
|
||||
// if (self.attribute.initialized) return; // We only need this to run once
|
||||
const workspaces = Hyprland.workspaces;
|
||||
let workspaceMask = 0;
|
||||
@@ -56,7 +55,7 @@ const WorkspaceContents = (count = 10) => {
|
||||
})
|
||||
.hook(Hyprland, (self) => self.attribute.updateMask(self), 'notify::workspaces')
|
||||
.on('draw', Lang.bind(area, (area, cr) => {
|
||||
const offset = Math.floor((Hyprland.active.workspace.id - 1) / count) * NUM_OF_WORKSPACES_SHOWN;
|
||||
const offset = Math.floor((Hyprland.active.workspace.id - 1) / count) * userOptions.workspaces.shown;
|
||||
|
||||
const allocation = area.get_allocation();
|
||||
const { width, height } = allocation;
|
||||
@@ -162,7 +161,7 @@ export default () => EventBox({
|
||||
children: [Box({
|
||||
className: 'bar-group bar-group-standalone bar-group-pad',
|
||||
css: 'min-width: 2px;',
|
||||
children: [WorkspaceContents(NUM_OF_WORKSPACES_SHOWN)],
|
||||
children: [WorkspaceContents(userOptions.workspaces.shown)],
|
||||
})]
|
||||
}),
|
||||
setup: (self) => {
|
||||
@@ -171,7 +170,7 @@ export default () => EventBox({
|
||||
if (!self.attribute.clicked) return;
|
||||
const [_, cursorX, cursorY] = event.get_coords();
|
||||
const widgetWidth = self.get_allocation().width;
|
||||
const wsId = Math.ceil(cursorX * NUM_OF_WORKSPACES_SHOWN / widgetWidth);
|
||||
const wsId = Math.ceil(cursorX * userOptions.workspaces.shown / widgetWidth);
|
||||
Utils.execAsync([`${App.configDir}/scripts/hyprland/workspace_action.sh`, 'workspace', `${wsId}`])
|
||||
.catch(print);
|
||||
})
|
||||
@@ -182,7 +181,7 @@ export default () => EventBox({
|
||||
const widgetWidth = self.get_allocation().width;
|
||||
// const wsId = Math.ceil(cursorX * NUM_OF_WORKSPACES_PER_GROUP / widgetWidth) + self.attribute.ws_group * NUM_OF_WORKSPACES_PER_GROUP;
|
||||
// Hyprland.messageAsync(`dispatch workspace ${wsId}`).catch(print);
|
||||
const wsId = Math.ceil(cursorX * NUM_OF_WORKSPACES_SHOWN / widgetWidth);
|
||||
const wsId = Math.ceil(cursorX * userOptions.workspaces.shown / widgetWidth);
|
||||
Utils.execAsync([`${App.configDir}/scripts/hyprland/workspace_action.sh`, 'workspace', `${wsId}`])
|
||||
.catch(print);
|
||||
})
|
||||
|
||||
@@ -9,7 +9,6 @@ import * as Utils from "resource:///com/github/Aylur/ags/utils.js";
|
||||
const { execAsync, exec } = Utils;
|
||||
const { Box, DrawingArea, EventBox } = Widget;
|
||||
|
||||
const NUM_OF_WORKSPACES = 10;
|
||||
const dummyWs = Box({ className: 'bar-ws' }); // Not shown. Only for getting size props
|
||||
const dummyActiveWs = Box({ className: 'bar-ws bar-ws-active' }); // Not shown. Only for getting size props
|
||||
const dummyOccupiedWs = Box({ className: 'bar-ws bar-ws-occupied' }); // Not shown. Only for getting size props
|
||||
@@ -168,7 +167,7 @@ export default () => EventBox({
|
||||
if (!self.attribute.clicked) return;
|
||||
const [_, cursorX, cursorY] = event.get_coords();
|
||||
const widgetWidth = self.get_allocation().width;
|
||||
const wsId = Math.ceil(cursorX * NUM_OF_WORKSPACES / widgetWidth);
|
||||
const wsId = Math.ceil(cursorX * userOptions.workspaces.shown / widgetWidth);
|
||||
switchToWorkspace(wsId);
|
||||
})
|
||||
self.on('button-press-event', (self, event) => {
|
||||
@@ -176,7 +175,7 @@ export default () => EventBox({
|
||||
self.attribute.clicked = true;
|
||||
const [_, cursorX, cursorY] = event.get_coords();
|
||||
const widgetWidth = self.get_allocation().width;
|
||||
const wsId = Math.ceil(cursorX * NUM_OF_WORKSPACES / widgetWidth);
|
||||
const wsId = Math.ceil(cursorX * userOptions.workspaces.shown / widgetWidth);
|
||||
switchToWorkspace(wsId);
|
||||
})
|
||||
self.on('button-release-event', (self) => self.attribute.clicked = false);
|
||||
|
||||
Reference in New Issue
Block a user