Bug 485146

Summary: kscreen-doctor output cannot be easily used in bash scripts anymore
Product: [I don't know] kde Reporter: Xwang <xwaang1976>
Component: generalAssignee: Unassigned bugs mailing-list <unassigned-bugs>
Status: RESOLVED NOT A BUG    
Severity: normal CC: fanzhuyifan
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Xwang 2024-04-06 18:50:06 UTC
SUMMARY
Kscreen-doctor -o output has changed in a way that makes it easier to read for a human, but more difficult to integrate in bash scripts.

Before I was able to get the names of external and internal monitors using these bash script lines:

TMP_EXT_MONITOR_NAME=$(kscreen-doctor -o | grep 'DisplayPort' | grep connected | cut -d ' ' -f 3)
TMP_INT_MONITOR_NAME=$(kscreen-doctor -o | grep 'Panel' | grep connected | cut -d ' ' -f 3)
echo "Internal monitor is: $TMP_INT_MONITOR_NAME"
echo "External monitor is: $TMP_EXT_MONITOR_NAME"

because each output information was in a single line.
Now the information of every monitor are split in multiple lines.

STEPS TO REPRODUCE
1.  Execute the four bash script lines above
2.  Read the displayed names

OBSERVED RESULT
It is not possible to read display names

EXPECTED RESULT
Before it was possible to read display names because all display nformations where on the same line

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.0.3
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.3
Kernel Version: 6.8.2-arch2-1 (64-bit)
Graphics Platform: Wayland
Processors: 12 × 12th Gen Intel® Core™ i5-1240U
Memory: 15.3 GiB of RAM
Graphics Processor: Mesa Intel® Graphics
Manufacturer: Dell Inc.
Product Name: Latitude 9330

ADDITIONAL INFORMATION
Is it possible to add a command line option to obtain the previous output format?
Comment 1 fanzhuyifan 2024-04-06 23:12:10 UTC
The -j option gives json output, which programs can handle easily.