Bug 2017903

Summary: [RFE] gnome-shell-extension-heads-up-display body from file
Product: Red Hat Enterprise Linux 9 Reporter: Pat Riehecky <riehecky>
Component: gnome-shell-extensionsAssignee: Ray Strode [halfline] <rstrode>
Status: ASSIGNED --- QA Contact: Michael Boisvert <mboisver>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: CentOS StreamCC: bstinson, jadahl, jkoten, jwboyer, misterbonnie, rstrode, tpelka, tpopela
Target Milestone: rcKeywords: FutureFeature, Triaged
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Pat Riehecky 2021-10-27 16:44:38 UTC
Description of problem:

Sites with required warning banners can use gnome-shell-extension-heads-up-display to set a notice.  However, this notice usually needs to be set in multiple places (/etc/issue.net, cockpit's login screen, etc).  If gnome-shell-extension-heads-up-display could read the body text from a known file, I could more easily keep them in sync.

Version-Release number of selected component (if applicable):


How reproducible:
100%

Steps to Reproduce:
1. Look for an easy way to de-dupe NOTICE TO USER messages with gnome-shell-extension-heads-up-display
2.
3.

Actual results:
Need to duplicate (and keep in sync) the message in multiple places

Expected results:
Way to centralize the "notice to users"

Additional info:

Comment 2 Ray Strode [halfline] 2021-12-06 19:35:23 UTC
Are you enabling the feature using the gnome-extensions settings ui? (the gnome-extensions-app command) ?

Assuming yes, you can actually configure this in a config file using dconf. For instance, by creating a file called

/etc/dconf/db/local.d/99-banner.conf

To know what to put in it, create a fresh user, go into the settings UI and enable the extension and set the message,
then run, 

$ dconf dump /

It will show all the settings the user has set that differ from defaults. In particular it could show, for example:

[org/gnome/shell/extensions]
enabled-extensions=['heads-up-display.github.com']

[org/gnome/shell/extensions/heads-up-display]
message-body='This machine is the property of the US Government.\n\nUnauthorized access is strictly prohibited.\n\nAbusers will be prosecuted to the fullest extent of the law.\n'
message-heading='CLASSIFIED SYSTEM'
show-when-locked=false
show-when-unlocked=true
show-when-unlocking=true

By putting that in /etc/dconf/db/local.d/99-banner.conf and running "dconf update" after making changes, the setting can be controlled from the file. 

You could imagine taking this a step further, by computing the setting from /etc/motd... Say with a script, update-message-banner.sh, like so:

#!/bin/bash
cat << EOF > "/etc/dconf/db/local.d/99-banner.conf"
[org/gnome/shell/extensions]
enabled-extensions=['heads-up-display.github.com']

[org/gnome/shell/extensions/heads-up-display]
message-heading="$(head -n1 /etc/motd)"
message-body="$(tail -n+2 /etc/motd | sed -z 's/\n/\\n/g')"
show-when-locked=true
show-when-unlocked=true
show-when-unlocking=true
EOF
dconf update

That script would take the first line of /etc/motd and put it in the heading and all other lines in the body of the banner.  Then you would just need to run "update-message-banner.sh" any time /etc/motd changes by running the script from systemd with a path monitoring unit. e.g., /etc/systemd/system/motd.path

[Unit] 
Wants=update-message-banner.service 

[Path] 
PathChanged=/etc/motd

and

/etc/systemd/system/update-message-banner.servce

[Service]  
Type=simple  
ExecStart=/usr/local/bin/update-message-banner.sh

Does that meet your needs?

If so great, let's close this out.

If not, I guess we could add some new setting "message-file" or "message-command" that makes it read from a file or run a command directly from within gnome-shell, but that setting would then conflict with message-header/message-body. We would have to establish a precedence or something like that to know which settings to honor and which to ignore if both the old ones and the new one are set.

The downside of reading it at runtime is it may require changes to SELinux policy to e.g. allow the login screen to read the file depending on which file is getting read.

Comment 3 Pat Riehecky 2021-12-07 14:17:15 UTC
Hello,

That comes close to what I'm looking for.  I might be able to tweak this into shape....

Ideally, a "message-file" with an inotify on the file would be much less setup.

Comment 4 Ray Strode [halfline] 2021-12-07 15:17:06 UTC
I guess we could make the precedence explicit by adding two new keys:

1. message-file
2. message-source

where the latter could be a string to say whether to honor message-file or message-header/message-body. 

Would you want the file format to be 

---
Heading
The message body goes here.
---

or

---
Heading

The message body goes here.
---

or something different? 

One concern I have is the nature of the banner (it's size, placement on screen, etc) means that not all messages are a good fit for it. By adding a file browser to the preferences dialog, the extension potentially makes it easy for the user to put a wall of text on their screen. Nothing catastrophic, but it's a bit of a UI niggle.

Comment 6 Pat Riehecky 2021-12-07 15:20:55 UTC
A format something like:

---
Heading

The message body goes here.
---

Would be great!

Comment 8 Ray Strode [halfline] 2022-02-23 14:56:46 UTC
I don't think this is going to make 9.0 at this point, proposing for a future update.