Linux Script to Save MS Word Doc and Close Wine?

Questions about Wine on Linux
Locked
jakfish
Level 2
Level 2
Posts: 11
Joined: Fri Jan 18, 2013 7:27 am

Linux Script to Save MS Word Doc and Close Wine?

Post by jakfish »

With a GPD Pocket 3 N6000, suspend/hibernation is a minefield of problems. In lieu, I'm looking at a timed shutdown, so I would need an initial script that would save/close a MS Word document, and gracefully close out Wine completely, before Arch went into general shutdown. Is there a Wine script that can automate this without user input?

I'm using up-to-date Manjaro/kernel 5.18.3./Wine 5.9/MS Word 97

Thanks,
Jake
jkfloris
Level 12
Level 12
Posts: 3141
Joined: Thu Aug 14, 2014 10:10 am

Re: Linux Script to Save MS Word Doc and Close Wine?

Post by jkfloris »

There is no ready-made script that will save a Word file, close Word, and close Wine.
However, I can provide some tips that can get you started.
Winetricks uses AutoHotkey to automatically install and exit Windows programs.
This program should also allow you to close Word and save a file.

You can close Wine in the following way:
wineserver -k This will kill all wine processes
jakfish
Level 2
Level 2
Posts: 11
Joined: Fri Jan 18, 2013 7:27 am

Re: Linux Script to Save MS Word Doc and Close Wine?

Post by jakfish »

Thank you for your quick response. I've been fumbling my way trying to make this script:

Code: Select all

#!/bin/sh
wmctrl -a "Microsoft Word"
sleep .2
xdotool keydown 0xffea + key 4
xdotool keyup 0xffea
xdotool key y
It seems to work okay so far to save a Word doc, then close, but I need to tie it to an xprintidle script, setting the timer, then calling the script above, then shutting down cleanly. I'm not familiar with xprintidle...

Thanks again for posting.
jakfish
Level 2
Level 2
Posts: 11
Joined: Fri Jan 18, 2013 7:27 am

Re: Linux Script to Save MS Word Doc and Close Wine?

Post by jakfish »

This appears to work, so far. It's primitive, but clean, and if there's anything good in it, the work belongs to other people ( https://askubuntu.com/questions/442795/ ... being-idle )

Code: Select all

#!/bin/bash
idletime=$((15*60*1000)) # 15 min in milliseconds
idle=0

while [ $idle -lt $idletime ];do
    idle=`xprintidle`
    sleep 1
done
/home/jake/Scripts_Icons/Word_Shutdown # calling the Word save/close script listed in previous post
sleep 5
sudo shutdown -P now
Locked