forked from Shinonome/dots-hyprland
Add translation
This commit is contained in:
@@ -7,6 +7,7 @@ import { setupCursorHover } from '../.widgetutils/cursorhover.js';
|
||||
|
||||
import { TodoWidget } from "./todolist.js";
|
||||
import { getCalendarLayout } from "./calendar_layout.js";
|
||||
import { getString } from '../../i18n/i18n.js';
|
||||
|
||||
let calendarJson = getCalendarLayout(undefined, true);
|
||||
let monthshift = 0;
|
||||
@@ -30,13 +31,13 @@ function getDateInXMonthsTime(x) {
|
||||
}
|
||||
|
||||
const weekDays = [ // MONDAY IS THE FIRST DAY OF THE WEEK :HESRIGHTYOUKNOW:
|
||||
{ day: 'Mo', today: 0 },
|
||||
{ day: 'Tu', today: 0 },
|
||||
{ day: 'We', today: 0 },
|
||||
{ day: 'Th', today: 0 },
|
||||
{ day: 'Fr', today: 0 },
|
||||
{ day: 'Sa', today: 0 },
|
||||
{ day: 'Su', today: 0 },
|
||||
{ day: getString('Mo'), today: 0 },
|
||||
{ day: getString('Tu'), today: 0 },
|
||||
{ day: getString('We'), today: 0 },
|
||||
{ day: getString('Th'), today: 0 },
|
||||
{ day: getString('Fr'), today: 0 },
|
||||
{ day: getString('Sa'), today: 0 },
|
||||
{ day: getString('Su'), today: 0 },
|
||||
]
|
||||
|
||||
const CalendarDay = (day, today) => Widget.Button({
|
||||
@@ -192,8 +193,8 @@ export const ModuleCalendar = () => Box({
|
||||
vertical: true,
|
||||
className: 'sidebar-navrail spacing-v-10',
|
||||
children: [
|
||||
StackButton('calendar', 'calendar_month', 'Calendar'),
|
||||
StackButton('todo', 'done_outline', 'To Do'),
|
||||
StackButton('calendar', 'calendar_month', getString('Calendar')),
|
||||
StackButton('todo', 'done_outline', getString('To Do')),
|
||||
// StackButton(box, 'stars', 'star', 'GitHub'),
|
||||
]
|
||||
}), false, false, 0);
|
||||
|
||||
@@ -5,6 +5,7 @@ const { Box, Button, Icon, Label, Revealer, Scrollable, Slider, Stack } = Widget
|
||||
import { MaterialIcon } from '../../.commonwidgets/materialicon.js';
|
||||
import { setupCursorHover } from '../../.widgetutils/cursorhover.js';
|
||||
import { iconExists } from '../../.miscutils/icons.js';
|
||||
import { getString } from '../../../i18n/i18n.js';
|
||||
|
||||
const AppVolume = (stream) => Box({
|
||||
className: 'sidebar-volmixer-stream spacing-h-10',
|
||||
@@ -165,7 +166,7 @@ export default (props) => {
|
||||
className: 'spacing-v-5 txt-subtext',
|
||||
children: [
|
||||
MaterialIcon('brand_awareness', 'gigantic'),
|
||||
Label({ label: 'No audio source', className: 'txt-small' }),
|
||||
Label({ label: getString('No audio source'), className: 'txt-small' }),
|
||||
]
|
||||
}),
|
||||
]
|
||||
|
||||
@@ -6,6 +6,7 @@ const { execAsync, exec } = Utils;
|
||||
import { MaterialIcon } from '../../.commonwidgets/materialicon.js';
|
||||
import { setupCursorHover } from '../../.widgetutils/cursorhover.js';
|
||||
import { ConfigToggle } from '../../.commonwidgets/configwidgets.js';
|
||||
import { getString } from '../../../i18n/i18n.js';
|
||||
|
||||
// can't connect: sync_problem
|
||||
|
||||
@@ -43,7 +44,7 @@ const BluetoothDevice = (device) => {
|
||||
label: device.connected ? 'Connected' : (device.paired ? 'Paired' : ''),
|
||||
className: 'txt-subtext',
|
||||
setup: (self) => self.hook(device, (self) => {
|
||||
self.label = device.connected ? 'Connected' : (device.paired ? 'Paired' : '');
|
||||
self.label = device.connected ? getString('Connected') : (device.paired ? getString('Paired') : '');
|
||||
}),
|
||||
}),
|
||||
]
|
||||
@@ -64,7 +65,7 @@ const BluetoothDevice = (device) => {
|
||||
vpack: 'center',
|
||||
className: 'sidebar-bluetooth-device-remove',
|
||||
child: MaterialIcon('delete', 'norm'),
|
||||
tooltipText: 'Remove device',
|
||||
tooltipText: getString('Remove device'),
|
||||
setup: setupCursorHover,
|
||||
onClicked: () => execAsync(['bluetoothctl', 'remove', device.address]).catch(print),
|
||||
});
|
||||
@@ -144,7 +145,7 @@ export default (props) => {
|
||||
execAsync(['bash', '-c', userOptions.apps.bluetooth]).catch(print);
|
||||
closeEverything();
|
||||
},
|
||||
label: 'More',
|
||||
label: getString('More'),
|
||||
setup: setupCursorHover,
|
||||
})],
|
||||
})
|
||||
|
||||
@@ -7,6 +7,7 @@ const { execAsync, exec } = Utils;
|
||||
import { MaterialIcon } from '../../.commonwidgets/materialicon.js';
|
||||
import { setupCursorHover } from '../../.widgetutils/cursorhover.js';
|
||||
import { ConfigGap, ConfigSpinButton, ConfigToggle } from '../../.commonwidgets/configwidgets.js';
|
||||
import { getString } from '../../../i18n/i18n.js';
|
||||
|
||||
const HyprlandToggle = ({ icon, name, desc = null, option, enableValue = 1, disableValue = 0, extraOnChange = () => { } }) => ConfigToggle({
|
||||
icon: icon,
|
||||
@@ -60,11 +61,11 @@ export default (props) => {
|
||||
className: 'spacing-v-10',
|
||||
children: [
|
||||
ConfigSection({
|
||||
name: 'Effects', children: [
|
||||
name: getString('Effects'), children: [
|
||||
ConfigToggle({
|
||||
icon: 'border_clear',
|
||||
name: 'Transparency',
|
||||
desc: '[AGS]\nMake shell elements transparent\nBlur is also recommended if you enable this',
|
||||
name: getString('Transparency'),
|
||||
desc: getString('[AGS]\nMake shell elements transparent\nBlur is also recommended if you enable this'),
|
||||
initValue: exec(`bash -c "sed -n \'2p\' ${GLib.get_user_state_dir()}/ags/user/colormode.txt"`) == "transparent",
|
||||
onChange: (self, newValue) => {
|
||||
const transparency = newValue == 0 ? "opaque" : "transparent";
|
||||
@@ -74,22 +75,22 @@ export default (props) => {
|
||||
.catch(print);
|
||||
},
|
||||
}),
|
||||
HyprlandToggle({ icon: 'blur_on', name: 'Blur', desc: "[Hyprland]\nEnable blur on transparent elements\nDoesn't affect performance/power consumption unless you have transparent windows.", option: "decoration:blur:enabled" }),
|
||||
HyprlandToggle({ icon: 'blur_on', name: getString('Blur'), desc: getString("[Hyprland]\nEnable blur on transparent elements\nDoesn't affect performance/power consumption unless you have transparent windows."), option: "decoration:blur:enabled" }),
|
||||
Subcategory([
|
||||
HyprlandToggle({ icon: 'stack_off', name: 'X-ray', desc: "[Hyprland]\nMake everything behind a window/layer except the wallpaper not rendered on its blurred surface\nRecommended to improve performance (if you don't abuse transparency/blur) ", option: "decoration:blur:xray" }),
|
||||
HyprlandSpinButton({ icon: 'target', name: 'Size', desc: '[Hyprland]\nAdjust the blur radius. Generally doesn\'t affect performance\nHigher = more color spread', option: 'decoration:blur:size', minValue: 1, maxValue: 1000 }),
|
||||
HyprlandSpinButton({ icon: 'repeat', name: 'Passes', desc: '[Hyprland] Adjust the number of runs of the blur algorithm\nMore passes = more spread and power consumption\n4 is recommended\n2- would look weird and 6+ would look lame.', option: 'decoration:blur:passes', minValue: 1, maxValue: 10 }),
|
||||
HyprlandToggle({ icon: 'stack_off', name: getString('X-ray'), desc: getString("[Hyprland]\nMake everything behind a window/layer except the wallpaper not rendered on its blurred surface\nRecommended to improve performance (if you don't abuse transparency/blur) "), option: "decoration:blur:xray" }),
|
||||
HyprlandSpinButton({ icon: 'target', name: getString('Size'), desc: getString('[Hyprland]\nAdjust the blur radius. Generally doesn\'t affect performance\nHigher = more color spread'), option: 'decoration:blur:size', minValue: 1, maxValue: 1000 }),
|
||||
HyprlandSpinButton({ icon: 'repeat', name: getString('Passes'), desc: getString('[Hyprland] Adjust the number of runs of the blur algorithm\nMore passes = more spread and power consumption\n4 is recommended\n2- would look weird and 6+ would look lame.'), option: 'decoration:blur:passes', minValue: 1, maxValue: 10 }),
|
||||
]),
|
||||
ConfigGap({}),
|
||||
HyprlandToggle({
|
||||
icon: 'animation', name: 'Animations', desc: '[Hyprland] [GTK]\nEnable animations', option: 'animations:enabled',
|
||||
icon: 'animation', name: getString('Animations'), desc: getString('[Hyprland] [GTK]\nEnable animations'), option: 'animations:enabled',
|
||||
extraOnChange: (self, newValue) => execAsync(['gsettings', 'set', 'org.gnome.desktop.interface', 'enable-animations', `${newValue}`])
|
||||
}),
|
||||
Subcategory([
|
||||
ConfigSpinButton({
|
||||
icon: 'clear_all',
|
||||
name: 'Choreography delay',
|
||||
desc: 'In milliseconds, the delay between animations of a series',
|
||||
name: getString('Choreography delay'),
|
||||
desc: getString('In milliseconds, the delay between animations of a series'),
|
||||
initValue: userOptions.animations.choreographyDelay,
|
||||
step: 10, minValue: 0, maxValue: 1000,
|
||||
onChange: (self, newValue) => {
|
||||
@@ -100,11 +101,11 @@ export default (props) => {
|
||||
]
|
||||
}),
|
||||
ConfigSection({
|
||||
name: 'Developer', children: [
|
||||
HyprlandToggle({ icon: 'speed', name: 'Show FPS', desc: "[Hyprland]\nShow FPS overlay on top-left corner", option: "debug:overlay" }),
|
||||
HyprlandToggle({ icon: 'sort', name: 'Log to stdout', desc: "[Hyprland]\nPrint LOG, ERR, WARN, etc. messages to the console", option: "debug:enable_stdout_logs" }),
|
||||
HyprlandToggle({ icon: 'motion_sensor_active', name: 'Damage tracking', desc: "[Hyprland]\nEnable damage tracking\nGenerally, leave it on.\nTurn off only when a shader doesn't work", option: "debug:damage_tracking", enableValue: 2 }),
|
||||
HyprlandToggle({ icon: 'destruction', name: 'Damage blink', desc: "[Hyprland] [Epilepsy warning!]\nShow screen damage flashes", option: "debug:damage_blink" }),
|
||||
name: getString('Developer'), children: [
|
||||
HyprlandToggle({ icon: 'speed', name: getString('Show FPS'), desc: getString("[Hyprland]\nShow FPS overlay on top-left corner"), option: "debug:overlay" }),
|
||||
HyprlandToggle({ icon: 'sort', name: getString('Log to stdout'), desc: getString("[Hyprland]\nPrint LOG, ERR, WARN, etc. messages to the console"), option: "debug:enable_stdout_logs" }),
|
||||
HyprlandToggle({ icon: 'motion_sensor_active', name: getString('Damage tracking'), desc: getString("[Hyprland]\nEnable damage tracking\nGenerally, leave it on.\nTurn off only when a shader doesn't work"), option: "debug:damage_tracking", enableValue: 2 }),
|
||||
HyprlandToggle({ icon: 'destruction', name: getString('Damage blink'), desc: getString("[Hyprland] [Epilepsy warning!]\nShow screen damage flashes"), option: "debug:damage_blink" }),
|
||||
]
|
||||
}),
|
||||
]
|
||||
@@ -115,7 +116,7 @@ export default (props) => {
|
||||
children: [Label({
|
||||
hpack: 'center',
|
||||
className: 'txt txt-italic txt-subtext margin-5',
|
||||
label: 'Not all changes are saved',
|
||||
label: getString('Not all changes are saved'),
|
||||
})]
|
||||
})
|
||||
return Box({
|
||||
|
||||
@@ -8,6 +8,7 @@ import { MaterialIcon } from '../../.commonwidgets/materialicon.js';
|
||||
import { setupCursorHover } from '../../.widgetutils/cursorhover.js';
|
||||
import Notification from '../../.commonwidgets/notification.js';
|
||||
import { ConfigToggle } from '../../.commonwidgets/configwidgets.js';
|
||||
import { getString } from '../../../i18n/i18n.js';
|
||||
|
||||
export default (props) => {
|
||||
const notifEmptyContent = Box({
|
||||
@@ -22,7 +23,7 @@ export default (props) => {
|
||||
className: 'spacing-v-5 txt-subtext',
|
||||
children: [
|
||||
MaterialIcon('notifications_active', 'gigantic'),
|
||||
Label({ label: 'No notifications', className: 'txt-small' }),
|
||||
Label({ label: getString('No notifications'), className: 'txt-small' }),
|
||||
]
|
||||
}),
|
||||
]
|
||||
@@ -82,7 +83,7 @@ export default (props) => {
|
||||
}),
|
||||
setup: setupCursorHover,
|
||||
});
|
||||
const silenceButton = ListActionButton('notifications_paused', 'Silence', (self) => {
|
||||
const silenceButton = ListActionButton('notifications_paused', getString('Silence'), (self) => {
|
||||
Notifications.dnd = !Notifications.dnd;
|
||||
self.toggleClassName('notif-listaction-btn-enabled', Notifications.dnd);
|
||||
});
|
||||
@@ -101,7 +102,7 @@ export default (props) => {
|
||||
setup: (self) => self.hook(Notifications, (self) => {
|
||||
self.revealChild = Notifications.notifications.length > 0;
|
||||
}),
|
||||
child: ListActionButton('clear_all', 'Clear', () => {
|
||||
child: ListActionButton('clear_all', getString('Clear'), () => {
|
||||
Notifications.clear();
|
||||
const kids = notificationList.get_children();
|
||||
for (let i = 0; i < kids.length; i++) {
|
||||
@@ -114,7 +115,7 @@ export default (props) => {
|
||||
attribute: {
|
||||
updateCount: (self) => {
|
||||
const count = Notifications.notifications.length;
|
||||
if (count > 0) self.label = `${count} notifications`;
|
||||
if (count > 0) self.label = `${count} ${getString("notifications")}`;
|
||||
else self.label = '';
|
||||
},
|
||||
},
|
||||
|
||||
@@ -6,6 +6,7 @@ const { execAsync, exec } = Utils;
|
||||
import { MaterialIcon } from '../../.commonwidgets/materialicon.js';
|
||||
import { setupCursorHover } from '../../.widgetutils/cursorhover.js';
|
||||
import { ConfigToggle } from '../../.commonwidgets/configwidgets.js';
|
||||
import { getString } from '../../../i18n/i18n.js';
|
||||
|
||||
const MATERIAL_SYMBOL_SIGNAL_STRENGTH = {
|
||||
'network-wireless-signal-excellent-symbolic': "signal_wifi_4_bar",
|
||||
@@ -29,7 +30,7 @@ const WifiNetwork = (accessPoint) => {
|
||||
accessPoint.active ? Label({
|
||||
hpack: 'start',
|
||||
className: 'txt-smaller txt-subtext',
|
||||
label: "Selected",
|
||||
label: getString("Selected"),
|
||||
}) : null,
|
||||
]
|
||||
});
|
||||
@@ -69,7 +70,7 @@ const CurrentNetwork = () => {
|
||||
Label({
|
||||
hpack: 'start',
|
||||
className: 'txt-smaller txt-subtext',
|
||||
label: "Current network",
|
||||
label: getString("Current network"),
|
||||
}),
|
||||
Label({
|
||||
hpack: 'start',
|
||||
@@ -101,7 +102,7 @@ const CurrentNetwork = () => {
|
||||
Label({
|
||||
className: 'margin-left-5',
|
||||
hpack: 'start',
|
||||
label: "Authentication",
|
||||
label: getString("Authentication"),
|
||||
}),
|
||||
Entry({
|
||||
className: 'sidebar-wifinetworks-auth-entry',
|
||||
@@ -199,7 +200,7 @@ export default (props) => {
|
||||
execAsync(['bash', '-c', userOptions.apps.network]).catch(print);
|
||||
closeEverything();
|
||||
},
|
||||
label: 'More',
|
||||
label: getString('More'),
|
||||
setup: setupCursorHover,
|
||||
})],
|
||||
})
|
||||
|
||||
@@ -10,10 +10,11 @@ import { BluetoothIndicator, NetworkIndicator } from '../.commonwidgets/statusic
|
||||
import { setupCursorHover } from '../.widgetutils/cursorhover.js';
|
||||
import { MaterialIcon } from '../.commonwidgets/materialicon.js';
|
||||
import { sidebarOptionsStack } from './sideright.js';
|
||||
import { getString } from '../../i18n/i18n.js';
|
||||
|
||||
export const ToggleIconWifi = (props = {}) => Widget.Button({
|
||||
className: 'txt-small sidebar-iconbutton',
|
||||
tooltipText: 'Wifi | Right-click to configure',
|
||||
tooltipText: getString('Wifi | Right-click to configure'),
|
||||
onClicked: () => Network.toggleWifi(),
|
||||
onSecondaryClickRelease: () => {
|
||||
execAsync(['bash', '-c', `${userOptions.apps.network}`]).catch(print);
|
||||
@@ -24,7 +25,7 @@ export const ToggleIconWifi = (props = {}) => Widget.Button({
|
||||
setupCursorHover(self);
|
||||
self.hook(Network, button => {
|
||||
button.toggleClassName('sidebar-button-active', [Network.wifi?.internet, Network.wired?.internet].includes('connected'))
|
||||
button.tooltipText = (`${Network.wifi?.ssid} | Right-click to configure` || 'Unknown');
|
||||
button.tooltipText = (`${Network.wifi?.ssid} | ${getString("Right-click to configure")}` || getString('Unknown'));
|
||||
});
|
||||
},
|
||||
...props,
|
||||
@@ -32,7 +33,7 @@ export const ToggleIconWifi = (props = {}) => Widget.Button({
|
||||
|
||||
export const ToggleIconBluetooth = (props = {}) => Widget.Button({
|
||||
className: 'txt-small sidebar-iconbutton',
|
||||
tooltipText: 'Bluetooth | Right-click to configure',
|
||||
tooltipText: getString('Bluetooth | Right-click to configure'),
|
||||
onClicked: () => {
|
||||
const status = Bluetooth?.enabled;
|
||||
if (status)
|
||||
@@ -86,7 +87,7 @@ export const ModuleNightLight = async (props = {}) => {
|
||||
enabled: false,
|
||||
},
|
||||
className: 'txt-small sidebar-iconbutton',
|
||||
tooltipText: 'Night Light',
|
||||
tooltipText: getString('Night Light'),
|
||||
onClicked: (self) => {
|
||||
self.attribute.enabled = !self.attribute.enabled;
|
||||
self.toggleClassName('sidebar-button-active', self.attribute.enabled);
|
||||
@@ -122,7 +123,7 @@ export const ModuleCloudflareWarp = async (props = {}) => {
|
||||
enabled: false,
|
||||
},
|
||||
className: 'txt-small sidebar-iconbutton',
|
||||
tooltipText: 'Cloudflare WARP',
|
||||
tooltipText: getString('Cloudflare WARP'),
|
||||
onClicked: (self) => {
|
||||
self.attribute.enabled = !self.attribute.enabled;
|
||||
self.toggleClassName('sidebar-button-active', self.attribute.enabled);
|
||||
@@ -147,7 +148,7 @@ export const ModuleInvertColors = async (props = {}) => {
|
||||
const Hyprland = (await import('resource:///com/github/Aylur/ags/service/hyprland.js')).default;
|
||||
return Widget.Button({
|
||||
className: 'txt-small sidebar-iconbutton',
|
||||
tooltipText: 'Color inversion',
|
||||
tooltipText: getString('Color inversion'),
|
||||
onClicked: (button) => {
|
||||
// const shaderPath = JSON.parse(exec('hyprctl -j getoption decoration:screen_shader')).str;
|
||||
Hyprland.messageAsync('j/getoption decoration:screen_shader')
|
||||
@@ -208,7 +209,7 @@ export const ModuleIdleInhibitor = (props = {}) => Widget.Button({ // TODO: Make
|
||||
enabled: false,
|
||||
},
|
||||
className: 'txt-small sidebar-iconbutton',
|
||||
tooltipText: 'Keep system awake',
|
||||
tooltipText: getString('Keep system awake'),
|
||||
onClicked: (self) => {
|
||||
self.attribute.enabled = !self.attribute.enabled;
|
||||
self.toggleClassName('sidebar-button-active', self.attribute.enabled);
|
||||
@@ -227,7 +228,7 @@ export const ModuleIdleInhibitor = (props = {}) => Widget.Button({ // TODO: Make
|
||||
export const ModuleReloadIcon = (props = {}) => Widget.Button({
|
||||
...props,
|
||||
className: 'txt-small sidebar-iconbutton',
|
||||
tooltipText: 'Reload Environment config',
|
||||
tooltipText: getString('Reload Environment config'),
|
||||
onClicked: () => {
|
||||
execAsync(['bash', '-c', 'hyprctl reload || swaymsg reload &']);
|
||||
App.closeWindow('sideright');
|
||||
@@ -241,7 +242,7 @@ export const ModuleReloadIcon = (props = {}) => Widget.Button({
|
||||
export const ModuleSettingsIcon = (props = {}) => Widget.Button({
|
||||
...props,
|
||||
className: 'txt-small sidebar-iconbutton',
|
||||
tooltipText: 'Open Settings',
|
||||
tooltipText: getString('Open Settings'),
|
||||
onClicked: () => {
|
||||
execAsync(['bash', '-c', `${userOptions.apps.settings}`, '&']);
|
||||
App.closeWindow('sideright');
|
||||
@@ -255,7 +256,7 @@ export const ModuleSettingsIcon = (props = {}) => Widget.Button({
|
||||
export const ModulePowerIcon = (props = {}) => Widget.Button({
|
||||
...props,
|
||||
className: 'txt-small sidebar-iconbutton',
|
||||
tooltipText: 'Session',
|
||||
tooltipText: getString('Session'),
|
||||
onClicked: () => {
|
||||
closeEverything();
|
||||
Utils.timeout(1, () => openWindowOnAllMonitors('session'));
|
||||
|
||||
@@ -25,31 +25,32 @@ import { getDistroIcon } from '../.miscutils/system.js';
|
||||
import { MaterialIcon } from '../.commonwidgets/materialicon.js';
|
||||
import { ExpandingIconTabContainer } from '../.commonwidgets/tabcontainer.js';
|
||||
import { checkKeybind } from '../.widgetutils/keybind.js';
|
||||
import { getString } from '../../i18n/i18n.js';
|
||||
|
||||
const centerWidgets = [
|
||||
{
|
||||
name: 'Notifications',
|
||||
name: getString('Notifications'),
|
||||
materialIcon: 'notifications',
|
||||
contentWidget: ModuleNotificationList,
|
||||
},
|
||||
{
|
||||
name: 'Audio controls',
|
||||
name: getString('Audio controls'),
|
||||
materialIcon: 'volume_up',
|
||||
contentWidget: ModuleAudioControls,
|
||||
},
|
||||
{
|
||||
name: 'Bluetooth',
|
||||
name: getString('Bluetooth'),
|
||||
materialIcon: 'bluetooth',
|
||||
contentWidget: ModuleBluetooth,
|
||||
},
|
||||
{
|
||||
name: 'Wifi networks',
|
||||
name: getString('Wifi networks'),
|
||||
materialIcon: 'wifi',
|
||||
contentWidget: ModuleWifiNetworks,
|
||||
onFocus: () => execAsync('nmcli dev wifi list').catch(print),
|
||||
},
|
||||
{
|
||||
name: 'Live config',
|
||||
name: getString('Live config'),
|
||||
materialIcon: 'tune',
|
||||
contentWidget: ModuleConfigure,
|
||||
},
|
||||
@@ -66,43 +67,44 @@ const timeRow = Box({
|
||||
hpack: 'center',
|
||||
className: 'txt-small txt',
|
||||
setup: (self) => {
|
||||
const getUptime = async () => {
|
||||
try {
|
||||
await execAsync(['bash', '-c', 'uptime -p']);
|
||||
const getUptime = async () => {
|
||||
try {
|
||||
await execAsync(['bash', '-c', 'uptime -p']);
|
||||
return execAsync(['bash', '-c', `uptime -p | sed -e 's/...//;s/ day\\| days/d/;s/ hour\\| hours/h/;s/ minute\\| minutes/m/;s/,[^,]*//2'`]);
|
||||
} catch {
|
||||
return execAsync(['bash', '-c', 'uptime']).then(output => {
|
||||
const uptimeRegex = /up\s+((\d+)\s+days?,\s+)?((\d+):(\d+)),/;
|
||||
const matches = uptimeRegex.exec(output);
|
||||
const uptimeRegex = /up\s+((\d+)\s+days?,\s+)?((\d+):(\d+)),/;
|
||||
const matches = uptimeRegex.exec(output);
|
||||
|
||||
if (matches) {
|
||||
const days = matches[2] ? parseInt(matches[2]) : 0;
|
||||
const days = matches[2] ? parseInt(matches[2]) : 0;
|
||||
const hours = matches[4] ? parseInt(matches[4]) : 0;
|
||||
const minutes = matches[5] ? parseInt(matches[5]) : 0;
|
||||
|
||||
let formattedUptime = '';
|
||||
|
||||
if (days > 0) {
|
||||
formattedUptime += `${days} d `;
|
||||
formattedUptime += `${days} d `;
|
||||
}
|
||||
if (hours > 0) {
|
||||
formattedUptime += `${hours} h `;
|
||||
formattedUptime += `${hours} h `;
|
||||
}
|
||||
formattedUptime += `${minutes} m`;
|
||||
|
||||
return formattedUptime;
|
||||
} else {
|
||||
throw new Error('Failed to parse uptime output');
|
||||
throw new Error('Failed to parse uptime output');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
self.poll(5000, label => {
|
||||
getUptime().then(upTimeString => {
|
||||
label.label = `Uptime: ${upTimeString}`;
|
||||
getUptime().then(upTimeString => {
|
||||
label.label = `${getString("Uptime:"
|
||||
)} ${upTimeString}`;
|
||||
}).catch(err => {
|
||||
console.error(`Failed to fetch uptime: ${err}`);
|
||||
console.error(`Failed to fetch uptime: ${err}`);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
@@ -5,6 +5,7 @@ import { MaterialIcon } from '../.commonwidgets/materialicon.js';
|
||||
import { TabContainer } from '../.commonwidgets/tabcontainer.js';
|
||||
import Todo from "../../services/todo.js";
|
||||
import { setupCursorHover } from '../.widgetutils/cursorhover.js';
|
||||
import { getString } from '../../i18n/i18n.js';
|
||||
|
||||
const TodoListItem = (task, id, isDone, isEven = false) => {
|
||||
const taskName = Widget.Label({
|
||||
@@ -108,7 +109,7 @@ const todoItems = (isDone) => Widget.Scrollable({
|
||||
className: 'txt txt-subtext',
|
||||
children: [
|
||||
MaterialIcon(`${isDone ? 'checklist' : 'check_circle'}`, 'gigantic'),
|
||||
Label({ label: `${isDone ? 'Finished tasks will go here' : 'Nothing here!'}` })
|
||||
Label({ label: `${isDone ? getString('Finished tasks will go here') : getString('Nothing here!')}` })
|
||||
]
|
||||
})
|
||||
]
|
||||
@@ -132,7 +133,7 @@ const UndoneTodoList = () => {
|
||||
className: 'txt-small sidebar-todo-new',
|
||||
halign: 'end',
|
||||
vpack: 'center',
|
||||
label: '+ New task',
|
||||
label: getString('+ New task'),
|
||||
setup: setupCursorHover,
|
||||
onClicked: (self) => {
|
||||
newTaskButton.revealChild = false;
|
||||
@@ -166,7 +167,7 @@ const UndoneTodoList = () => {
|
||||
// hexpand: true,
|
||||
vpack: 'center',
|
||||
className: 'txt-small sidebar-todo-entry',
|
||||
placeholderText: 'Add a task...',
|
||||
placeholderText: getString('Add a task...'),
|
||||
onAccept: ({ text }) => {
|
||||
if (text == '') return;
|
||||
Todo.add(text)
|
||||
@@ -216,7 +217,7 @@ const UndoneTodoList = () => {
|
||||
|
||||
export const TodoWidget = () => TabContainer({
|
||||
icons: ['format_list_bulleted', 'task_alt'],
|
||||
names: ['Unfinished', 'Done'],
|
||||
names: [getString('Unfinished'), getString('Done')],
|
||||
children: [
|
||||
UndoneTodoList(),
|
||||
todoItems(true),
|
||||
|
||||
Reference in New Issue
Block a user