summaryrefslogtreecommitdiff
path: root/archive/bin/develacc-please
blob: 63d86ecca68554a791b79e81417e782af68438f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh

# Boot or resume develacc and open a VNC viewer.  Suspend develacc,
# mainly to save battery power, when the viewer is closed.
#
# This is mainly for when I want to work in develacc for a while, full
# screen, almost as if my laptop was running sid.
#
# For work where I expect to be going back and forth between the VM
# and the bare metal host or other VMs, it might be better to access
# the VM via a normal, non-fullscreened virt-manager window rather
# than full screen virt-viewer.  Similarly if I have a large monitor
# available, it might be more convenient not to have the VM viewer
# fullscreened

set -e

. $HOME/.shenv

VIRSH="virsh --connect qemu:///system"
develacc="develacc.$(hostname -f)"

if wmctrl -l | grep -q "$develacc"; then
    wmctrl -a "$develacc"
else
    if $VIRSH list | grep -q "$develacc .*paused"; then
        $VIRSH resume $develacc
    elif ! $VIRSH list | grep -q $develacc; then
        $VIRSH start $develacc
    fi

    virt-viewer -c qemu:///system --hotkeys=release-cursor=ctrl+alt \
                -a -f -r $develacc # \
        # && $VIRSH suspend $develacc &
    until wmctrl -l | grep -q "$develacc"; do
        sleep 0.3
    done
    i3-fresh-workspace --take-along
fi