session: logout grab focus on open
This commit is contained in:
parent
76ded7bb6d
commit
9c3c59fb33
1 changed files with 13 additions and 4 deletions
|
|
@ -1,10 +1,19 @@
|
||||||
import { execAsync } from "astal";
|
import { execAsync } from "astal";
|
||||||
import { Astal, Gtk } from "astal/gtk3";
|
import { App, Astal, Gtk } from "astal/gtk3";
|
||||||
import PopupWindow from "../widgets/popupwindow";
|
import PopupWindow from "../widgets/popupwindow";
|
||||||
|
|
||||||
const Item = ({ icon, label, cmd }: { icon: string; label: string; cmd: string }) => (
|
const Item = ({ icon, label, cmd, isDefault }: { icon: string; label: string; cmd: string; isDefault?: boolean }) => (
|
||||||
<box vertical className="item">
|
<box vertical className="item">
|
||||||
<button cursor="pointer" onClicked={() => execAsync(cmd).catch(console.error)}>
|
<button
|
||||||
|
cursor="pointer"
|
||||||
|
onClicked={() => execAsync(cmd).catch(console.error)}
|
||||||
|
setup={self =>
|
||||||
|
isDefault &&
|
||||||
|
self.hook(App, "window-toggled", (_, window) => {
|
||||||
|
if (window.name === "session" && window.visible) self.grab_focus();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
<label className="icon" label={icon} />
|
<label className="icon" label={icon} />
|
||||||
</button>
|
</button>
|
||||||
<label className="label" label={label} />
|
<label className="label" label={label} />
|
||||||
|
|
@ -22,7 +31,7 @@ export default () => (
|
||||||
>
|
>
|
||||||
<box vertical halign={Gtk.Align.CENTER} valign={Gtk.Align.CENTER} className="inner">
|
<box vertical halign={Gtk.Align.CENTER} valign={Gtk.Align.CENTER} className="inner">
|
||||||
<box>
|
<box>
|
||||||
<Item icon="logout" label="Logout" cmd="uwsm stop" />
|
<Item icon="logout" label="Logout" cmd="uwsm stop" isDefault />
|
||||||
<Item icon="cached" label="Reboot" cmd="systemctl reboot" />
|
<Item icon="cached" label="Reboot" cmd="systemctl reboot" />
|
||||||
</box>
|
</box>
|
||||||
<box>
|
<box>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue