[SOLVED] Possible to modify lock screen to show battery percentage?

Please post suggestions for improvement of Cinnamon on:
https://github.com/linuxmint/Cinnamon
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
SilenceIsG0lden
Level 3
Level 3
Posts: 151
Joined: Thu Mar 12, 2020 3:50 pm

Re: [SOLVED] Possible to modify lock screen to show battery percentage?

Post by SilenceIsG0lden »

Koentje wrote: Wed Feb 14, 2024 6:48 pm Ok, thanks! That made some things more clear.. you have another path to your AC device then my laptop. And your battery power has decimals indeed.. you can uncomment a line to get rid of the decimals.
The script now checks for the right path to BAT0 and AC. And it logs more stuff, your environment, when started, some upower things and when it goes into a loop waiting for the screensaver.. etc.
Call it ss-battstat3.sh and place it in your ~/bin folder. Then change the autostart application to point to the correct script. Logout and login again and it now has created a ~/bin/ss-battstat.log.
I ran it uncommented in the terminal, and it worked perfectly. Then I saved it, per your instructions, rebooted -- but no log file was created. And the percentage is, again, stuck at what it was when I ran it in the terminal.

There must be something going wrong when I save the script. Is there something to consider that I'm not aware of? I'm using the standard text editor (xed).
LM 21.1 cinnamon on PC built by myself in 2008
LM 21.3 cinnamon on Macbook Air
Living in Linux Mint land since 2020, after decades on Microsoft (from DOS to Win7).
User avatar
Koentje
Level 7
Level 7
Posts: 1581
Joined: Tue Jan 04, 2022 6:23 pm
Location: Netherlands

Re: [SOLVED] Possible to modify lock screen to show battery percentage?

Post by Koentje »

Nah, my guess is, the script does not get started! If it does not create a log, then it isn't started! That explains why it stays at the same percentage after a reboot. So double check if you did things correctly to create an autostart application!
Image
SilenceIsG0lden
Level 3
Level 3
Posts: 151
Joined: Thu Mar 12, 2020 3:50 pm

Re: [SOLVED] Possible to modify lock screen to show battery percentage?

Post by SilenceIsG0lden »

Koentje wrote: Thu Feb 15, 2024 5:38 pm So double check if you did things correctly to create an autostart application!
I went about it the same way as for other programs:
1. open Startup Applications
2. click on the + sign
3. give it a Name (LockBatPerc)
4. Browse for the script (/home/mackie/bin/ss-battstat3.sh)
5. Add a Comment.
6. set Startup delay to 30
7. Save
8. Reboot

Do you see anything wrong here?
LM 21.1 cinnamon on PC built by myself in 2008
LM 21.3 cinnamon on Macbook Air
Living in Linux Mint land since 2020, after decades on Microsoft (from DOS to Win7).
User avatar
Koentje
Level 7
Level 7
Posts: 1581
Joined: Tue Jan 04, 2022 6:23 pm
Location: Netherlands

Re: [SOLVED] Possible to modify lock screen to show battery percentage?

Post by Koentje »

Nope... strange. And in that same bin directory after 30 seconds, you can't see any ss-battstat.log??
Image
User avatar
Koentje
Level 7
Level 7
Posts: 1581
Joined: Tue Jan 04, 2022 6:23 pm
Location: Netherlands

Re: [SOLVED] Possible to modify lock screen to show battery percentage?

Post by Koentje »

This is how the log of my laptop looks like..

Code: Select all


*** Starting battery status in screensaver on 18-02-2024 01:23 ***

------------------------------------------------------------------

SHELL=/bin/bash
SESSION_MANAGER=local/laptop:@/tmp/.ICE-unix/1517,unix/laptop:/tmp/.ICE-unix/1517
QT_ACCESSIBILITY=1
XDG_CONFIG_DIRS=/etc/xdg/xdg-cinnamon:/etc/xdg
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
LANGUAGE=nl_NL
SSH_AUTH_SOCK=/run/user/1001/keyring/ssh
DESKTOP_SESSION=cinnamon
GTK_MODULES=gail:atk-bridge
XDG_SEAT=seat0
PWD=/home/admin
XDG_SESSION_DESKTOP=cinnamon
LOGNAME=admin
QT_QPA_PLATFORMTHEME=qt5ct
XDG_SESSION_TYPE=x11
GPG_AGENT_INFO=/run/user/1001/gnupg/S.gpg-agent:0:1
XAUTHORITY=/home/admin/.Xauthority
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/admin
GDM_LANG=nl_NL
HOME=/home/admin
LANG=nl_NL.UTF-8
XDG_CURRENT_DESKTOP=X-Cinnamon
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
XDG_SESSION_CLASS=user
GTK_OVERLAY_SCROLLING=1
USER=admin
DISPLAY=:0
SHLVL=0
XDG_VTNR=7
DESKTOP_AUTOSTART_ID=10132d3e3e2d0ca075170821578386585200000015170009
XDG_SESSION_ID=c2
XDG_RUNTIME_DIR=/run/user/1001
GTK3_MODULES=xapp-gtk3-module
XDG_DATA_DIRS=/usr/share/cinnamon:/usr/share/gnome:/home/admin/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share
PATH=/home/admin/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
GDMSESSION=cinnamon
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1001/bus
_=/usr/bin/env

------------------------------------------------------------------

upower path = /usr/bin/upower
BAT0 path = /org/freedesktop/UPower/devices/battery_BAT0
AC path = /org/freedesktop/UPower/devices/line_power_AC

Device: /org/freedesktop/UPower/devices/line_power_AC
  native-path:          AC
  power supply:         yes
  updated:              zo 18 feb 2024 01:22:58 CET (7 seconds ago)
  has history:          no
  has statistics:       no
  line-power
    warning-level:       none
    online:              no
    icon-name:          'ac-adapter-symbolic'

