From 8e5166a3f84ef8ee93319defb052f38802a842f0 Mon Sep 17 00:00:00 2001 From: afonsofrancof Date: Fri, 13 Oct 2023 10:27:49 +0100 Subject: [PATCH] [MAJOR] updated xmobar scripts (battery and updates) --- .config/xmobar/scripts/battery.sh | 15 +++++++++++++-- .config/xmobar/scripts/updates.sh | 4 ++++ .config/xmobar/xmobarrc | 23 +++++++++++------------ 3 files changed, 28 insertions(+), 14 deletions(-) create mode 100755 .config/xmobar/scripts/updates.sh diff --git a/.config/xmobar/scripts/battery.sh b/.config/xmobar/scripts/battery.sh index 81a7de3..7bb01e0 100755 --- a/.config/xmobar/scripts/battery.sh +++ b/.config/xmobar/scripts/battery.sh @@ -1,8 +1,19 @@ #!/bin/bash -if [ "$(acpi)" == "No support for device type: power_supply" ] +#Check if its laptop of pc with hostnamectl + +pctype=$(hostnamectl | grep -Po '(Chassis: )(\w+)' | sed 's/Chassis: //') +if [ "$pctype" == "desktop" ]; then - echo "" + #Check if any connected device has a battery with upower + xm3bat=$(upower -i /org/freedesktop/UPower/devices/headset_dev_94_DB_56_AB_B5_D4 | grep -Po '(percentage: *)(\d+)' | sed 's/\s*percentage: //' | xargs) + if [ "$xm3bat" == 0 ]; + then + echo "" + exit 0 + fi + echo "󰋋 $xm3bat%" + exit 0 fi batLevel=$(acpi --battery | grep -Po '(\d+)\%' | sed 's/%//') diff --git a/.config/xmobar/scripts/updates.sh b/.config/xmobar/scripts/updates.sh new file mode 100755 index 0000000..ed93d23 --- /dev/null +++ b/.config/xmobar/scripts/updates.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +update_number=$(checkupdates | wc -l) +echo "󰣇 $update_number" diff --git a/.config/xmobar/xmobarrc b/.config/xmobar/xmobarrc index 5b77932..dd4773d 100644 --- a/.config/xmobar/xmobarrc +++ b/.config/xmobar/xmobarrc @@ -22,18 +22,16 @@ Config {font = "Ubuntu bold 10" , persistent = False , iconRoot = "/home/afonso/.config/xmobar/xpm/" -- default: "." , commands = [ - Run XMonadLog + Run XMonadLog , Run Date "%a, %d %b  %H:%M" "date" 10 , Run Mpris2 "playerctld" ["-t", " - </fc>"] 10 - , Run Memory ["-t","<fn=6></fn> <fc=#AAC0F0><usedratio></fc>%"] 10 - , Run Com "/home/afonso/.config/xmobar/scripts/disk.sh" [] "disk" 10 - , Run Com "/home/afonso/.config/xmobar/scripts/cpu_temp.sh" [] "cpu" 10 - , Run Com "/home/afonso/.config/xmobar/scripts/volume.sh" [] "volume" 10 - , Run Com "/home/afonso/.config/xmobar/scripts/bluetooth.sh" [] "bluetooth" 10 - , Run Com "/home/afonso/.config/xmobar/scripts/network.sh" [] "network" 10 - , Run Com "/home/afonso/.config/xmobar/scripts/battery.sh" [] "battery" 20 - , Run Com "/home/afonso/.config/xmobar/scripts/trayer-padding-icon.sh" [] "trayerpad" 20 - ] + , Run Memory ["-t","<fn=6></fn> <fc=#AAC0F0><usedratio></fc>%"] 50 + , Run Com "/home/afonso/.config/xmobar/scripts/disk.sh" [] "disk" 100 + , Run Com "/home/afonso/.config/xmobar/scripts/cpu_temp.sh" [] "cpu" 50 + , Run Com "/home/afonso/.config/xmobar/scripts/battery.sh" [] "battery" 50 + , Run Com "/home/afonso/.config/xmobar/scripts/updates.sh" [] "updates" 6000 + , Run Com "/home/afonso/.config/xmobar/scripts/trayer-padding-icon.sh" [] "trayerpad" 20 + ] , sepChar = "%" , alignSep = "}{" , template = " <icon=logo.xpm/> \ @@ -47,6 +45,9 @@ Config {font = "Ubuntu bold 10" \ \ \|\ \ \ + \%updates%\ + \ \ + \ \ \%memory%\ \ \ \ \ @@ -57,8 +58,6 @@ Config {font = "Ubuntu bold 10" \ \ \ \ \%battery%\ - \ \ - \ \ \|\ \%trayerpad%" }