Xfce Forum

Sub domains
 

You are not logged in.

#26 2019-12-26 12:54:14

alcornoqui
Member
Registered: 2014-07-28
Posts: 831

Re: No "Ask" at set critical power level. [Solved]

makem wrote:

All I need now is an audible warning of impending loss of data but having looked around I find that there is not an easy solution.

I wouldn't call it an easy solution, but with the info in the answers here you can probably get what you want: How can I get an alert when my battery is about to die in Linux Mint?

Offline

#27 2019-12-26 12:58:31

makem
Member
Registered: 2019-12-25
Posts: 36

Re: No "Ask" at set critical power level. [Solved]

alcornoqui wrote:
makem wrote:

All I need now is an audible warning of impending loss of data but having looked around I find that there is not an easy solution.

I wouldn't call it an easy solution, but with the info in the answers here you can probably get what you want: How can I get an alert when my battery is about to die in Linux Mint?

Yes, I read that when I was looking for an audible solution and agree, it is not easy, for me anyway.

Offline

#28 2019-12-26 14:01:33

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: No "Ask" at set critical power level. [Solved]

Here is a similar script with instructions (includes both a sound and bubble notification) geared towards your system. Create the file batteryalert.sh in your home directory with the following content:

#!/bin/bash

lockfile=/tmp/.batteryalert.$USER.lockfile
if ( set -o noclobber; echo "locked" > "$lockfile") 2> /dev/null; then
  	trap 'rm -f "$lockfile"; exit $?' INT TERM EXIT
  	echo "batteryalertDEBUG: Locking succeeded" >&2

	while true
	do
		sleep 15s
		P=$(upower -d | grep -A20 BAT1 | grep percentage | awk '{print $2 }' | sed -e 's/%//g')
		if [ $P -lt 10 ];
		then
			notify-send -i dialog-warning "Battery Low Warning" "The battery is below 10% charge!"
			mplayer /usr/share/sounds/freedesktop/stereo/alarm-clock-elapsed.oga > /dev/null 2>&1
		fi
	done
	
else
  	echo "batteryalertDEBUG: Lock failed, check for existing process and/or lock file and delete - exiting." >&2
  	exit 1
fi			

exit 0

...and make the file executable:

chmod +x ~/batteryalert.sh

Note: I'm using mplayer to play the sound. Either make sure that mplayer is installed or change the command to use another program to play the sound.

Then create the file ~/.config/autostart/batteryalert.desktop with the following content:

[Desktop Entry]
Encoding=UTF-8
Version=0.9.4
Type=Application
Name=batteryalert
Comment=batteryalert
Exec=/home/makem/batteryalert.sh
OnlyShowIn=XFCE;
StartupNotify=false
Terminal=false
Hidden=false

The next time you log in, this script will start and you will get an audible and visual alert every 15 seconds when the battery drops below 10% charge.

Last edited by ToZ (2019-12-26 15:14:00)


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#29 2019-12-26 14:32:52

alcornoqui
Member
Registered: 2014-07-28
Posts: 831

Re: No "Ask" at set critical power level. [Solved]

Am I evil if I admit that I planned this? [evil grim]

Thank you ToZ, gonna use it myself!

Offline

#30 2019-12-26 14:51:06

makem
Member
Registered: 2019-12-25
Posts: 36

Re: No "Ask" at set critical power level. [Solved]

@ToZ

That appears to be a script I saw when looking around for something.

Thank you, I can do that with your instructions.

Offline

#31 2019-12-26 14:58:46

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: No "Ask" at set critical power level. [Solved]

alcornoqui wrote:

Am I evil if I admit that I planned this? [evil grim]

Thank you ToZ, gonna use it myself!

lol. Make sure you change the "BAT1" in the script to be your actual battery device name (mine is BAT0).


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#32 2019-12-26 15:05:59

makem
Member
Registered: 2019-12-25
Posts: 36

Re: No "Ask" at set critical power level. [Solved]

@ToZ

ToZ wrote:

...and make the file executable:

chmod +x ~/batteryalert

Should read:

chmod +x ~/batteryalert.sh

Right?

Where do I find battery name?

Ah, it is battery_BAT1 big_smile

Last edited by makem (2019-12-26 15:11:49)

Offline

#33 2019-12-26 15:13:36

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: No "Ask" at set critical power level. [Solved]

Yes, thanks. I'll edit my post.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#34 2019-12-26 15:16:37

makem
Member
Registered: 2019-12-25
Posts: 36

Re: No "Ask" at set critical power level. [Solved]

ToZ wrote:

Yes, thanks. I'll edit my post.

You are most welcome.

You have:

P=$(upower -d | grep -A20 BAT1 | grep percentage | awk '{print $2 }' | se$

Is the -A20 part of the battery name or a command? I think command. (will read the upower man)

My battery name includes a 'battery_' prefix to the BAT1

Last edited by makem (2019-12-26 15:23:24)

Offline

#35 2019-12-26 15:24:05

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: No "Ask" at set critical power level. [Solved]

The "-A 20" means return 20 lines after the match to BAT1 (you will only have one of this string in that output). Included in those 20 lines is the percentage line so I clumsily pull that out using greps, awks and seds. The prefix is not important here.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#36 2019-12-26 17:24:34

makem
Member
Registered: 2019-12-25
Posts: 36

Re: No "Ask" at set critical power level. [Solved]

I have VLC media player installed and also installed mplayer to align with the script.

I get the popup warning along with what appears to be two sounds. One a very quiet tapping and the other like a very quiet squeak. I think that sound is being played by VLC because I can choose that player to play the file alarm-clock-elapsed.oga.

If I choose from the command line mplayer alarm-clock-elapsed.oga I get a file not found error.

As far as I am aware the command is mplayer foo.mp3 so I am surprised it does not play the alarm. Can you enlighten me please?

Better still, how to edit the script to use vlc?

Last edited by makem (2019-12-26 17:26:22)

Offline

#37 2019-12-26 18:46:50

alcornoqui
Member
Registered: 2014-07-28
Posts: 831

Re: No "Ask" at set critical power level. [Solved]

makem wrote:

Better still, how to edit the script to use vlc?

Substitute "mplayer" for "cvlc" in the script.

Offline

#38 2019-12-26 19:02:52

makem
Member
Registered: 2019-12-25
Posts: 36

Re: No "Ask" at set critical power level. [Solved]

alcornoqui wrote:
makem wrote:

Better still, how to edit the script to use vlc?

Substitute "mplayer" for "cvlc" in the script.

Sorry, I think you refer to a post in which I substituted cvlc for mplayer because the sound was very quiet and I normally use vlc media player.

I want to use cvlc.

I found that the usual system popup triggered at !0% and stopped me doing anything except answer it. I thought the script was a replacement for that and therefore assumed the script did not work. However, during the changes I made I found that the script sound triggered below and after the system popup. So, now I know the script works but need to change it to a value greater than 10% I think. In that way the script will audibly warn me and if I fail to action that the system popup will save any data loss if I fail to heed that too.

As it currently stands the system will save data and shut down before the script works I think.

Last edited by makem (2019-12-26 20:01:03)

Offline

#39 2019-12-26 20:17:49

makem
Member
Registered: 2019-12-25
Posts: 36

Re: No "Ask" at set critical power level. [Solved]

Replacing mplayer with cvlc works and the sound level is that set by the system.

I left the script setting at 10% and set the system to 8%.

However, I think using cvlc stops the script which hangs after it only triggers once.

When I use cvlc from the command line I get:

makem@ssdTOSH:~$ cvlc /home/makem/Desktop/fart.wav
VLC media player 3.0.8 Vetinari (revision 3.0.8-0-gf350b6b5a7)
[0000559c5c0698c0] dummy interface: using the dummy interface module...

The terminal hangs at that point having played the sound. This must also be happening in the script.

Offline

#40 2019-12-26 23:44:54

makem
Member
Registered: 2019-12-25
Posts: 36

Re: No "Ask" at set critical power level. [Solved]

Using xubuntu (ubuntu 18.04.3 LTS) with XFCE desktop and having uninstalled the xfce4-battery-plugin, leaving only the xfce4-power-manager installed.

For me this edited script (mplayer replaced by aplay) works correctly with the system critical power setting at 8%:

#!/bin/bash

lockfile=/tmp/.batteryalert.$USER.lockfile
if ( set -o noclobber; echo "locked" > "$lockfile") 2> /dev/null; then
        trap 'rm -f "$lockfile"; exit $?' INT TERM EXIT
        echo "batteryalertDEBUG: Locking succeeded" >&2

        while true
        do
                sleep 15s
                P=$(upower -d | grep -A20 battery_BAT1 | grep percentage | awk '{print $2 }' | sed -e 's/%//g')
                if [ $P -lt 10 ];
                then
                        notify-send -i dialog-warning "Battery Low Warning" "The battery is below 10% charge!"
                        aplay /media/WinData/windows/myprofile/Music/SndFiles/44MAGNUM.WAV > /dev/null 2>&1
                fi
        done

else
        echo "batteryalertDEBUG: Lock failed, check for existing process and/or lock file and delete - exiting." >&2
        exit 1
fi

exit 0

Thank you all for the help.

Marked as solved.

Last edited by makem (2019-12-26 23:54:21)

Offline

#41 2019-12-27 00:59:37

makem
Member
Registered: 2019-12-25
Posts: 36

Re: No "Ask" at set critical power level. [Solved]

Aravisian wrote:

Missed seeing this earlier:

makem wrote:

Can you explain how to do that please? I cannot understand what to do from the man xmodmap

The xmodmap file is used if you want to reassign the keyboard key values. For example, if you want the ctrl key to be caps lock and caps lock to be ctrl key. Or if you want Tab key to be an Enter key on the left side of the keyboard.
From your error log:

xmodmap:  /home/makem/.Xmodmap:1:  bad value "3  given for buttons list
xmodmap:  1 error encountered, aborting.

I swapped mouse button 3 and 1 to make my mouse left handed using the system Mouse and Touchpad Buttons setting. I had forgotten that some while ago I did that via xinput:

makem@ssdTOSH:~$ xinput --set-button-map 10 3 2 1
makem@ssdTOSH:~$

The file .Xmodmap in my home folder contains:

pointer = "3 2 1"

That file is dated 11/10/17 and as I always save my home folder between OS installs, that is probably when I first made the change using xinput. The entry in .Xmodmap is made by the system as far as I am aware so it added the quotes before and after "3 2 1". I have never done that.

I wonder if that is causing the error and if so I don't see how it can be corrected. If it works don't mess with it perhaps lol

Offline

#42 2019-12-27 01:15:13

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: No "Ask" at set critical power level. [Solved]

makem wrote:

I wonder if that is causing the error and if so I don't see how it can be corrected. If it works don't mess with it perhaps lol

The file is not being processed when it encounters this error. If there are any other settings in that file they are not being processed. If everything is working fine now, try renaming the file and re-logging in to see if there is any change.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#43 2019-12-27 09:12:05

makem
Member
Registered: 2019-12-25
Posts: 36

Re: No "Ask" at set critical power level. [Solved]

ToZ wrote:
makem wrote:

I wonder if that is causing the error and if so I don't see how it can be corrected. If it works don't mess with it perhaps lol

The file is not being processed when it encounters this error. If there are any other settings in that file they are not being processed. If everything is working fine now, try renaming the file and re-logging in to see if there is any change.

makem@ssdTOSH:~$ mv /home/makem/.Xmodmap .Xmodmap_bak
makem@ssdTOSH:~$

Output of .xsession-errors

makem@ssdTOSH:~$ cat /home/makem/.xsession-errors
dbus-update-activation-environment: setting DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
dbus-update-activation-environment: setting DISPLAY=:0
dbus-update-activation-environment: setting XAUTHORITY=/home/makem/.Xauthority
dbus-update-activation-environment: setting QT_ACCESSIBILITY=1
dbus-update-activation-environment: setting LANG=en_GB.UTF-8
dbus-update-activation-environment: setting GDM_LANG=en_GB
dbus-update-activation-environment: setting DISPLAY=:0
dbus-update-activation-environment: setting GTK_OVERLAY_SCROLLING=0
dbus-update-activation-environment: setting PAM_KWALLET5_LOGIN=/run/user/1000/kwallet5.socket
dbus-update-activation-environment: setting MANDATORY_PATH=/usr/share/gconf/xubuntu.mandatory.path
dbus-update-activation-environment: setting XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/makem
dbus-update-activation-environment: setting USER=makem
dbus-update-activation-environment: setting DESKTOP_SESSION=xubuntu
dbus-update-activation-environment: setting DEFAULTS_PATH=/usr/share/gconf/xubuntu.default.path
dbus-update-activation-environment: setting QT_QPA_PLATFORMTHEME=gtk2
dbus-update-activation-environment: setting PWD=/home/makem
dbus-update-activation-environment: setting HOME=/home/makem
dbus-update-activation-environment: setting QT_ACCESSIBILITY=1
dbus-update-activation-environment: setting XDG_SESSION_TYPE=x11
dbus-update-activation-environment: setting XDG_DATA_DIRS=/usr/share/xubuntu:/usr/share/xfce4:/usr/local/share:/usr/share:/var/lib/snapd/desktop:/var/lib/snapd/desktop
dbus-update-activation-environment: setting XDG_SESSION_DESKTOP=xubuntu
dbus-update-activation-environment: setting CLUTTER_BACKEND=x11
dbus-update-activation-environment: setting SHELL=/bin/bash
dbus-update-activation-environment: setting XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
dbus-update-activation-environment: setting IM_CONFIG_PHASE=1
dbus-update-activation-environment: setting GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1
dbus-update-activation-environment: setting SHLVL=1
dbus-update-activation-environment: setting LANGUAGE=en_GB:en
dbus-update-activation-environment: setting GDMSESSION=xubuntu
dbus-update-activation-environment: setting LOGNAME=makem
dbus-update-activation-environment: setting DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
dbus-update-activation-environment: setting XDG_RUNTIME_DIR=/run/user/1000
dbus-update-activation-environment: setting XAUTHORITY=/home/makem/.Xauthority
dbus-update-activation-environment: setting XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session1
dbus-update-activation-environment: setting XDG_CONFIG_DIRS=/etc/xdg/xdg-xubuntu:/etc/xdg:/usr/share/kubuntu-default-settings/kf5-settings
dbus-update-activation-environment: setting PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/makem/Android/Sdk/platform-tools/:/snap/bin
dbus-update-activation-environment: setting _=/usr/bin/dbus-update-activation-environment
Connecting to deprecated signal QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)
QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
QDBusConnection: name 'org.a11y.atspi.Registry' had owner '' but we thought it was ':1.18'
kbuildsycoca4 running...
kbuildsycoca4(3062) KBuildSycoca::checkTimestamps: checking file timestamps
kbuildsycoca4(3062) KBuildSycoca::checkTimestamps: timestamps check ok
kbuildsycoca4(3062) kdemain: Emitting notifyDatabaseChanged ()