Device: /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          BAT0
  vendor:               SMP
  model:                DELL DM3WC64
  serial:               1271
  power supply:         yes
  updated:              zo 18 feb 2024 01:22:58 CET (7 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               discharging
    warning-level:       none
    energy:              43,1376 Wh
    energy-empty:        0 Wh
    energy-full:         43,4948 Wh
    energy-full-design:  60,002 Wh
    energy-rate:         8,55 W
    voltage:             8,21 V
    charge-cycles:       N/A
    time to empty:       5,0 hours
    percentage:          99%
    capacity:            72,4889%
    technology:          lithium-polymer
    icon-name:          'battery-full-symbolic'
  History (charge):
    1708215778<>0,000<->unknown
  History (rate):
    1708215778<>0,000<->unknown

Device: /org/freedesktop/UPower/devices/DisplayDevice
  power supply:         yes
  updated:              zo 18 feb 2024 01:22:58 CET (7 seconds ago)
  has history:          no
  has statistics:       no
  battery
    present:             yes
    state:               discharging
    warning-level:       none
    energy:              43,1376 Wh
    energy-full:         43,4948 Wh
    energy-rate:         8,55 W
    charge-cycles:       N/A
    time to empty:       5,0 hours
    percentage:          99%
    icon-name:          'battery-full-symbolic'

Daemon:
  daemon-version:  0.99.17
  on-battery:      yes
  lid-is-closed:   no
  lid-is-present:  yes
  critical-action: HybridSleep

------------------------------------------------------------------

*** Going into loop ***
* Screensaver inactive, waiting to get active..
* Screensaver active!
Dconf set to:  ' Battery 98%'
Dconf set to:  ' Battery 98%'
Dconf set to:  ' Battery 98%'
Dconf set to:  ' Battery 98%'
* Screensaver inactive, waiting to get active..
Image
SilenceIsG0lden
Level 3
Level 3
Posts: 151
Joined: Thu Mar 12, 2020 3:50 pm

Re: [SOLVED] Possible to modify lock screen to show battery percentage?

Post by SilenceIsG0lden »

Koentje wrote: Sat Feb 17, 2024 8:25 pm Nope... strange. And in that same bin directory after 30 seconds, you can't see any ss-battstat.log??
Nada. Let's go through how I save the script:

1. Copy the script from your post.
2. Paste it into an xed window.
3. Click Save As...
4. Navigate to /home/mackie/bin
5. Make sure it's set to Line Ending: Unix/Linux -- it's also Character Encoding: Current Locale (UTF-8)
6. Enter the file name: ss-battstat3.sh
7. Click Save

Question: After I create the Startup Applications entry - if I were to click on the Run Now arrow, should the script run? (It doesn't. When I go into the screensaver, it doesn't show the updated %, no matter how long I wait.)
LM 21.1 cinnamon on PC built by myself in 2008
LM 21.3 cinnamon on Macbook Air
Living in Linux Mint land since 2020, after decades on Microsoft (from DOS to Win7).
User avatar
Koentje
Level 7
Level 7
Posts: 1581
Joined: Tue Jan 04, 2022 6:23 pm
Location: Netherlands

Re: [SOLVED] Possible to modify lock screen to show battery percentage?

Post by Koentje »

SilenceIsG0lden wrote: Sun Feb 18, 2024 10:26 pm
Koentje wrote: Sat Feb 17, 2024 8:25 pm Nope... strange. And in that same bin directory after 30 seconds, you can't see any ss-battstat.log??
Nada. Let's go through how I save the script:

1. Copy the script from your post.
2. Paste it into an xed window.
3. Click Save As...
4. Navigate to /home/mackie/bin
5. Make sure it's set to Line Ending: Unix/Linux -- it's also Character Encoding: Current Locale (UTF-8)
6. Enter the file name: ss-battstat3.sh
7. Click Save
Have you set the script so it can execute?
Question: After I create the Startup Applications entry - if I were to click on the Run Now arrow, should the script run? (It doesn't. When I go into the screensaver, it doesn't show the updated %, no matter how long I wait.)
If you click run now it should make a log immediately!
Image
SilenceIsG0lden
Level 3
Level 3
Posts: 151
Joined: Thu Mar 12, 2020 3:50 pm

Re: [SOLVED] Possible to modify lock screen to show battery percentage?

Post by SilenceIsG0lden »

Koentje wrote: Sun Feb 18, 2024 10:34 pm Have you set the script so it can execute?
ummm... I think we're getting to the crux of things, as I have no idea what you mean. I'm so sorry I haven't mentioned that I don't really have much experience with anything "under the hood" in Linux. (Will fix my signature now.)

Edit: I've looked it up now -- turns out I never came across this before.

Any "real" Linux person probably fainted, reading my response. Koentje, are you OK? :lol:

This may be one of those cases for Linuxers who keep asking: what can we do to keep more people who come from Windows from going back or to a Mac? Why not implement a line to set the script executable or at least a note in the Startup Applications dialog that informs/reminds people of this necessary step?

As to my issue: it is now truly solved. Thank you, Koentje, for your persistence! And for your scripting in the first place. I hope you can add this somewhere in a repository (or to the screensaver source code...?). I'm surely not the only one who'd appreciate this.
LM 21.1 cinnamon on PC built by myself in 2008
LM 21.3 cinnamon on Macbook Air
Living in Linux Mint land since 2020, after decades on Microsoft (from DOS to Win7).
User avatar
Koentje
Level 7
Level 7
Posts: 1581
Joined: Tue Jan 04, 2022 6:23 pm
Location: Netherlands

Re: [SOLVED] Possible to modify lock screen to show battery percentage?

Post by Koentje »

Sorry, missed your last post! Glad it finally works! :D
Image
Post Reply

Return to “Cinnamon”