forked from Shinonome/dots-hyprland
cheatsheet: switch on all monitors; add tab cycle (#637)
This commit is contained in:
@@ -217,6 +217,7 @@ let configOptions = {
|
|||||||
},
|
},
|
||||||
'nextTab': "Ctrl+Page_Down",
|
'nextTab': "Ctrl+Page_Down",
|
||||||
'prevTab': "Ctrl+Page_Up",
|
'prevTab': "Ctrl+Page_Up",
|
||||||
|
'cycleTab': "Ctrl+Tab",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,18 +118,26 @@ export default (id) => {
|
|||||||
clickCloseRegion({ name: 'cheatsheet' }),
|
clickCloseRegion({ name: 'cheatsheet' }),
|
||||||
],
|
],
|
||||||
setup: (self) => self.on('key-press-event', (widget, event) => { // Typing
|
setup: (self) => self.on('key-press-event', (widget, event) => { // Typing
|
||||||
|
// Whole sheet
|
||||||
if (checkKeybind(event, userOptions.keybinds.cheatsheet.nextTab))
|
if (checkKeybind(event, userOptions.keybinds.cheatsheet.nextTab))
|
||||||
sheetContents[id].nextTab();
|
sheetContents.forEach(tab => tab.nextTab())
|
||||||
else if (checkKeybind(event, userOptions.keybinds.cheatsheet.prevTab))
|
else if (checkKeybind(event, userOptions.keybinds.cheatsheet.prevTab))
|
||||||
sheetContents[id].prevTab();
|
sheetContents.forEach(tab => tab.prevTab())
|
||||||
|
else if (checkKeybind(event, userOptions.keybinds.cheatsheet.cycleTab))
|
||||||
|
sheetContents.forEach(tab => tab.cycleTab())
|
||||||
|
// Keybinds
|
||||||
if (sheets.attribute.names[sheets.attribute.shown.value] == 'Keybinds') { // If Keybinds tab is focused
|
if (sheets.attribute.names[sheets.attribute.shown.value] == 'Keybinds') { // If Keybinds tab is focused
|
||||||
if (checkKeybind(event, userOptions.keybinds.cheatsheet.keybinds.nextTab)) {
|
if (checkKeybind(event, userOptions.keybinds.cheatsheet.keybinds.nextTab)) {
|
||||||
const toSwitchTab = sheets.attribute.children[sheets.attribute.shown.value];
|
sheetContents.forEach((sheet) => {
|
||||||
toSwitchTab.nextTab();
|
const toSwitchTab = sheet.attribute.children[sheet.attribute.shown.value];
|
||||||
|
toSwitchTab.nextTab();
|
||||||
|
})
|
||||||
}
|
}
|
||||||
else if (checkKeybind(event, userOptions.keybinds.cheatsheet.keybinds.prevTab)) {
|
else if (checkKeybind(event, userOptions.keybinds.cheatsheet.keybinds.prevTab)) {
|
||||||
const toSwitchTab = sheets.attribute.children[sheets.attribute.shown.value];
|
sheetContents.forEach((sheet) => {
|
||||||
toSwitchTab.prevTab();
|
const toSwitchTab = sheet.attribute.children[sheet.attribute.shown.value];
|
||||||
|
toSwitchTab.prevTab();
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -75,14 +75,14 @@ const timeRow = Box({
|
|||||||
return execAsync(['bash', '-c', 'uptime']).then(output => {
|
return execAsync(['bash', '-c', 'uptime']).then(output => {
|
||||||
const uptimeRegex = /up\s+((\d+)\s+days?,\s+)?((\d+):(\d+)),/;
|
const uptimeRegex = /up\s+((\d+)\s+days?,\s+)?((\d+):(\d+)),/;
|
||||||
const matches = uptimeRegex.exec(output);
|
const matches = uptimeRegex.exec(output);
|
||||||
|
|
||||||
if (matches) {
|
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 hours = matches[4] ? parseInt(matches[4]) : 0;
|
||||||
const minutes = matches[5] ? parseInt(matches[5]) : 0;
|
const minutes = matches[5] ? parseInt(matches[5]) : 0;
|
||||||
|
|
||||||
let formattedUptime = '';
|
let formattedUptime = '';
|
||||||
|
|
||||||
if (days > 0) {
|
if (days > 0) {
|
||||||
formattedUptime += `${days} d `;
|
formattedUptime += `${days} d `;
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ const timeRow = Box({
|
|||||||
formattedUptime += `${hours} h `;
|
formattedUptime += `${hours} h `;
|
||||||
}
|
}
|
||||||
formattedUptime += `${minutes} m`;
|
formattedUptime += `${minutes} m`;
|
||||||
|
|
||||||
return formattedUptime;
|
return formattedUptime;
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Failed to parse uptime output');
|
throw new Error('Failed to parse uptime output');
|
||||||
@@ -98,7 +98,7 @@ const timeRow = Box({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.poll(5000, label => {
|
self.poll(5000, label => {
|
||||||
getUptime().then(upTimeString => {
|
getUptime().then(upTimeString => {
|
||||||
label.label = `Uptime: ${upTimeString}`;
|
label.label = `Uptime: ${upTimeString}`;
|
||||||
|
|||||||
Reference in New Issue
Block a user