(xfce4-session:3039): xfce4-session-WARNING **: 09:03:51.788: Unable to launch "~/.chromecache" (specified by autostart/Chrome Cache.desktop): Failed to execute child process “~/.chromecache” (No such file or directory)
batteryalertDEBUG: Lock failed, check for existing process and/or lock file and delete - exiting.
Unable to run: daemon: Resource temporarily unavailablelibxfce4panel-Message: 09:03:51.819: Failed to load image "/usr/share/icons/hicolor/48x48/apps/vncviewer48x48.png": Failed to open file '/usr/share/icons/hicolor/48x48/apps/vncviewer48x48.png': No such file or directory

(xfce4-session:3039): xfce4-session-WARNING **: 09:03:52.038: Unable to launch "/usr/lib/x86_64-linux-gnu/libexec/kdeconnectd" (specified by autostart/kdeconnectd.desktop): Failed to execute child process “/usr/lib/x86_64-linux-gnu/libexec/kdeconnectd” (No such file or directory)

(wrapper-2.0:3079): Gtk-WARNING **: 09:03:52.088: Negative content width -3 (allocation 1, extents 2x2) while allocating gadget (node button, owner GtkToggleButton)

(wrapper-2.0:3083): Gtk-WARNING **: 09:03:52.103: Theme parsing error: <data>:1:46: The style property GtkWidget:focus-padding is deprecated and shouldn't be used anymore. It will be removed in a future version

(wrapper-2.0:3083): Gtk-WARNING **: 09:03:52.104: Theme parsing error: <data>:1:78: The style property GtkWidget:focus-line-width is deprecated and shouldn't be used anymore. It will be removed in a future version

(wrapper-2.0:3083): Gtk-WARNING **: 09:03:52.104: Theme parsing error: <data>:1:108: The style property GtkButton:default-border is deprecated and shouldn't be used anymore. It will be removed in a future version

(wrapper-2.0:3083): Gtk-WARNING **: 09:03:52.104: Theme parsing error: <data>:1:136: The style property GtkButton:inner-border is deprecated and shouldn't be used anymore. It will be removed in a future version

(wrapper-2.0:3083): Gtk-WARNING **: 09:03:52.290: Theme parsing error: <data>:1:46: The style property GtkWidget:focus-padding is deprecated and shouldn't be used anymore. It will be removed in a future version

(wrapper-2.0:3083): Gtk-WARNING **: 09:03:52.290: Theme parsing error: <data>:1:78: The style property GtkWidget:focus-line-width is deprecated and shouldn't be used anymore. It will be removed in a future version

(wrapper-2.0:3083): Gtk-WARNING **: 09:03:52.290: Theme parsing error: <data>:1:108: The style property GtkButton:default-border is deprecated and shouldn't be used anymore. It will be removed in a future version

(wrapper-2.0:3083): Gtk-WARNING **: 09:03:52.290: Theme parsing error: <data>:1:136: The style property GtkButton:inner-border is deprecated and shouldn't be used anymore. It will be removed in a future version

(polkit-gnome-authentication-agent-1:3185): GLib-CRITICAL **: 09:03:52.429: g_variant_new_string: assertion 'string != NULL' failed

(polkit-gnome-authentication-agent-1:3185): polkit-gnome-1-WARNING **: 09:03:52.432: Failed to register client: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files

** (xfdesktop:3073): WARNING **: 09:03:52.492: Failed to set the background '/home/makem/Desktop/New Folder/scene01400.jpg': GDBus.Error:org.freedesktop.Accounts.Error.Failed: file '/home/makem/Desktop/New Folder/scene01400.jpg' is not a regular file

(nm-applet:3129): Gtk-WARNING **: 09:03:52.722: Can't set a parent on widget which has a parent

(wrapper-2.0:3083): Gtk-WARNING **: 09:03:52.850: Theme parsing error: <data>:1:46: The style property GtkWidget:focus-padding is deprecated and shouldn't be used anymore. It will be removed in a future version

(wrapper-2.0:3083): Gtk-WARNING **: 09:03:52.850: Theme parsing error: <data>:1:78: The style property GtkWidget:focus-line-width is deprecated and shouldn't be used anymore. It will be removed in a future version

(wrapper-2.0:3083): Gtk-WARNING **: 09:03:52.850: Theme parsing error: <data>:1:108: The style property GtkButton:default-border is deprecated and shouldn't be used anymore. It will be removed in a future version

(wrapper-2.0:3083): Gtk-WARNING **: 09:03:52.850: Theme parsing error: <data>:1:136: The style property GtkButton:inner-border is deprecated and shouldn't be used anymore. It will be removed in a future version

(nm-applet:3129): Gtk-CRITICAL **: 09:03:53.194: gtk_widget_destroy: assertion 'GTK_IS_WIDGET (widget)' failed

(nm-applet:3129): Gtk-CRITICAL **: 09:03:53.194: gtk_widget_destroy: assertion 'GTK_IS_WIDGET (widget)' failed

(wrapper-2.0:3083): Gtk-WARNING **: 09:03:53.240: Theme parsing error: <data>:1:46: The style property GtkWidget:focus-padding is deprecated and shouldn't be used anymore. It will be removed in a future version

(wrapper-2.0:3083): Gtk-WARNING **: 09:03:53.240: Theme parsing error: <data>:1:78: The style property GtkWidget:focus-line-width is deprecated and shouldn't be used anymore. It will be removed in a future version

(wrapper-2.0:3083): Gtk-WARNING **: 09:03:53.240: Theme parsing error: <data>:1:108: The style property GtkButton:default-border is deprecated and shouldn't be used anymore. It will be removed in a future version

(wrapper-2.0:3083): Gtk-WARNING **: 09:03:53.240: Theme parsing error: <data>:1:136: The style property GtkButton:inner-border is deprecated and shouldn't be used anymore. It will be removed in a future version

(nm-applet:3129): Gtk-WARNING **: 09:03:53.281: Can't set a parent on widget which has a parent

(nm-applet:3129): Gtk-CRITICAL **: 09:03:53.327: gtk_widget_destroy: assertion 'GTK_IS_WIDGET (widget)' failed

(nm-applet:3129): Gtk-CRITICAL **: 09:03:53.327: gtk_widget_destroy: assertion 'GTK_IS_WIDGET (widget)' failed

(nm-applet:3129): Gtk-WARNING **: 09:03:53.356: Can't set a parent on widget which has a parent

(nm-applet:3129): Gtk-CRITICAL **: 09:03:53.395: gtk_widget_destroy: assertion 'GTK_IS_WIDGET (widget)' failed

(nm-applet:3129): Gtk-CRITICAL **: 09:03:53.395: gtk_widget_destroy: assertion 'GTK_IS_WIDGET (widget)' failed

(nm-applet:3129): Gtk-WARNING **: 09:03:53.432: Can't set a parent on widget which has a parent
sh: 1: dropbox: not found

(xfce4-terminal:3733): Gdk-CRITICAL **: 09:04:38.203: gdk_window_get_window_type: assertion 'GDK_IS_WINDOW (window)' failed
makem@ssdTOSH:~$ 

The error has gone away. The file has not been replaced and everything appears to be working fine (mouse button change)

I see many other errors and must go through the list sorting them before 2020 :-)

Last edited by makem (2019-12-27 09:13:20)

Offline

Board footer

Powered by FluxBB