mirror of
https://github.com/danbulant/dots-hyprland
synced 2026-05-24 12:22:09 +00:00
sway workspace switching
This commit is contained in:
parent
830f6a780d
commit
f14d3146db
3 changed files with 27 additions and 8 deletions
19
.config/ags/scripts/sway/swayToRelativeWs.sh
Executable file
19
.config/ags/scripts/sway/swayToRelativeWs.sh
Executable file
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Get the current workspace number
|
||||||
|
current=$(swaymsg -t get_workspaces | gojq '.[] | select(.focused==true) | .num')
|
||||||
|
|
||||||
|
# Check if a number was passed as an argument
|
||||||
|
if [[ "$1" =~ ^[+-]?[0-9]+$ ]]; then
|
||||||
|
new_workspace=$((current + $1))
|
||||||
|
else
|
||||||
|
new_workspace=$((current + 1))
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if the new workspace number is out of bounds
|
||||||
|
if [[ $new_workspace -lt 1 ]]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Switch to the new workspace
|
||||||
|
swaymsg workspace $new_workspace
|
||||||
|
|
@ -32,12 +32,12 @@ const TrackProgress = () => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const moveToRelativeWorkspace = async (self, num) => {
|
const switchToRelativeWorkspace = async (self, num) => {
|
||||||
try {
|
try {
|
||||||
const Hyprland = (await import('resource:///com/github/Aylur/ags/service/hyprland.js')).default;
|
const Hyprland = (await import('resource:///com/github/Aylur/ags/service/hyprland.js')).default;
|
||||||
Hyprland.sendMessage(`dispatch workspace ${num > 0 ? '+' : ''}${num}`);
|
Hyprland.sendMessage(`dispatch workspace ${num > 0 ? '+' : ''}${num}`);
|
||||||
} catch {
|
} catch {
|
||||||
console.log(`TODO: Sway workspace ${num > 0 ? '+' : ''}${num}`);
|
execAsync([`${App.configDir}/scripts/sway/swayToRelativeWs.sh`, `${num}`]).catch(print);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,8 +85,8 @@ export default () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
return Widget.EventBox({
|
return Widget.EventBox({
|
||||||
onScrollUp: (self) => moveToRelativeWorkspace(self, -1),
|
onScrollUp: (self) => switchToRelativeWorkspace(self, -1),
|
||||||
onScrollDown: (self) => moveToRelativeWorkspace(self, +1),
|
onScrollDown: (self) => switchToRelativeWorkspace(self, +1),
|
||||||
onPrimaryClickRelease: () => showMusicControls.setValue(!showMusicControls.value),
|
onPrimaryClickRelease: () => showMusicControls.setValue(!showMusicControls.value),
|
||||||
onSecondaryClickRelease: () => execAsync(['bash', '-c', 'playerctl next || playerctl position `bc <<< "100 * $(playerctl metadata mpris:length) / 1000000 / 100"` &']),
|
onSecondaryClickRelease: () => execAsync(['bash', '-c', 'playerctl next || playerctl position `bc <<< "100 * $(playerctl metadata mpris:length) / 1000000 / 100"` &']),
|
||||||
onMiddleClickRelease: () => execAsync('playerctl play-pause').catch(print),
|
onMiddleClickRelease: () => execAsync('playerctl play-pause').catch(print),
|
||||||
|
|
|
||||||
|
|
@ -167,18 +167,18 @@ const BarGroup = ({ child }) => Widget.Box({
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
const moveToRelativeWorkspace = async (self, num) => {
|
const switchToRelativeWorkspace = async (self, num) => {
|
||||||
try {
|
try {
|
||||||
const Hyprland = (await import('resource:///com/github/Aylur/ags/service/hyprland.js')).default;
|
const Hyprland = (await import('resource:///com/github/Aylur/ags/service/hyprland.js')).default;
|
||||||
Hyprland.sendMessage(`dispatch workspace ${num > 0 ? '+' : ''}${num}`);
|
Hyprland.sendMessage(`dispatch workspace ${num > 0 ? '+' : ''}${num}`);
|
||||||
} catch {
|
} catch {
|
||||||
console.log(`TODO: Sway workspace ${num > 0 ? '+' : ''}${num}`);
|
execAsync([`${App.configDir}/scripts/sway/swayToRelativeWs.sh`, `${num}`]).catch(print);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default () => Widget.EventBox({
|
export default () => Widget.EventBox({
|
||||||
onScrollUp: (self) => moveToRelativeWorkspace(self, -1),
|
onScrollUp: (self) => switchToRelativeWorkspace(self, -1),
|
||||||
onScrollDown: (self) => moveToRelativeWorkspace(self, +1),
|
onScrollDown: (self) => switchToRelativeWorkspace(self, +1),
|
||||||
onPrimaryClick: () => App.toggleWindow('sideright'),
|
onPrimaryClick: () => App.toggleWindow('sideright'),
|
||||||
child: Widget.Box({
|
child: Widget.Box({
|
||||||
className: 'spacing-h-5',
|
className: 'spacing-h-5',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue