mirror of
https://github.com/DO1JLR/ansible_linux_desktop_setup.git
synced 2024-09-14 19:54:51 +02:00
Add akku warning script
This commit is contained in:
parent
53a09af828
commit
f5f657f702
3 changed files with 46 additions and 0 deletions
11
roles/akku-warning/files/akku.sh
Normal file
11
roles/akku-warning/files/akku.sh
Normal file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
power="$((`cat /sys/class/power_supply/BAT0/energy_now` * 100 / `cat /sys/class/power_supply/BAT0/energy_full_design`))"
|
||||
|
||||
if (( $power < 15 && $power > 9 )); then
|
||||
zenity --warning --title="Low Power" --text="$power percent remaining.\n\nPlease recharge soon!" --display=:0.0
|
||||
elif (( $power < 9 && $power > 5 )); then
|
||||
zenity --warning --title="Critical Power" --text="$power percent remaining.\n\nPlease recharge NOW!" --display=:0.0
|
||||
elif (( $power < 5 )); then
|
||||
zenity --warning --title="Critical Power" --text="$power percent remaining.\n\nRECHARGE!\nNOW!" --display=:0.0
|
||||
fi
|
26
roles/akku-warning/tasks/main.yml
Normal file
26
roles/akku-warning/tasks/main.yml
Normal file
|
@ -0,0 +1,26 @@
|
|||
---
|
||||
|
||||
- name: copy sound warning script
|
||||
become: yes
|
||||
copy:
|
||||
src: 'files/akku.sh'
|
||||
dest: '/opt/akku.sh'
|
||||
owner: 'root'
|
||||
group: 'root'
|
||||
mode: '0755'
|
||||
|
||||
- name: install zenity
|
||||
become: yes
|
||||
package:
|
||||
name: zenity
|
||||
state: present
|
||||
|
||||
- name: Check akku every 2 minutes
|
||||
become: yes
|
||||
cron:
|
||||
name: check if akku still okay
|
||||
job: /opt/akku.sh
|
||||
minute: '*/2'
|
||||
user: root
|
||||
cron_file: /etc/crontab
|
||||
|
|
@ -26,6 +26,15 @@
|
|||
roles:
|
||||
- dotfiles
|
||||
|
||||
- name: set akku warning
|
||||
hosts: thinkpad
|
||||
tags:
|
||||
- setup
|
||||
- akku
|
||||
roles:
|
||||
- akku-warning
|
||||
|
||||
|
||||
- name: install modules for sound and bluetooth
|
||||
hosts: thinkpad
|
||||
tags:
|
||||
|
|
Loading…
Reference in a new issue