WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: acpid scripts for laptop Fn+F2/3/6/7/8 functions  (Read 488 times)

Offline nick65go

  • Sr. Member
  • ****
  • Posts: 315
Re: acpid scripts for laptop Fn+F2/3/6/7/8 functions
« Reply #30 on: May 21, 2020, 12:35:22 PM »
My touch-pad is very good (i think). but i do no know how to PASTE with only my synaptic, so I add an external mouse (2 buttons + 1 wheel).

What I discovered now is that clipboard buffer of aterm is NOT shared with others like fltk editor.In aterm shft+del is useless: just selecting with the touch-pad is enough (it auto copy the section).the shft+ins = PASTE in aterm.
Using the external mouse: double click will select (AND copy the selection), Wheel click (middle button) will paste it ANYWHERE (aterm, editor, firefox). This is why is need a mouse.

Disconnecting touch-pad could be with Xinput, like Juanito said previously. I do not think Xorg should be stop & start. I did not tried because I prefer to use/keep the touchpad.
« Last Edit: May 21, 2020, 12:51:50 PM by nick65go »

Offline jazzbiker

  • Full Member
  • ***
  • Posts: 215
Re: acpid scripts for laptop Fn+F2/3/6/7/8 functions
« Reply #31 on: May 21, 2020, 12:59:01 PM »
Yes You're right again, Shift-Del is useless, both in aterm and in rxvt. Releasing mouse button is copying selected text.

Even more questions with fifth.
1. We can copy in terminal and paste into fifth.
2. We can copy in fifth and paste into terminal.
3. We can copy in Editor and paste into fifth
4. We CAN NOT copy in fifth and paste into Editor.

My guess, Curaga knows something intereting about this clipboards.


Offline jazzbiker

  • Full Member
  • ***
  • Posts: 215
Re: acpid scripts for laptop Fn+F2/3/6/7/8 functions
« Reply #32 on: May 21, 2020, 01:00:26 PM »
Thank You for advice about Xinput, but I am not able to use it under Xfbdev.
So seems that Shift-Ins works everywhere as Paste, and can replace middle mouse click.
« Last Edit: May 21, 2020, 01:10:26 PM by jazzbiker »

Offline nick65go

  • Sr. Member
  • ****
  • Posts: 315
Re: acpid scripts for laptop Fn+F2/3/6/7/8 functions
« Reply #33 on: May 21, 2020, 01:28:49 PM »
@jazzbiker: Sorry to dissapoint you.
I love software on 32 bits. Smaller means less surface for attack versus bloat, so more secure etc.
But my laptop has UEFI_64 (not my choose, it came with win10) and 8 GB RAM, so I am tempted by software on 64 bits.
(yes, I get older and stupid, aka more lazy). Yes, I know, the gain in speed is minor (if ever) for my home work.

So no more (for the time beeing) Xvesa, Xfvdev, only in virtual machines. But I am tempted by firejail also.
All is about pristine/virgin trusted environment. No bloat/spy/useless-features. No unsolicited-updates.
I think I could live with just Firefox, vlc, libre-office, 7zip, in an emergency.
« Last Edit: May 21, 2020, 01:32:10 PM by nick65go »

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10206
Re: acpid scripts for laptop Fn+F2/3/6/7/8 functions
« Reply #34 on: May 22, 2020, 12:24:21 AM »
X has this weirdness that it has two clipboards, unlike Win and Mac. One for mouse selection and one for app's ctrl-c/other use. But apps use them however they wish.
The only barriers that can stop you are the ones you create yourself.

Offline nick65go

  • Sr. Member
  • ****
  • Posts: 315
Re: acpid scripts for laptop Fn+F2/3/6/7/8 functions
« Reply #35 on: May 23, 2020, 09:40:55 AM »

Or you could just launch a script in the background that sleeps 99.9999% of the time and occasionally reads the remaining
battery capacity directly:
Code: [Select]
#!/bin/sh
# Short script to monitor remaining percent of battery power.
# Check  /sys/class/power_supply  to find how your battery is named.
#
#  Usage:
#      BatteryMonitor.sh BatteryName &
#
#  Example:
#      BatteryMonitor.sh BAT0 &

[ -z "$1" ] && exit

# The percentage that triggers a warning.
WarningLevel=5
# Number of minutes to sleep before checking capacity again.
SleepMinutes=5

PowerPath="/sys/class/power_supply"
BatteryName="$1"
Capacity="$PowerPath/$BatteryName/capacity"
SleepTime="60 * $SleepMinutes"

while true
do
   sleep "$SleepTime"
   RemainingCapacity="`cat $Capacity`"
   [ "$RemainingCapacity" -gt "$WarningLevel" ] && continue
   popup "Remaining battery capacity is $RemainingCapacity%%"
done
I think SleepTime="60 * $SleepMinutes" is not working, because " ", and multiplication not allowed, only sum/diff
Code: [Select]
sleep: invalid number '60 * 5'
Code: [Select]
tc@box:~$ echo `expr 60 + 5`
65
tc@box:~$ echo `expr 60 * 5`
expr: syntax error

tc@box:~$ calc 60 + 5
65
tc@box:~$ calc 60 *  5
awk: cmd. line:1: Unexpected token
tc@box:~$ calc 60*5
300
so, it should be
Code: [Select]
SleepTime=`calc 60*$SleepMinutes`
« Last Edit: May 23, 2020, 09:47:35 AM by nick65go »

Online Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 7645
Re: acpid scripts for laptop Fn+F2/3/6/7/8 functions
« Reply #36 on: May 23, 2020, 09:58:51 AM »
Hi nick65go
You caught me. I didn't test that part of the script. I set  SleepTime  directly equal to 5 because I wasn't going to wait 5 minutes.
However, you can do multiplication without using  calc.  I know, because I've seen roberts use it in the  tc-config  script. I just
checked his script and the correct syntax is:
Code: [Select]
SleepTime=$((60 * $SleepMinutes))
This shows up in the  waitusb  section of  tc-config.  He also uses the same syntax for division.

Offline nick65go

  • Sr. Member
  • ****
  • Posts: 315
Re: acpid scripts for laptop Fn+F2/3/6/7/8 functions
« Reply #37 on: May 23, 2020, 10:15:06 AM »
Thank you. Good catch. I tested , it works :)
« Last Edit: May 23, 2020, 10:17:20 AM by nick65go »

Online Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 7645
Re: acpid scripts for laptop Fn+F2/3/6/7/8 functions
« Reply #38 on: May 23, 2020, 11:07:18 AM »
Hi nick65go
The text and the attachment in reply #22 have been corrected. Thank you for bringing this issue to my attention. :)

Offline nick65go

  • Sr. Member
  • ****
  • Posts: 315
Re: acpid scripts for laptop Fn+F2/3/6/7/8 functions
« Reply #39 on: May 23, 2020, 03:19:36 PM »
This is just a remainder to myself. It is a good practice to first kill a daemon then start it again, if the daemon is in /home/tc/.X.d/*. Otherwise if I get out of Xorg (with Ctrl+Alt+Backspace), and then start it again (with starrtx), few pairs of zombie daemons processes can be seen with top.The BatteryMonitor.sh should be sent in the background (with &) otherwise nothing will run after it (it is a infinite loop).
my /home/tc/.X.d/myacpi.sh
Code: [Select]
#!/bin/sh
# lower brightness, from default 255 to 32
echo 32 | sudo tee /sys/class/backlight/radeon_bl0/brightness &

#start acpid daemon for F2/3(brightness), F6/7/8(sound), and LID
sudo kill `pidof acpid`
echo 1
sudo /usr/local/sbin/acpid
echo 2

echo powersupersave | sudo tee /sys/module/pcie_aspm/parameters/policy
echo 3

#stop wire-network if we use wifi
[ -e /var/run/udhcpc.eth0.pid ] && sudo kill `cat /var/run/udhcpc.eth0.pid`
echo 4

#stop orfans daemons (/sbin/udevd --daemon) for firmware
sudo kill `pidof udevd`
echo 5

#start crond daemon for battery low 2%
#sudo kill `pidof crond`
#sudo /usr/local/sbin/crond &

sudo kill `pidof BatteryMonitor.sh` `pidof sleep`
/home/tc/.acpi/BatteryMonitor.sh BAT0 &
echo 6

Online Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 7645
Re: acpid scripts for laptop Fn+F2/3/6/7/8 functions
« Reply #40 on: May 25, 2020, 10:47:38 PM »
Hi nick65go
Attached is a modified version of the script. It now also shows percent of charge remaining in a little display in the lower right
corner of the screen. The display gets updated every 5 minutes. The text is normally white. When remaining charge drops
to 20%, it turns yellow. When it drops to 10%, it turns red. When it drops to 5%, you get a popup just like before. There are
variables for setting the percentages at which the colors change. You can also change the XY coordinates of the display as
well as the font.