From d33905058e31a326821d898c25576f56190e1829 Mon Sep 17 00:00:00 2001 From: Asocia Date: Wed, 26 Jan 2022 04:13:26 +0300 Subject: [PATCH] Add required files --- .config/qtile/polybar/launch.sh | 47 ++++++++++++++++++++++++++++++++ .config/qtile/polybar/system.ini | 27 ++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100755 .config/qtile/polybar/launch.sh create mode 100644 .config/qtile/polybar/system.ini diff --git a/.config/qtile/polybar/launch.sh b/.config/qtile/polybar/launch.sh new file mode 100755 index 0000000..18ab4cb --- /dev/null +++ b/.config/qtile/polybar/launch.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +## Copyright (C) 2020-2021 Aditya Shakya +## Everyone is permitted to copy and distribute copies of this file under GNU-GPL3 + +## Files and Directories +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +SFILE="$DIR/system.ini" +RFILE="$DIR/.system" + +## Get system variable values for various modules +get_values() { + CARD=$(light -L | grep 'backlight' | head -n1 | cut -d'/' -f3) + BATTERY=$(upower -i `upower -e | grep 'BAT'` | grep 'native-path' | cut -d':' -f2 | tr -d '[:blank:]') + ADAPTER=$(upower -i `upower -e | grep 'AC'` | grep 'native-path' | cut -d':' -f2 | tr -d '[:blank:]') + INTERFACE=$(ip link | awk '/state UP/ {print $2}' | tr -d :) +} + +## Write values to `system.ini` file +set_values() { + if [[ "$ADAPTER" ]]; then + sed -i -e "s/adapter = .*/adapter = $ADAPTER/g" ${SFILE} + fi + if [[ "$BATTERY" ]]; then + sed -i -e "s/battery = .*/battery = $BATTERY/g" ${SFILE} + fi + if [[ "$CARD" ]]; then + sed -i -e "s/graphics_card = .*/graphics_card = $CARD/g" ${SFILE} + fi + if [[ "$INTERFACE" ]]; then + sed -i -e "s/network_interface = .*/network_interface = $INTERFACE/g" ${SFILE} + fi +} + +## Launch Polybar with selected style +launch_bar() { + STYLE="default" + bash "$HOME"/.config/qtile/polybar/"$STYLE"/launch.sh +} + +# Execute functions +if [[ ! -f "$RFILE" ]]; then + get_values + set_values + touch ${RFILE} +fi +launch_bar diff --git a/.config/qtile/polybar/system.ini b/.config/qtile/polybar/system.ini new file mode 100644 index 0000000..1d12512 --- /dev/null +++ b/.config/qtile/polybar/system.ini @@ -0,0 +1,27 @@ +## Copyright (C) 2020-2021 Aditya Shakya +## Everyone is permitted to copy and distribute copies of this file under GNU-GPL3 +;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ +;; +;; System Variables (Edit according to your system) +;; +;; Warning : DO NOT DELETE THIS FILE +;; +;; Run `ls -1 /sys/class/power_supply/` to list list batteries and adapters. +;; +;; Run `ls -1 /sys/class/backlight/` to list available graphics cards. +;; +;; Run `ip link | awk '/state UP/ {print $2}' | tr -d :` to get active network interface. +;; +;; Polybar Variables For Modules : +;; card = ${system.graphics_card} +;; battery = BAT0 +;; adapter = AC +;; interface = ${system.network_interface} + +[system] +adapter = AC0 +battery = BAT0 +graphics_card = intel_backlight +network_interface = enp3s0 + +;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_