# Detect project update from client in notify mode

**URL:** <https://forum.inductiveautomation.com/t/detect-project-update-from-client-in-notify-mode/21424>\
**Category:** Ignition\
**Tags:** scripting, ignition79\
**Created:** [December 14, 2018, 3:53pm UTC](https://forum.inductiveautomation.com/t/detect-project-update-from-client-in-notify-mode/21424 "2018-12-14T15:53:38Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [December 14, 2018, 9:57pm UTC](https://forum.inductiveautomation.com/t/detect-project-update-from-client-in-notify-mode/21424/10 "2018-12-14T21:57:50Z")

</div>

Works as desired; thanks! In case it helps someone else, the below updates on idle, re-opening all the windows that were open in the primary desktop after updating. It also prints a line to client console recording update.

Script in shared.gui (edit: improved with @cmaynes suggestion in following post):

```auto
from com.inductiveautomation.factorypmi.application.runtime import UpdateAvailableInfoBar

# Is an update available for client?
def getUpdateNotification(obj):
	result = False
	for sub in obj.getComponents():
		#print "*"*10, type(sub)
		if not result:
			if isinstance(sub,UpdateAvailableInfoBar):
				return True
			else:
				result = getUpdateNotification(sub)			
	return result

```

Script in client event timer script:

```python
from javax.swing import SwingUtilities

# If client has been inactive for an hour, check for update.
if system.util.getInactivitySeconds() > 3600:
	# Get windows in main desktop where notification is shown.
	windows = system.gui.getOpenedWindows()
	# Get root of first window.
	root = SwingUtilities.getRoot(windows[0])
	# If there's an update notification, update client.
	if shared.gui.getUpdateNotification(root):
		# Get project name and opened windows.
		print "Found update notification info bar while idle. Updating client."
		projectName = system.tag.read('[System]Client/System/ProjectName').value
		openWindows = system.gui.getOpenedWindowNames()
		# Update by retargeting back to same project and open same windows.
		system.util.retarget(projectName, None, None, openWindows)

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/detect-project-update-from-client-in-notify-mode/21424)._
