LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-27-2024, 12:34 PM   #1
floppy_stuttgart
Senior Member
 
Registered: Nov 2010
Location: EU mainland
Distribution: Debian like
Posts: 1,155
Blog Entries: 5

Rep: Reputation: 107Reputation: 107
HowTo open a terminal for output in Debian11 Gnome?


Hello,

I created an icon on my gnome desktop which start the script below: showing the RAM usage.
So far after clicking the icon, a window open but there is a message coming up: I have to click 3x time on "restart" = "Erneut starten" before I could see the message "RAM usage..". (see attachment) because it is probably hidden behind the message "Der Kindprozess..".

Any proposal HowTo delete this message "Der Kindprozess.." is welcome.

Code:
#! /bin/bash
THRESHOLD=5  # Set your desired threshold percentage
# https://www.inmotionhosting.com/support/server/linux/check-memory-usage/
RAM=$(free | awk '/Speicher/{printf("%.2f"), $3/$2*100}')
if [ $(echo "$RAM > $THRESHOLD" | bc) -eq 1 ]; then
    gnome-terminal --window-with-profile=RAM --command "echo 'RAM usage is above $THRESHOLD% - Current usage: $RAM%'" --geometry=50x10
fi
Attached Thumbnails
Click image for larger version

Name:	Bildschirmfoto vom 2024-04-27 19-26-52.png
Views:	5
Size:	15.8 KB
ID:	42736  

Last edited by floppy_stuttgart; 04-27-2024 at 02:05 PM.
 
Old 04-27-2024, 02:29 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,746

Rep: Reputation: 5925Reputation: 5925Reputation: 5925Reputation: 5925Reputation: 5925Reputation: 5925Reputation: 5925Reputation: 5925Reputation: 5925Reputation: 5925Reputation: 5925
I would just use Terminal=True in my desktop shortcut and then instead starting another terminal I would use:
Quote:
echo "RAM usage is above $THRESHOLD% - Current usage: $RAM%"
read -p "Press enter to exit ..."
Granted you get the default window size.

However, to fix your problem:
Code:
gnome-terminal --geometry=50x10  -- bash -c "echo 'RAM usage is above $THRESHOLD% - Current usage: $RAM%'; exec bash"

Last edited by michaelk; 04-27-2024 at 06:53 PM.
 
1 members found this post helpful.
Old 04-28-2024, 05:20 AM   #3
floppy_stuttgart
Senior Member
 
Registered: Nov 2010
Location: EU mainland
Distribution: Debian like
Posts: 1,155

Original Poster
Blog Entries: 5

Rep: Reputation: 107Reputation: 107
Outstanding proposal.
My last improved version is below:
- click on an icon on the gnome desktop (which execute this script; .desktop file in the bottom of the message),
- a window pop up,
- it stay open for 30s,
- then it goes alone away (no need to close or further act).

executable script check_ram.sh
Quote:
#! /bin/bash
THRESHOLD=5 # Set your desired threshold percentage
# https://www.inmotionhosting.com/supp...-memory-usage/
RAM=$(free | awk '/Speicher/{printf("%.2f"), $3/$2*100}')
if [ $(echo "$RAM > $THRESHOLD" | bc) -eq 1 ]; then
gnome-terminal --geometry=50x10 -- bash -c "echo 'RAM usage is above $THRESHOLD% - Current usage: $RAM%'; sleep 30; exit; exec bash"
fi
file RAM.desktop in /home/userX/Schreibtisch
Quote:
[Desktop Entry]
Name=RAM check
Comment=this is an icon for checking the RAM use
Exec=bash /home/userX/pc_issues/RAM/check_ram.sh
Type=Application
Terminal=false
Icon=/home/userX/pc_issues/RAM/ram.jpeg

UPDATE (added: indication of the used swap in a new line)

Quote:
#! /bin/bash
THRESHOLD=5 # Set your desired threshold percentage
RAM=$(free | awk '/Speicher/{printf("%.1f"), $3/$2*100}')
SWAP=$(free | awk '/Speicher/{printf("%.0f"), $8}')
if [ $(echo "$RAM > $THRESHOLD" | bc) -eq 1 ]; then
gnome-terminal --geometry=63x5 -- bash -c "echo 'RAM usage is above $THRESHOLD% - Current usage: $RAM%' ; printf %b '\n' ; echo 'SWAP used: $SWAP'; sleep 15; exit; exec bash"
fi

Last edited by floppy_stuttgart; 05-06-2024 at 10:24 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
GNOME screen recording: how to start it in Debian11 GNOME ? floppy_stuttgart Debian 2 01-29-2024 03:34 AM
HowTo install H.264 on Debian11 (Firefox) for running WebEx? floppy_stuttgart Linux - Newbie 3 11-14-2022 04:42 AM
How to define a new position of icons on Debian11 GNOME? floppy_stuttgart Debian 0 04-25-2022 05:51 PM
[SOLVED] Not able to install Debian11 Camello Linux - Newbie 5 08-22-2021 07:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration