mirror of
				https://github.com/okunze/Argon40-ArgonOne-Script.git
				synced 2025-11-04 10:50:42 +01:00 
			
		
		
		
	Downloaded updated script from Argon 40 / Updating README.md
This commit is contained in:
		
							
								
								
									
										157
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										157
									
								
								README.md
									
									
									
									
									
								
							@@ -1,73 +1,84 @@
 | 
			
		||||
# Argon ONE Pi 4 Script
 | 
			
		||||
 | 
			
		||||
This script for the [Argon ONE Pi 4 Raspberry Pi Case](https://www.argon40.com/argon-one-raspberry-pi-4-case.html "Argon ONE Pi 4 Raspberry Pi Case") was pulled from [https://download.argon40.com/argon1.sh](https://download.argon40.com/argon1.sh).
 | 
			
		||||
 | 
			
		||||
## How to install Argon ONE Pi 4 Power Button & Fan Control
 | 
			
		||||
 | 
			
		||||
### Prerequisites
 | 
			
		||||
 | 
			
		||||
* [Raspberry Pi 4 Model B (2GB, 4GB or 8GB version)](https://www.raspberrypi.org/products/raspberry-pi-4-model-b/ "Raspberry Pi 4 Model B")
 | 
			
		||||
* [Raspberry Pi OS (previously called Raspbian)](https://www.raspberrypi.org/downloads/ "Raspberry Pi OS") installed on microSD card
 | 
			
		||||
* [Argon ONE Pi 4 Raspberry Pi Case](https://www.argon40.com/argon-one-raspberry-pi-4-case.html "Argon ONE Pi 4 Raspberry Pi Case")
 | 
			
		||||
 | 
			
		||||
### Installing
 | 
			
		||||
 | 
			
		||||
1. Connect to the internet.
 | 
			
		||||
2. Open "Terminal" in Raspbian.
 | 
			
		||||
3. Type the text below in the "Terminal" to initiate installation of Argon ONE Pi 4 script.
 | 
			
		||||
 | 
			
		||||
   ```
 | 
			
		||||
   curl https://download.argon40.com/argon1.sh | bash
 | 
			
		||||
   ```
 | 
			
		||||
 | 
			
		||||
4. Reboot.
 | 
			
		||||
 | 
			
		||||
## Usage Instructions
 | 
			
		||||
 | 
			
		||||
### Argon ONE Pi 4 Power Button Functions
 | 
			
		||||
 | 
			
		||||
ARGON ONE PI 4 STATE | ACTION | FUNCTION
 | 
			
		||||
:------------------: | :----: | :------:
 | 
			
		||||
OFF | Short Press | Turn ON
 | 
			
		||||
ON | Long Press (>= 3 s) | Soft Shutdown and Power Cut
 | 
			
		||||
ON | Short Press (< 3 s) | Nothing
 | 
			
		||||
ON | Double Tap | Reboot
 | 
			
		||||
ON | Long Press (>= 5 s) | Forced Shutdown
 | 
			
		||||
 | 
			
		||||
### Argon ONE Pi 4 Fan Speed
 | 
			
		||||
Upon installation of the Argon ONE Pi 4 script by default, the settings of the Argon ONE Pi 4 cooling system are as follows:
 | 
			
		||||
 | 
			
		||||
CPU TEMP | FAN POWER
 | 
			
		||||
:------: | :-------:
 | 
			
		||||
55 C | 10%
 | 
			
		||||
60 C | 55%
 | 
			
		||||
65 C | 100%
 | 
			
		||||
 | 
			
		||||
However, you may change or configure the FAN to your desired settings by clicking the Argon ONE Pi 4 Config icon on your Desktop.
 | 
			
		||||
 | 
			
		||||
Or via "Terminal" by typing and following the specified format:
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
argonone-config
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Uninstalling Argon ONE Pi 4 Script
 | 
			
		||||
 | 
			
		||||
To uninstall the Argon ONE Pi 4 script you may do so by clicking the Argon One Pi 4 Uninstall icon on your Desktop.
 | 
			
		||||
 | 
			
		||||
You may also remove the script via "Terminal" by typing.
 | 
			
		||||
```
 | 
			
		||||
argonone-uninstall
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Always reboot after changing any configuration or uninstallation for the revised settings to take effect. 
 | 
			
		||||
 | 
			
		||||
## Built With
 | 
			
		||||
 | 
			
		||||
* [Danny Guo / Make a README](https://www.makeareadme.com/ "Make a README") - The README generator used for README.md
 | 
			
		||||
* [Adam Pritchard / Markdown Cheatsheet](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet "Markdown Cheatsheet") - The Markdown Cheatsheet used for README.md
 | 
			
		||||
* [PurpleBooth / README-Template.md](https://gist.github.com/PurpleBooth/109311bb0361f32d87a2 "PurpleBooth / README-Template.md") - The template used for README.md
 | 
			
		||||
 | 
			
		||||
## Acknowledgments
 | 
			
		||||
 | 
			
		||||
Thanks to [Argon Forty](https://www.argon40.com/) for building these great Raspberry Pi Case.
 | 
			
		||||
# Argon ONE (V2) Pi 4 Script
 | 
			
		||||
 | 
			
		||||
I have been using the [Argon ONE (V2) Case for Raspberry Pi 4](https://www.argon40.com/collections/raspberry-pi-cases "Argon ONE (V2) Case for Raspberry Pi 4") for a long time and I am very happy with it.
 | 
			
		||||
 | 
			
		||||
To be able to use the case to the full extent, it is recommended to install the [script](https://download.argon40.com/argon1.sh "https://download.argon40.com/argon1.sh") offered by [Argon 40](https://www.argon40.com "https://www.argon40.com").
 | 
			
		||||
 | 
			
		||||
I have saved a copy here along with the instructions to have a copy in case [Argon 40](https://www.argon40.com "https://www.argon40.com") no longer offers it themselves.
 | 
			
		||||
 | 
			
		||||
**Just to clarify: I am in no way affiliated with [Argon 40](https://www.argon40.com "https://www.argon40.com"), I only use their cases as an end user.**
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
You can find them here:
 | 
			
		||||
* Argon 40 Website: [https://www.argon40.com](https://www.argon40.com "https://www.argon40.com")
 | 
			
		||||
* Argon 40 Github: [https://github.com/Argon40Tech](https://github.com/Argon40Tech "https://github.com/Argon40Tech")
 | 
			
		||||
 | 
			
		||||
## How to install Argon ONE (V2) Pi 4 Power Button & Fan Control
 | 
			
		||||
 | 
			
		||||
### Prerequisites
 | 
			
		||||
 | 
			
		||||
* [Raspberry Pi 4 Model B (2GB, 4GB or 8GB version)](https://www.raspberrypi.org/products/raspberry-pi-4-model-b/ "Raspberry Pi 4 Model B")
 | 
			
		||||
* [Raspberry Pi OS (previously called Raspbian)](https://www.raspberrypi.org/downloads/ "Raspberry Pi OS") installed on microSD card
 | 
			
		||||
* [Argon ONE (V2) Case for Raspberry Pi 4](https://www.argon40.com/collections/raspberry-pi-cases "Argon ONE (V2) Case for Raspberry Pi 4")
 | 
			
		||||
 | 
			
		||||
### Installing
 | 
			
		||||
 | 
			
		||||
1. Connect to the internet.
 | 
			
		||||
2. Open "Terminal" in Raspbian.
 | 
			
		||||
3. Type the text below in the "Terminal" to initiate installation of Argon ONE (V2) Pi 4 script.
 | 
			
		||||
 | 
			
		||||
   ```
 | 
			
		||||
   curl https://download.argon40.com/argon1.sh | bash
 | 
			
		||||
   ```
 | 
			
		||||
 | 
			
		||||
4. Reboot.
 | 
			
		||||
 | 
			
		||||
## Usage Instructions
 | 
			
		||||
 | 
			
		||||
### Argon ONE (V2) Pi 4 Power Button Functions
 | 
			
		||||
 | 
			
		||||
ARGON ONE (V2) PI 4 STATE | ACTION | FUNCTION
 | 
			
		||||
:------------------: | :----: | :------:
 | 
			
		||||
OFF | Short Press | Turn ON
 | 
			
		||||
ON | Long Press (>= 3 s) | Soft Shutdown and Power Cut
 | 
			
		||||
ON | Short Press (< 3 s) | Nothing
 | 
			
		||||
ON | Double Tap | Reboot
 | 
			
		||||
ON | Long Press (>= 5 s) | Forced Shutdown
 | 
			
		||||
 | 
			
		||||
### Argon ONE (V2) Pi 4 Fan Speed
 | 
			
		||||
Upon installation of the Argon ONE (V2) Pi 4 script by default, the settings of the Argon ONE (V2) Pi 4 cooling system are as follows:
 | 
			
		||||
 | 
			
		||||
CPU TEMP | FAN POWER
 | 
			
		||||
:------: | :-------:
 | 
			
		||||
55 C | 10%
 | 
			
		||||
60 C | 55%
 | 
			
		||||
65 C | 100%
 | 
			
		||||
 | 
			
		||||
However, you may change or configure the FAN to your desired settings by clicking the Argon ONE (V2) Pi 4 Config icon on your Desktop.
 | 
			
		||||
 | 
			
		||||
Or via "Terminal" by typing and following the specified format:
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
argonone-config
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Uninstalling Argon ONE (V2) Pi 4 Script
 | 
			
		||||
 | 
			
		||||
To uninstall the Argon ONE (V2) Pi 4 script you may do so by clicking the Argon One (V2) Pi 4 Uninstall icon on your Desktop.
 | 
			
		||||
 | 
			
		||||
You may also remove the script via "Terminal" by typing.
 | 
			
		||||
```
 | 
			
		||||
argonone-uninstall
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Always reboot after changing any configuration or uninstallation for the revised settings to take effect.
 | 
			
		||||
 | 
			
		||||
## Built With
 | 
			
		||||
 | 
			
		||||
* [Danny Guo / Make a README](https://www.makeareadme.com/ "Make a README") - The README generator used for README.md
 | 
			
		||||
* [Adam Pritchard / Markdown Cheatsheet](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet "Markdown Cheatsheet") - The Markdown Cheatsheet used for README.md
 | 
			
		||||
* [PurpleBooth / README-Template.md](https://gist.github.com/PurpleBooth/109311bb0361f32d87a2 "PurpleBooth / README-Template.md") - The template used for README.md
 | 
			
		||||
 | 
			
		||||
## Acknowledgments
 | 
			
		||||
 | 
			
		||||
Thanks to [Argon 40](https://www.argon40.com "https://www.argon40.com") for building these great Raspberry Pi Cases.
 | 
			
		||||
 
 | 
			
		||||
| 
		 Before Width: | Height: | Size: 117 KiB After Width: | Height: | Size: 117 KiB  | 
| 
		 Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 118 KiB  | 
@@ -3,22 +3,33 @@
 | 
			
		||||
 | 
			
		||||
argon_create_file() {
 | 
			
		||||
	if [ -f $1 ]; then
 | 
			
		||||
        sudo rm $1
 | 
			
		||||
    fi
 | 
			
		||||
		sudo rm $1
 | 
			
		||||
	fi
 | 
			
		||||
	sudo touch $1
 | 
			
		||||
	sudo chmod 666 $1
 | 
			
		||||
}
 | 
			
		||||
argon_check_pkg() {
 | 
			
		||||
    RESULT=$(dpkg-query -W -f='${Status}\n' "$1" 2> /dev/null | grep "installed")
 | 
			
		||||
	RESULT=$(dpkg-query -W -f='${Status}\n' "$1" 2> /dev/null | grep "installed")
 | 
			
		||||
 | 
			
		||||
    if [ "" == "$RESULT" ]; then
 | 
			
		||||
        echo "NG"
 | 
			
		||||
    else
 | 
			
		||||
        echo "OK"
 | 
			
		||||
    fi
 | 
			
		||||
	if [ "" == "$RESULT" ]; then
 | 
			
		||||
		echo "NG"
 | 
			
		||||
	else
 | 
			
		||||
		echo "OK"
 | 
			
		||||
	fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pkglist=(raspi-gpio python-rpi.gpio python3-rpi.gpio python-smbus python3-smbus i2c-tools)
 | 
			
		||||
CHECKPLATFORM="Others"
 | 
			
		||||
# Check if Raspbian, otherwise Ubuntu
 | 
			
		||||
grep -q -F 'Raspbian' /etc/os-release &> /dev/null
 | 
			
		||||
if [ $? -eq 0 ]
 | 
			
		||||
then
 | 
			
		||||
	CHECKPLATFORM="Raspbian"
 | 
			
		||||
	pkglist=(raspi-gpio python3-rpi.gpio python3-smbus i2c-tools)	
 | 
			
		||||
else
 | 
			
		||||
	# Ubuntu has serial and i2c enabled
 | 
			
		||||
	pkglist=(python3-rpi.gpio python3-smbus i2c-tools)
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
for curpkg in ${pkglist[@]}; do
 | 
			
		||||
	sudo apt-get install -y $curpkg
 | 
			
		||||
	RESULT=$(argon_check_pkg "$curpkg")
 | 
			
		||||
@@ -31,8 +42,16 @@ for curpkg in ${pkglist[@]}; do
 | 
			
		||||
	fi
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
# Ubuntu Mate for RPi has raspi-config too
 | 
			
		||||
command -v raspi-config &> /dev/null
 | 
			
		||||
if [ $? -eq 0 ]
 | 
			
		||||
then
 | 
			
		||||
	# Enable i2c and serial
 | 
			
		||||
	sudo raspi-config nonint do_i2c 0
 | 
			
		||||
	sudo raspi-config nonint do_serial 2
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Helper variables
 | 
			
		||||
daemonname="argononed"
 | 
			
		||||
powerbuttonscript=/usr/bin/$daemonname.py
 | 
			
		||||
shutdownscript="/lib/systemd/system-shutdown/"$daemonname"-poweroff.py"
 | 
			
		||||
@@ -41,9 +60,6 @@ configscript=/usr/bin/argonone-config
 | 
			
		||||
removescript=/usr/bin/argonone-uninstall
 | 
			
		||||
 | 
			
		||||
daemonfanservice=/lib/systemd/system/$daemonname.service
 | 
			
		||||
 | 
			
		||||
sudo raspi-config nonint do_i2c 0
 | 
			
		||||
sudo raspi-config nonint do_serial 0	
 | 
			
		||||
	
 | 
			
		||||
if [ ! -f $daemonconfigfile ]; then
 | 
			
		||||
	# Generate config file for fan speed
 | 
			
		||||
@@ -77,7 +93,7 @@ fi
 | 
			
		||||
# Generate script that runs every shutdown event
 | 
			
		||||
argon_create_file $shutdownscript
 | 
			
		||||
 | 
			
		||||
echo "#!/usr/bin/python" >> $shutdownscript
 | 
			
		||||
echo "#!/usr/bin/python3" >> $shutdownscript
 | 
			
		||||
echo 'import sys' >> $shutdownscript
 | 
			
		||||
echo 'import smbus' >> $shutdownscript
 | 
			
		||||
echo 'import RPi.GPIO as GPIO' >> $shutdownscript
 | 
			
		||||
@@ -89,18 +105,21 @@ echo '	bus = smbus.SMBus(0)' >> $shutdownscript
 | 
			
		||||
 | 
			
		||||
echo 'if len(sys.argv)>1:' >> $shutdownscript
 | 
			
		||||
echo "	bus.write_byte(0x1a,0)"  >> $shutdownscript
 | 
			
		||||
 | 
			
		||||
# powercut signal
 | 
			
		||||
echo '	if sys.argv[1] == "poweroff" or sys.argv[1] == "halt":'  >> $shutdownscript
 | 
			
		||||
echo "		try:"  >> $shutdownscript
 | 
			
		||||
echo "			bus.write_byte(0x1a,0xFF)"  >> $shutdownscript
 | 
			
		||||
echo "		except:"  >> $shutdownscript
 | 
			
		||||
echo "			rev=0"  >> $shutdownscript
 | 
			
		||||
 | 
			
		||||
sudo chmod 755 $shutdownscript
 | 
			
		||||
 | 
			
		||||
# Generate script to monitor shutdown button
 | 
			
		||||
 | 
			
		||||
argon_create_file $powerbuttonscript
 | 
			
		||||
 | 
			
		||||
echo "#!/usr/bin/python" >> $powerbuttonscript
 | 
			
		||||
echo "#!/usr/bin/python3" >> $powerbuttonscript
 | 
			
		||||
echo 'import smbus' >> $powerbuttonscript
 | 
			
		||||
echo 'import RPi.GPIO as GPIO' >> $powerbuttonscript
 | 
			
		||||
echo 'import os' >> $powerbuttonscript
 | 
			
		||||
@@ -136,6 +155,8 @@ echo '		curpair = curconfig.split("=")' >> $powerbuttonscript
 | 
			
		||||
echo '		tempcfg = float(curpair[0])' >> $powerbuttonscript
 | 
			
		||||
echo '		fancfg = int(float(curpair[1]))' >> $powerbuttonscript
 | 
			
		||||
echo '		if tempval >= tempcfg:' >> $powerbuttonscript
 | 
			
		||||
echo '			if fancfg < 25:' >> $powerbuttonscript
 | 
			
		||||
echo '				return 25' >> $powerbuttonscript
 | 
			
		||||
echo '			return fancfg' >> $powerbuttonscript
 | 
			
		||||
echo '	return 0' >> $powerbuttonscript
 | 
			
		||||
 | 
			
		||||
@@ -183,14 +204,23 @@ echo '		fanconfig = tmpconfig' >> $powerbuttonscript
 | 
			
		||||
echo '	address=0x1a' >> $powerbuttonscript
 | 
			
		||||
echo '	prevblock=0' >> $powerbuttonscript
 | 
			
		||||
echo '	while True:' >> $powerbuttonscript
 | 
			
		||||
echo '		temp = os.popen("vcgencmd measure_temp").readline()' >> $powerbuttonscript
 | 
			
		||||
echo '		temp = temp.replace("temp=","")' >> $powerbuttonscript
 | 
			
		||||
echo '		val = float(temp.replace("'"'"'C",""))' >> $powerbuttonscript
 | 
			
		||||
 | 
			
		||||
echo '		try:' >> $powerbuttonscript
 | 
			
		||||
echo '			tempfp = open("/sys/class/thermal/thermal_zone0/temp", "r")' >> $powerbuttonscript
 | 
			
		||||
echo '			temp = tempfp.readline()' >> $powerbuttonscript
 | 
			
		||||
echo '			tempfp.close()' >> $powerbuttonscript
 | 
			
		||||
echo '			val = float(int(temp)/1000)' >> $powerbuttonscript
 | 
			
		||||
echo '		except IOError:' >> $powerbuttonscript
 | 
			
		||||
echo '			val = 0' >> $powerbuttonscript
 | 
			
		||||
 | 
			
		||||
echo '		block = get_fanspeed(val, fanconfig)' >> $powerbuttonscript
 | 
			
		||||
echo '		if block < prevblock:' >> $powerbuttonscript
 | 
			
		||||
echo '			time.sleep(30)' >> $powerbuttonscript
 | 
			
		||||
echo '		prevblock = block' >> $powerbuttonscript
 | 
			
		||||
echo '		try:' >> $powerbuttonscript
 | 
			
		||||
echo '			if block > 0:' >> $powerbuttonscript
 | 
			
		||||
echo '				bus.write_byte(address,100)' >> $powerbuttonscript
 | 
			
		||||
echo '				time.sleep(1)' >> $powerbuttonscript
 | 
			
		||||
echo '			bus.write_byte(address,block)' >> $powerbuttonscript
 | 
			
		||||
echo '		except IOError:' >> $powerbuttonscript
 | 
			
		||||
echo '			temp=""' >> $powerbuttonscript
 | 
			
		||||
@@ -265,7 +295,7 @@ argon_create_file $configscript
 | 
			
		||||
 | 
			
		||||
# Config Script
 | 
			
		||||
echo '#!/bin/bash' >> $configscript
 | 
			
		||||
echo 'daemonconfigfile=/etc/'$daemonname'.conf' >> $configscript
 | 
			
		||||
echo 'daemonconfigfile='$daemonconfigfile >> $configscript
 | 
			
		||||
echo 'echo "--------------------------------------"' >> $configscript
 | 
			
		||||
echo 'echo "Argon One Fan Speed Configuration Tool"' >> $configscript
 | 
			
		||||
echo 'echo "--------------------------------------"' >> $configscript
 | 
			
		||||
@@ -446,16 +476,23 @@ sudo systemctl enable $daemonname.service
 | 
			
		||||
 | 
			
		||||
sudo systemctl start $daemonname.service
 | 
			
		||||
 | 
			
		||||
if [ -d "/home/pi/Desktop" ]; then
 | 
			
		||||
	sudo wget http://download.argon40.com/ar1config.png -O /usr/share/pixmaps/ar1config.png
 | 
			
		||||
	sudo wget http://download.argon40.com/ar1uninstall.png -O /usr/share/pixmaps/ar1uninstall.png
 | 
			
		||||
 | 
			
		||||
shortcutfile="/home/pi/Desktop/argonone-config.desktop"
 | 
			
		||||
if [ "$CHECKPLATFORM" = "Raspbian" ] && [ -d "/home/pi/Desktop" ]
 | 
			
		||||
then
 | 
			
		||||
	terminalcmd="lxterminal --working-directory=/home/pi/ -t"
 | 
			
		||||
	if  [ -f "/home/pi/.twisteros.twid" ]
 | 
			
		||||
	then
 | 
			
		||||
		terminalcmd="xfce4-terminal --default-working-directory=/home/pi/ -T"
 | 
			
		||||
	fi
 | 
			
		||||
	sudo wget http://download.argon40.com/ar1config.png -O /usr/share/pixmaps/ar1config.png --quiet
 | 
			
		||||
	sudo wget http://download.argon40.com/ar1uninstall.png -O /usr/share/pixmaps/ar1uninstall.png --quiet
 | 
			
		||||
	# Create Shortcuts
 | 
			
		||||
	shortcutfile="/home/pi/Desktop/argonone-config.desktop"
 | 
			
		||||
	echo "[Desktop Entry]" > $shortcutfile
 | 
			
		||||
	echo "Name=Argon One Configuration" >> $shortcutfile
 | 
			
		||||
	echo "Comment=Argon One Configuration" >> $shortcutfile
 | 
			
		||||
	echo "Icon=/usr/share/pixmaps/ar1config.png" >> $shortcutfile
 | 
			
		||||
	echo 'Exec=lxterminal -t "Argon One Configuration" --working-directory=/home/pi/ -e '$configscript >> $shortcutfile
 | 
			
		||||
	echo 'Exec='$terminalcmd' "Argon One Configuration" -e '$configscript >> $shortcutfile
 | 
			
		||||
	echo "Type=Application" >> $shortcutfile
 | 
			
		||||
	echo "Encoding=UTF-8" >> $shortcutfile
 | 
			
		||||
	echo "Terminal=false" >> $shortcutfile
 | 
			
		||||
@@ -467,7 +504,7 @@ if [ -d "/home/pi/Desktop" ]; then
 | 
			
		||||
	echo "Name=Argon One Uninstall" >> $shortcutfile
 | 
			
		||||
	echo "Comment=Argon One Uninstall" >> $shortcutfile
 | 
			
		||||
	echo "Icon=/usr/share/pixmaps/ar1uninstall.png" >> $shortcutfile
 | 
			
		||||
	echo 'Exec=lxterminal -t "Argon One Uninstall" --working-directory=/home/pi/ -e '$removescript >> $shortcutfile
 | 
			
		||||
	echo 'Exec='$terminalcmd' -t "Argon One Uninstall" --working-directory=/home/pi/ -e '$removescript >> $shortcutfile
 | 
			
		||||
	echo "Type=Application" >> $shortcutfile
 | 
			
		||||
	echo "Encoding=UTF-8" >> $shortcutfile
 | 
			
		||||
	echo "Terminal=false" >> $shortcutfile
 | 
			
		||||
@@ -475,15 +512,23 @@ if [ -d "/home/pi/Desktop" ]; then
 | 
			
		||||
	chmod 755 $shortcutfile
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# IR config script
 | 
			
		||||
sudo wget https://download.argon40.com/argonone-irconfig.sh -O /usr/bin/argonone-ir --quiet
 | 
			
		||||
sudo chmod 755 /usr/bin/argonone-ir
 | 
			
		||||
 | 
			
		||||
echo "***************************"
 | 
			
		||||
echo "Argon One Setup Completed."
 | 
			
		||||
echo "***************************"
 | 
			
		||||
echo 
 | 
			
		||||
if [ -d "/home/pi/Desktop" ]; then
 | 
			
		||||
echo
 | 
			
		||||
if [ ! "$CHECKPLATFORM" = "Raspbian" ]
 | 
			
		||||
then
 | 
			
		||||
		echo "You may need to reboot for changes to take effect"
 | 
			
		||||
		echo
 | 
			
		||||
fi 
 | 
			
		||||
if [ -f $shortcutfile ]; then
 | 
			
		||||
	echo Shortcuts created in your desktop.
 | 
			
		||||
else
 | 
			
		||||
	echo Use 'argonone-config' to configure fan
 | 
			
		||||
	echo Use 'argonone-uninstall' to uninstall
 | 
			
		||||
fi
 | 
			
		||||
echo
 | 
			
		||||
echo
 | 
			
		||||
							
								
								
									
										325
									
								
								source/argonone-irconfig.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										325
									
								
								source/argonone-irconfig.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,325 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
CHECKPLATFORM="Others"
 | 
			
		||||
# Check if Raspbian
 | 
			
		||||
grep -q -F 'Raspbian' /etc/os-release &> /dev/null
 | 
			
		||||
if [ $? -eq 0 ]
 | 
			
		||||
then
 | 
			
		||||
	CHECKPLATFORM="Raspbian"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
echo "--------------------------------"
 | 
			
		||||
echo "Argon One IR Configuration Tool"
 | 
			
		||||
echo "--------------------------------"
 | 
			
		||||
echo "WARNING: This only supports NEC"
 | 
			
		||||
echo "         protocol only."
 | 
			
		||||
echo -n "Press Y to continue:"
 | 
			
		||||
read -n 1 confirm
 | 
			
		||||
echo
 | 
			
		||||
 | 
			
		||||
if [ "$confirm" = "y" ]
 | 
			
		||||
then
 | 
			
		||||
	confirm="Y"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ "$confirm" != "Y" ]
 | 
			
		||||
then
 | 
			
		||||
	echo "Cancelled"
 | 
			
		||||
	exit
 | 
			
		||||
fi
 | 
			
		||||
echo "Thank you."
 | 
			
		||||
 | 
			
		||||
get_number () {
 | 
			
		||||
	read curnumber
 | 
			
		||||
	if [ -z "$curnumber" ]
 | 
			
		||||
	then
 | 
			
		||||
		echo "-2"
 | 
			
		||||
		return
 | 
			
		||||
	elif [[ $curnumber =~ ^[+-]?[0-9]+$ ]]
 | 
			
		||||
	then
 | 
			
		||||
		if [ $curnumber -lt 0 ]
 | 
			
		||||
		then
 | 
			
		||||
			echo "-1"
 | 
			
		||||
			return
 | 
			
		||||
		elif [ $curnumber -gt 100 ]
 | 
			
		||||
		then
 | 
			
		||||
			echo "-1"
 | 
			
		||||
			return
 | 
			
		||||
		fi	
 | 
			
		||||
		echo $curnumber
 | 
			
		||||
		return
 | 
			
		||||
	fi
 | 
			
		||||
	echo "-1"
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
irexecrcfile=/etc/lirc/irexec.lircrc
 | 
			
		||||
irexecshfile=/usr/bin/argonirexec
 | 
			
		||||
irdecodefile=/usr/bin/argonirdecoder
 | 
			
		||||
kodiuserdatafolder="$HOME/.kodi/userdata"
 | 
			
		||||
kodilircmapfile="$kodiuserdatafolder/Lircmap.xml"
 | 
			
		||||
remotemode=""
 | 
			
		||||
needinstallation=0
 | 
			
		||||
 | 
			
		||||
loopflag=1
 | 
			
		||||
while [ $loopflag -eq 1 ]
 | 
			
		||||
do
 | 
			
		||||
	echo
 | 
			
		||||
	echo "Select remote control to configure:"
 | 
			
		||||
	echo "  1. Configure Remote ON/OFF Button"
 | 
			
		||||
	if [ "$CHECKPLATFORM" = "Raspbian" ]
 | 
			
		||||
	then
 | 
			
		||||
		echo "  2. Configure Other Remote Buttons"
 | 
			
		||||
		if [ ! -f "$irexecshfile" ]
 | 
			
		||||
		then
 | 
			
		||||
			echo "  3. Cancel"
 | 
			
		||||
			echo -n "Enter Number (1-3):"
 | 
			
		||||
 | 
			
		||||
			newmode=$( get_number )
 | 
			
		||||
			if [[ $newmode -ge 1 && $newmode -le 3 ]]
 | 
			
		||||
			then
 | 
			
		||||
				loopflag=0
 | 
			
		||||
				if [ $newmode -eq 3 ]
 | 
			
		||||
				then
 | 
			
		||||
					newmode=4
 | 
			
		||||
				fi
 | 
			
		||||
			fi
 | 
			
		||||
 | 
			
		||||
		else
 | 
			
		||||
			echo "  3. Uninstall Other Remote Buttons"
 | 
			
		||||
			echo "  4. Cancel"
 | 
			
		||||
			echo -n "Enter Number (1-4):"
 | 
			
		||||
			newmode=$( get_number )
 | 
			
		||||
			if [[ $newmode -ge 1 && $newmode -le 4 ]]
 | 
			
		||||
			then
 | 
			
		||||
				loopflag=0
 | 
			
		||||
			fi
 | 
			
		||||
		fi
 | 
			
		||||
	else
 | 
			
		||||
		echo "  2. Cancel"
 | 
			
		||||
		echo -n "Enter Number (1-2):"
 | 
			
		||||
 | 
			
		||||
		newmode=$( get_number )
 | 
			
		||||
		if [[ $newmode -ge 1 && $newmode -le 2 ]]
 | 
			
		||||
		then
 | 
			
		||||
			loopflag=0
 | 
			
		||||
			if [ $newmode -eq 2 ]
 | 
			
		||||
			then
 | 
			
		||||
				newmode=4
 | 
			
		||||
			fi
 | 
			
		||||
		fi
 | 
			
		||||
	fi
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
echo
 | 
			
		||||
if [ $newmode -eq 3 ]
 | 
			
		||||
then
 | 
			
		||||
	irtmpconfigfile=/dev/shm/argonirconfig.txt
 | 
			
		||||
	sudo systemctl stop irexec.service
 | 
			
		||||
	sudo systemctl disable irexec.service
 | 
			
		||||
	sudo pip3 uninstall lirc -y
 | 
			
		||||
	sudo apt-get -y remove lirc
 | 
			
		||||
	sudo rm $irexecshfile
 | 
			
		||||
	sudo rm $irdecodefile
 | 
			
		||||
 | 
			
		||||
	sudo cat /boot/config.txt | grep -v 'dtoverlay=gpio-ir,gpio_pin=23' > $irtmpconfigfile
 | 
			
		||||
	cat $irtmpconfigfile | sudo tee /boot/config.txt 1> /dev/null
 | 
			
		||||
	sudo rm $irtmpconfigfile
 | 
			
		||||
 | 
			
		||||
	echo "Uninstall Completed"
 | 
			
		||||
	echo "Please reboot for changes to take effect"
 | 
			
		||||
	exit
 | 
			
		||||
elif [ $newmode -eq 1 ]
 | 
			
		||||
then
 | 
			
		||||
	loopflag=1
 | 
			
		||||
	while [ $loopflag -eq 1 ]
 | 
			
		||||
	do
 | 
			
		||||
		echo
 | 
			
		||||
		echo "Select remote control to configure:"
 | 
			
		||||
		echo "  1. Use Argon Remote ON/OFF Button"
 | 
			
		||||
		echo "  2. Use Custom Remote ON/OFF Button"
 | 
			
		||||
		echo "  3. Cancel"
 | 
			
		||||
		echo -n "Enter Number (1-3):"
 | 
			
		||||
		newmode=$( get_number )
 | 
			
		||||
		if [[ $newmode -ge 1 && $newmode -le 4 ]]
 | 
			
		||||
		then
 | 
			
		||||
			loopflag=0
 | 
			
		||||
		fi
 | 
			
		||||
	done
 | 
			
		||||
 | 
			
		||||
	if [ $newmode -eq 3 ]
 | 
			
		||||
	then
 | 
			
		||||
		echo "Cancelled"
 | 
			
		||||
		exit
 | 
			
		||||
	elif [ $newmode -eq 1 ]
 | 
			
		||||
	then
 | 
			
		||||
		remotemode="resetpower"
 | 
			
		||||
	elif [ $newmode -eq 2 ]
 | 
			
		||||
	then
 | 
			
		||||
		remotemode="power"
 | 
			
		||||
	fi
 | 
			
		||||
elif [ $newmode -eq 2 ]
 | 
			
		||||
then
 | 
			
		||||
	echo "--------------------------------"
 | 
			
		||||
	echo "Argon One IR Configuration Tool"
 | 
			
		||||
	echo "--------------------------------"
 | 
			
		||||
	echo "WARNING: This will install LIRC"
 | 
			
		||||
	echo "         and related libraries."
 | 
			
		||||
	echo -n "Press Y to agree:"
 | 
			
		||||
	read -n 1 confirm
 | 
			
		||||
	echo
 | 
			
		||||
 | 
			
		||||
	if [ "$confirm" = "y" ]
 | 
			
		||||
	then
 | 
			
		||||
		confirm="Y"
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
	if [ "$confirm" != "Y" ]
 | 
			
		||||
	then
 | 
			
		||||
		echo "Cancelled"
 | 
			
		||||
		exit
 | 
			
		||||
	fi
 | 
			
		||||
	echo "Thank you."
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	needinstallation=1
 | 
			
		||||
	loopflag=1
 | 
			
		||||
	while [ $loopflag -eq 1 ]
 | 
			
		||||
	do
 | 
			
		||||
		echo
 | 
			
		||||
		echo "Select remote control to configure:"
 | 
			
		||||
		echo "  1. Use Argon Remote Buttons"
 | 
			
		||||
		echo "  2. Use Custom Remote Buttons"
 | 
			
		||||
		echo "  3. Cancel"
 | 
			
		||||
		echo -n "Enter Number (1-3):"
 | 
			
		||||
		newmode=$( get_number )
 | 
			
		||||
		if [[ $newmode -ge 1 && $newmode -le 4 ]]
 | 
			
		||||
		then
 | 
			
		||||
			loopflag=0
 | 
			
		||||
		fi
 | 
			
		||||
	done
 | 
			
		||||
 | 
			
		||||
	if [ $newmode -eq 3 ]
 | 
			
		||||
	then
 | 
			
		||||
		echo "Cancelled"
 | 
			
		||||
		exit
 | 
			
		||||
	elif [ $newmode -eq 1 ]
 | 
			
		||||
	then
 | 
			
		||||
		remotemode="default"
 | 
			
		||||
	elif [ $newmode -eq 2 ]
 | 
			
		||||
	then
 | 
			
		||||
		remotemode="custom"
 | 
			
		||||
	fi
 | 
			
		||||
else
 | 
			
		||||
	echo "Cancelled"
 | 
			
		||||
	exit
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
needrestart=0
 | 
			
		||||
if [ $needinstallation -eq 1 ]
 | 
			
		||||
then
 | 
			
		||||
	if [ ! -f "$irexecshfile" ]
 | 
			
		||||
	then
 | 
			
		||||
		needrestart=1
 | 
			
		||||
		sudo apt-get -y update
 | 
			
		||||
		sudo apt-get -y install lirc
 | 
			
		||||
 | 
			
		||||
		sudo pip3 install lirc
 | 
			
		||||
 | 
			
		||||
		echo "dtoverlay=gpio-ir,gpio_pin=23" | sudo tee -a /boot/config.txt 1> /dev/null
 | 
			
		||||
 | 
			
		||||
		sudo /usr/share/lirc/lirc-old2new
 | 
			
		||||
 | 
			
		||||
		sudo systemctl daemon-reload
 | 
			
		||||
		sudo systemctl enable irexec.service
 | 
			
		||||
		sudo systemctl start irexec.service
 | 
			
		||||
 | 
			
		||||
		echo "" | sudo tee $irexecrcfile 1> /dev/null
 | 
			
		||||
		for keyname in UP DOWN LEFT RIGHT BACK PLAYPAUSE MENU HOME OK MUTE VOLUMEUP VOLUMEDOWN
 | 
			
		||||
		do
 | 
			
		||||
			echo 'begin' | sudo tee -a $irexecrcfile 1> /dev/null
 | 
			
		||||
			echo '	remote=argon' | sudo tee -a $irexecrcfile 1> /dev/null
 | 
			
		||||
			echo '	prog=irexec' | sudo tee -a $irexecrcfile 1> /dev/null
 | 
			
		||||
			echo '	button=KEY_'$keyname | sudo tee -a $irexecrcfile 1> /dev/null
 | 
			
		||||
			echo '	config='$irexecshfile' "'$keyname'"' | sudo tee -a $irexecrcfile 1> /dev/null
 | 
			
		||||
			echo 'end' | sudo tee -a $irexecrcfile 1> /dev/null
 | 
			
		||||
		done
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		echo "#!/bin/bash" | sudo tee $irexecshfile 1> /dev/null
 | 
			
		||||
 | 
			
		||||
		echo '' | sudo tee -a $irexecshfile 1> /dev/null
 | 
			
		||||
		echo 'if [ -z "$1" ]' | sudo tee -a $irexecshfile 1> /dev/null
 | 
			
		||||
		echo 'then' | sudo tee -a $irexecshfile 1> /dev/null
 | 
			
		||||
		echo '        exit' | sudo tee -a $irexecshfile 1> /dev/null
 | 
			
		||||
		echo 'fi' | sudo tee -a $irexecshfile 1> /dev/null
 | 
			
		||||
 | 
			
		||||
		echo '' | sudo tee -a $irexecshfile 1> /dev/null
 | 
			
		||||
 | 
			
		||||
		echo '# Handlers for different key codes' | sudo tee -a $irexecshfile 1> /dev/null
 | 
			
		||||
		echo '# Key codes: UP DOWN LEFT RIGHT BACK PLAYPAUSE MENU HOME OK MUTE VOLUMEUP VOLUMEDOWN' | sudo tee -a $irexecshfile 1> /dev/null
 | 
			
		||||
		echo '' | sudo tee -a $irexecshfile 1> /dev/null
 | 
			
		||||
 | 
			
		||||
		echo 'amixerdevice=$(/usr/bin/amixer scontrols | sed -n "s/^.*'"'\(.*\)'"'.*$/\1/p")' | sudo tee -a $irexecshfile 1> /dev/null
 | 
			
		||||
		echo 'if [ $1 == "VOLUMEUP" ]' | sudo tee -a $irexecshfile 1> /dev/null
 | 
			
		||||
		echo 'then' | sudo tee -a $irexecshfile 1> /dev/null
 | 
			
		||||
		echo '        /usr/bin/amixer set $amixerdevice -- $[$(/usr/bin/amixer get $amixerdevice|grep -o [0-9]*%|sed '"'s/%//'"')+5]%' | sudo tee -a $irexecshfile 1> /dev/null
 | 
			
		||||
		echo 'elif [ $1 == "VOLUMEDOWN" ]' | sudo tee -a $irexecshfile 1> /dev/null
 | 
			
		||||
		echo 'then' | sudo tee -a $irexecshfile 1> /dev/null
 | 
			
		||||
		echo '        /usr/bin/amixer set $amixerdevice -- $[$(/usr/bin/amixer get $amixerdevice|grep -o [0-9]*%|sed '"'s/%//'"')-5]%' | sudo tee -a $irexecshfile 1> /dev/null
 | 
			
		||||
		echo 'elif [ $1 == "MUTE" ]' | sudo tee -a $irexecshfile 1> /dev/null
 | 
			
		||||
		echo 'then' | sudo tee -a $irexecshfile 1> /dev/null
 | 
			
		||||
		echo '        /usr/bin/amixer set $amixerdevice toggle' | sudo tee -a $irexecshfile 1> /dev/null
 | 
			
		||||
		echo 'fi' | sudo tee -a $irexecshfile 1> /dev/null
 | 
			
		||||
 | 
			
		||||
		echo '' | sudo tee -a $irexecshfile 1> /dev/null
 | 
			
		||||
 | 
			
		||||
		sudo chmod 755 $irexecshfile
 | 
			
		||||
	fi	
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ ! -f "$irdecodefile" ]
 | 
			
		||||
then
 | 
			
		||||
	sudo wget https://download.argon40.com/argonone-irdecoder.py -O $irdecodefile --quiet
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
sudo python3 $irdecodefile $remotemode
 | 
			
		||||
 | 
			
		||||
if [ ! -d $kodiuserdatafolder ]
 | 
			
		||||
then
 | 
			
		||||
	if [ ! -d "$HOME/.kodi" ]
 | 
			
		||||
	then
 | 
			
		||||
		mkdir "$HOME/.kodi"
 | 
			
		||||
	fi
 | 
			
		||||
	mkdir $kodiuserdatafolder
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ -d $kodiuserdatafolder ]
 | 
			
		||||
then
 | 
			
		||||
	echo "<lircmap>" | tee $kodilircmapfile 1> /dev/null
 | 
			
		||||
	echo '    <remote device="argon">' | tee -a $kodilircmapfile 1> /dev/null
 | 
			
		||||
	echo '        <left>KEY_LEFT</left>' | tee -a $kodilircmapfile 1> /dev/null
 | 
			
		||||
	echo '        <right>KEY_RIGHT</right>' | tee -a $kodilircmapfile 1> /dev/null
 | 
			
		||||
	echo '        <up>KEY_UP</up>' | tee -a $kodilircmapfile 1> /dev/null
 | 
			
		||||
	echo '        <down>KEY_DOWN</down>' | tee -a $kodilircmapfile 1> /dev/null
 | 
			
		||||
	echo '        <select>KEY_OK</select>' | tee -a $kodilircmapfile 1> /dev/null
 | 
			
		||||
	echo '        <start>KEY_HOME</start>' | tee -a $kodilircmapfile 1> /dev/null
 | 
			
		||||
	echo '        <rootmenu>KEY_MENUBACK</rootmenu>' | tee -a $kodilircmapfile 1> /dev/null
 | 
			
		||||
	echo '        <volumeplus>KEY_VOLUMEUP</volumeplus>' | tee -a $kodilircmapfile 1> /dev/null
 | 
			
		||||
	echo '        <volumeminus>KEY_VOLUMEDOWN</volumeminus>' | tee -a $kodilircmapfile 1> /dev/null
 | 
			
		||||
	echo '    </remote>' | tee -a $kodilircmapfile 1> /dev/null
 | 
			
		||||
	echo '</lircmap>' | tee -a $kodilircmapfile 1> /dev/null
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
echo
 | 
			
		||||
echo "Thank you."
 | 
			
		||||
if [ $needrestart -eq 1 ]
 | 
			
		||||
then
 | 
			
		||||
	echo "Changes should take after reboot."
 | 
			
		||||
elif [ $needinstallation -eq 1 ]
 | 
			
		||||
then
 | 
			
		||||
	sudo systemctl restart lircd.service
 | 
			
		||||
	sudo systemctl restart irexec.service
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										1
									
								
								source/downloaded.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								source/downloaded.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
Files downloaded on: 2022-04-06
 | 
			
		||||
		Reference in New Issue
	
	Block a user