Compare commits

...

2 Commits

Author SHA1 Message Date
93365a5492 22-03-2025
-Makefile
-.plist
2025-03-22 15:17:44 +01:00
f0bc67729a 22-03-2024
bugfix:
-size with To
- figlet not in $PATH
features:
-Makefile
-.plist
2025-03-22 15:16:57 +01:00
3 changed files with 104 additions and 7 deletions

13
Makefile Normal file
View File

@@ -0,0 +1,13 @@
.PHONY: install
install:
./update-motd.sh
mkdir -p ${HOME}/Library/LaunchAgents/
cp com.bruno21.update-motd.plist ${HOME}/Library/LaunchAgents/
launchctl load -w ${HOME}/Library/LaunchAgents/com.bruno21.update-motd.plist
launchctl list | grep .update-motd
uninstall:
sudo launchctl unload -w ${HOME}/Library/LaunchAgents/com.bruno21.update-motd.plist
rm ${HOME}/Library/LaunchAgents/com.bruno21.update-motd.plist
launchctl list | grep update-motd || exit 0

View File

@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.bruno21.update-motd</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
<string>${HOME}/.local/bin/update-motd.sh</string>
</array>
<key>StartCalendarInterval</key>
<array>
<dict>
<key>Minute</key>
<integer>0</integer>
</dict>
<dict>
<key>Minute</key>
<integer>5</integer>
</dict>
<dict>
<key>Minute</key>
<integer>10</integer>
</dict>
<dict>
<key>Minute</key>
<integer>15</integer>
</dict>
<dict>
<key>Minute</key>
<integer>20</integer>
</dict>
<dict>
<key>Minute</key>
<integer>25</integer>
</dict>
<dict>
<key>Minute</key>
<integer>30</integer>
</dict>
<dict>
<key>Minute</key>
<integer>35</integer>
</dict>
<dict>
<key>Minute</key>
<integer>40</integer>
</dict>
<dict>
<key>Minute</key>
<integer>45</integer>
</dict>
<dict>
<key>Minute</key>
<integer>50</integer>
</dict>
<dict>
<key>Minute</key>
<integer>55</integer>
</dict>
</array>
<key>StandardOutPath</key>
<string>/tmp/com.bruno21.update-motd.out</string>
<key>StandardErrorPath</key>
<string>/tmp/com.bruno21.update-motd.err</string>
</dict>
</plist>

View File

@@ -1,5 +1,5 @@
#!/bin/bash
PATH="${PATH}:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
PATH="${PATH}:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin/"
COLOR_LIGHT_GREEN='\033[0;32m'
COLOR_LIGHT_BLUE='\033[0;34m'
@@ -23,10 +23,20 @@ nb_cores="$(echo "$cores" | awk -F" " '{print $1}') cores"
type_cores=$(echo "$cores" | cut -f2- -d' ')
core="$nb_cores ""$type_cores"
diskSize=$(diskutil info /dev/disk3s1 | grep Total | awk '{ print int($4) }')
diskFree=$(diskutil info /dev/disk3s1 | grep Free | awk '{ print int($4) }')
# Container Total Space: 2.0 TB (1995218165760 Bytes) (exactly 3896910480 512-Byte-Units)
diskSize=$(diskutil info /dev/disk3s1 | grep Total | awk -F" " '{print $6}' | sed 's/(//')
# Container Free Space: 1.6 TB (1618374803456 Bytes) (exactly 3160888288 512-Byte-Units)
diskFree=$(diskutil info /dev/disk3s1 | grep Free | awk -F" " '{print $6}' | sed 's/(//')
# Disk occupé
diskUsage=$((${diskSize} - ${diskFree}))
diskUsage=$(printf %s\\n $diskUsage | numfmt --to=iec --suffix=B | sed 's/,/./')
diskFree=$(printf %s\\n $diskFree | numfmt --to=iec --suffix=B | sed 's/,/./')
diskSize=$(printf %s\\n $diskSize | numfmt --to=iec --suffix=B | sed 's/,/./')
profiler=$(system_profiler SPSoftwareDataType | tail -n10 | cut -c 5- )
_sip=$(echo "$profiler" | grep 'System Integrity' | awk -F":" '{print $2}' | xargs)
_sv_mem=$(echo "$profiler" | grep 'Virtual Memory' | awk -F":" '{print $2}' | xargs)
@@ -40,9 +50,12 @@ networkservice=$(echo "$list_network" | grep "$interface" | awk -F":" '{print $1
local_ip=$(ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}')
dat=$(date)
# | lolcat
echo -e "
${COLOR_LIGHT_GREEN}$(figlet -ckw 100 -f slant $(hostname | sed -e 's/.local//'))
${COLOR_WHITE}Hostname : ${COLOR_LIGHT_BLUE}$(hostname)
${COLOR_WHITE}Private IP Address : ${COLOR_LIGHT_BLUE}$(ifconfig en0 2>/dev/null | grep 'inet ' | cut -d ' ' -f 2)
${COLOR_WHITE}Current interface : ${COLOR_LIGHT_BLUE}${networkservice} (${interface})
@@ -52,8 +65,10 @@ ${COLOR_WHITE}OS Info : ${COLOR_LIGHT_BLUE}${osname} ${version} ($
${COLOR_WHITE}Model (Number) : ${COLOR_LIGHT_BLUE}${identifier} (${number})
${COLOR_WHITE}CPU : ${COLOR_LIGHT_BLUE}${chip} (${core})
${COLOR_WHITE}Memory : ${COLOR_LIGHT_BLUE}${memory}
${COLOR_WHITE}Disk Used/Total : ${COLOR_LIGHT_BLUE}${diskUsage}Go / ${diskSize}Go
${COLOR_WHITE}Disk Used/Total : ${COLOR_LIGHT_BLUE}${diskUsage} / ${diskSize}
${COLOR_WHITE}Secure Virtual Memory : ${COLOR_LIGHT_BLUE}${_sv_mem}
${COLOR_WHITE}SIP : ${COLOR_LIGHT_BLUE}${_sip}
${COLOR_WHITE}Uptime : ${COLOR_LIGHT_BLUE}${_uptime}" | lolcat
#${COLOR_WHITE}" > /etc/motd
${COLOR_WHITE}Uptime : ${COLOR_LIGHT_BLUE}${_uptime}
${COLOR_WHITE}Date : ${COLOR_LIGHT_BLUE}${dat}
${COLOR_WHITE}" > /etc/motd