Compare commits

..

No commits in common. "main" and "v0.1.0" have entirely different histories.
main ... v0.1.0

63 changed files with 2430 additions and 307 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

19
.direnv/bin/nix-direnv-reload Executable file
View file

@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -e
if [[ ! -d "/home/willifan/Desktop/desktop-utils" ]]; then
echo "Cannot find source directory; Did you move it?"
echo "(Looking for "/home/willifan/Desktop/desktop-utils")"
echo 'Cannot force reload with this script - use "direnv reload" manually and then try again'
exit 1
fi
# rebuild the cache forcefully
_nix_direnv_force_reload=1 direnv exec "/home/willifan/Desktop/desktop-utils" true
# Update the mtime for .envrc.
# This will cause direnv to reload again - but without re-building.
touch "/home/willifan/Desktop/desktop-utils/.envrc"
# Also update the timestamp of whatever profile_rc we have.
# This makes sure that we know we are up to date.
touch -r "/home/willifan/Desktop/desktop-utils/.envrc" "/home/willifan/Desktop/desktop-utils/.direnv"/*.rc

View file

@ -0,0 +1 @@
/nix/store/pqsj954jryyfldxmv0fgag0ahmyrklbq-nix-shell-env

File diff suppressed because it is too large Load diff

5
.gitignore vendored
View file

@ -1,6 +1,5 @@
/result result
/.vscode .vscode/
/.direnv
# Added by cargo # Added by cargo

View file

@ -1,6 +1,6 @@
[package] [package]
name = "ewwbar" name = "ewwbar"
version = "0.1.2" version = "0.1.0"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View file

@ -1,10 +1,10 @@
{ pkgs ? import <nixpkgs> { } }: { pkgs ? import <nixpkgs> { } }:
pkgs.rustPlatform.buildRustPackage { pkgs.rustPlatform.buildRustPackage {
pname = "ewwbar"; pname = "desktop-utils";
version = "0.1.2"; version = "1.0.0";
src = builtins.path { path = ./.; name = "ewwbar"; }; src = builtins.path { path = ./.; name = "desktop-utils"; };
cargoLock = { cargoLock = {
lockFile = ./Cargo.lock; lockFile = ./Cargo.lock;
@ -16,20 +16,18 @@ pkgs.rustPlatform.buildRustPackage {
buildInputs = [ buildInputs = [
pkgs.libxkbcommon pkgs.libxkbcommon
pkgs.eww
]; ];
postInstall = '' # installPhase = ''
mkdir -p $out/bin # mkdir -p $out/bin
cp -r $src/eww $out/bin/eww # cp clients $out/bin/clients
''; #'';
meta = with pkgs.lib; { meta = with pkgs.lib; {
description = "Top bar using ElKowars Wacky Widgets"; description = "utils for my desktop";
homepage = " git.huwe.mooo.com/willifan/desktop-utils"; homepage = " git.huwe.mooo.com/willifan/desktop-utils";
license = licenses.gpl3; license = licenses.gpl3;
platforms = platforms.unix; platforms = platforms.unix;
mainProgram = "ewwbar";
}; };
} }

View file

@ -35,56 +35,56 @@
:widgetclass "cpu" :widgetclass "cpu"
:hover "${round(EWW_CPU.avg, 1)}%" :hover "${round(EWW_CPU.avg, 1)}%"
:percentage {round(EWW_CPU.avg, 1)} :percentage {round(EWW_CPU.avg, 1)}
:image "./images/cpu.png")) :image "../images/cpu.png"))
(defwidget ram [] (defwidget ram []
(icon (icon
:widgetclass "ram" :widgetclass "ram"
:hover "${round(EWW_RAM.used_mem /(1024*1024*1024), 1)} GiB | ${round(EWW_RAM.used_mem_perc, 1)}%" :hover "${round(EWW_RAM.used_mem /(1024*1024*1024), 1)} GiB | ${round(EWW_RAM.used_mem_perc, 1)}%"
:percentage {round(EWW_RAM.used_mem_perc, 1)} :percentage {round(EWW_RAM.used_mem_perc, 1)}
:image "./images/ram.png")) :image "../images/ram.png"))
(defwidget audio [] (defwidget audio []
(icon (icon
:widgetclass {volume.muted == 1 ? "muted" : "volume"} :widgetclass {volume.muted == 1 ? "muted" : "volume"}
:hover "${volume.volume}%" :hover "${volume.volume}%"
:percentage {volume.volume >= 0 && volume.volume <= 100 ? volume.volume : 0} :percentage {volume.volume >= 0 && volume.volume <= 100 ? volume.volume : 0}
:image {volume.muted == 1 ? "./images/volumeMuted.png" : "./images/volume.png"})) :image {volume.muted == 1 ? "../images/volumeMuted.png" : "../images/volume.png"}))
(defwidget brightness [] (defwidget brightness []
(icon (icon
:widgetclass "brightness" :widgetclass "brightness"
:hover "${brightnessValue / 960}%" :hover "${brightnessValue / 960}%"
:percentage {brightnessValue / 960} :percentage {brightnessValue / 960}
:image "./images/brightness.png")) :image "../images/brightness.png"))
(defwidget network [] (defwidget network []
(icon (icon
:widgetclass "network" :widgetclass "network"
:hover {network.name} :hover {network.name}
:percentage "100" :percentage "100"
:image "./images/${network.image}.png")) :image "../images/${network.image}.png"))
(defwidget bluetooth [] (defwidget bluetooth []
(icon (icon
:widgetclass "bluetooth" :widgetclass "bluetooth"
:hover {bluetooth.name} :hover {bluetooth.name}
:percentage {bluetooth.battery} :percentage {bluetooth.battery}
:image "./images/bluetooth.png")) :image "../images/bluetooth.png"))
(defwidget battery [] (defwidget battery []
(icon (icon
:widgetclass {EWW_BATTERY.BAT1.status == "Charging" ? "battery" : EWW_BATTERY.total_avg > 25 ? "battery" : "batteryLow"} :widgetclass {EWW_BATTERY.BAT1.status == "Charging" ? "battery" : EWW_BATTERY.total_avg > 25 ? "battery" : "batteryLow"}
:hover "${round(EWW_BATTERY.total_avg, 1)}%" :hover "${round(EWW_BATTERY.total_avg, 1)}%"
:percentage {EWW_BATTERY.total_avg <= 90 ? round(EWW_BATTERY.total_avg, 1)/0.9 : 100} :percentage {EWW_BATTERY.total_avg <= 90 ? round(EWW_BATTERY.total_avg, 1)/0.9 : 100}
:image {EWW_BATTERY.BAT1.status == "Charging" ? "./images/charging.png" : EWW_BATTERY.total_avg > 25 ? "./images/battery.png" : "./images/batteryLow.png"})) :image {EWW_BATTERY.BAT1.status == "Charging" ? "../images/charging.png" : EWW_BATTERY.total_avg > 25 ? "../images/battery.png" : "../images/batteryLow.png"}))
(defwidget power [] (defwidget power []
(icon (icon
:widgetclass "power" :widgetclass "power"
:hover "placeholder" :hover "placeholder"
:percentage "0" :percentage "0"
:image "./images/power.png")) :image "../images/power.png"))
@ -271,11 +271,11 @@
(space) (space)
(testtime (testtime
:timezone "US/Eastern" :timezone "US/Eastern"
:image "./images/USTime.png") :image "../images/USTime.png")
(seperator) (seperator)
(testtime (testtime
:timezone "Asia/Seoul" :timezone "Asia/Seoul"
:image "./images/SamGuk-by_Sang_Min.png") :image "../images/SamGuk-by_Sang_Min.png")
(space)) (space))
(box (box
:class "barbox" :class "barbox"
@ -287,13 +287,13 @@
:halign "end" :halign "end"
(space) (space)
;; (systray ;; (systray
;; :spacing 2 ;; :spacing 2
;; :orientation "h" ;; :orientation "h"
;; :space-evenly true ;; :space-evenly true
;; :icon-size 16) ;; :icon-size 16)
;; ;;
;; (seperator) ;; (seperator)
(processing) (processing)

View file

@ -1,25 +1,25 @@
(deflisten brightnessValue (deflisten brightnessValue
:initial "0" :initial "0"
`./scripts/brightness.sh`) `../ewwScripts/brightness.sh`)
(deflisten network (deflisten network
:initial '{"name":"No Connection","image":"n.A."}' :initial '{"name":"No Connection","image":"n.A."}'
`./scripts/network.sh`) `../ewwScripts/network.sh`)
(deflisten workspaces (deflisten workspaces
:initial '' :initial ''
`./scripts/client`) `../ewwScripts/client`)
(defpoll bluetooth (defpoll bluetooth
:initial '{"name":"","battery":"0"}' :initial '{"name":"","battery":"0"}'
:interval "2s" :interval "2s"
`./scripts/bluetooth.sh`) `../ewwScripts/bluetooth.sh`)
(deflisten volume (deflisten volume
:initial '{"volume":"0","muted":"0"}' :initial '{"volume":"0","muted":"0"}'
`./scripts/volume.sh`) `../ewwScripts/volume.sh`)
(defpoll media (defpoll media
:initial '{"status":"","name":""}' :initial '{"status":"","name":""}'
:interval "2s" :interval "2s"
`./scripts/media.sh`) `../ewwScripts/media.sh`)

38
ewwScripts/monitors.sh Executable file
View file

@ -0,0 +1,38 @@
#!/usr/bin/env bash
unset id name horizontal vertical scale activeWorkspace
i=0
while read -r k n h v s t; do
id[i]="$k"
name[i]="$n"
horizontal[i]="$h"
vertical[i]="$v"
scale[i]="$s"
if [[ $((t%2)) == 1 ]]; then
temp=${vertical[$i]}
vertical[i]=${horizontal[$i]}
horizontal[i]=$temp
fi
((i=i+1))
done < <(hyprctl monitors -j | jq -r '.[]|"\(.id) \(.name) \(.width) \(.height) \(.scale) \(.transform)"')
eww close-all --config ../eww
sleep 2
for ((i = 0; i < ${#id[@]}; i++)); do
scale_value=$(echo "${scale[$i]}" | bc -l)
new_width_float=$(echo "(${horizontal[$i]} / ${scale_value}) -10" | bc)
new_width=$(echo "$new_width_float / 1" | bc)
monitorID=$(xrandr --listactivemonitors | grep +"${name[$i]}" | awk '{sub(/.$/,"",$1); print $1}')
eww open bar --id bar"${monitorID}" --arg monitor="${monitorID}" --arg width="${new_width}" --arg height=30 --config ../eww
sleep 2
done

33
ewwScripts/test.sh Executable file
View file

@ -0,0 +1,33 @@
#!/usr/bin/env bash
getIcon() {
local desktop=""
# Search for desktop files by WM class
if [ -n "$1" ]; then
desktop=$(grep -l "StartupWMClass.*$1$" /run/current-system/sw/share/applications/*.desktop)
[ -z "$desktop" ] && desktop=$(grep -Pl "Name\s*=\s*$1$" /run/current-system/sw/share/applications/*.desktop)
[ -z "$desktop" ] && desktop=$(ls /run/current-system/sw/share/applications/"${1}".desktop 2>/dev/null)
fi
# If not found by WM class, search by process name
if [ -z "$desktop" ] && [ -n "$2" ]; then
process=$(ps -p "${2}" -o comm=)
desktop=$(grep -Pl "$process" /run/current-system/sw/share/applications/*.desktop)
[ -n "$desktop" ]
fi
# If not found by WM class or process name, search by name or description
if [ -z "$desktop" ] && [ -n "$1" ]; then
desktop=$(grep -Pl "$1" /run/current-system/sw/share/applications/*.desktop)
fi
echo "$desktop"
}
desktop=$(getIcon "$1" "$2")
if [ -n "$desktop" ]; then
desktop=$(echo "$desktop" | awk 'NR==1')
icon=$(awk -F'[[:space:]]*=[[:space:]]*' '/Icon[[:space:]]*=/ && !seen[$2]++ {print $2; exit}' "$desktop")
echo -n "${icon}.svg"
fi

View file

Before

Width:  |  Height:  |  Size: 734 KiB

After

Width:  |  Height:  |  Size: 734 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 9.7 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

Before After
Before After

1
result Symbolic link
View file

@ -0,0 +1 @@
/nix/store/mp0zkc5iaf73f3yiq606qvfpqvs48q5i-desktop-utils-1.0.0

7
scripts/idle.sh Executable file
View file

@ -0,0 +1,7 @@
#!/usr/bin/env bash
if [[ $(acpi -a | awk '{print $3}') == "on-line" ]]; then
swaylock
else
systemctl suspend-then-hibernate
fi

7
scripts/lock.sh Executable file
View file

@ -0,0 +1,7 @@
#!/usr/bin/env bash
swaylock &
sleep 0.1
hyprctl dispatch dpms off

10
scripts/scale.sh Executable file
View file

@ -0,0 +1,10 @@
#!/usr/bin/env bash
while read -r f s; do
if [[ $f == true && $(awk -v s="$s" 'BEGIN{ if (s > 1.5) print 1; else print 0; }') == 1 ]]; then
export GDK_SCALE=2
export QT_SCALE_FACTOR=2
fi
done < <(hyprctl monitors -j | jq -r '.[]|"\(.focused) \(.scale)"')
wofi --show drun

0
scripts/startup.sh Normal file
View file

View file

@ -7,7 +7,6 @@ pkgs.mkShell {
pkgs.cargo pkgs.cargo
pkgs.pkg-config pkgs.pkg-config
pkgs.libxkbcommon pkgs.libxkbcommon
pkgs.eww
pkgs.rust-analyzer pkgs.rust-analyzer
pkgs.clippy pkgs.clippy

View file

@ -12,22 +12,13 @@ use smithay_client_toolkit::{
use wayland_client::{globals::registry_queue_init, protocol::wl_output, Connection, QueueHandle}; use wayland_client::{globals::registry_queue_init, protocol::wl_output, Connection, QueueHandle};
const CONFIG_DIR: &str = "./eww"; const CONFIG_DIR: &str = "/home/willifan/.config/desktop-utils/eww";
fn main() -> Result<(), Box<dyn Error>> { fn main() -> Result<(), Box<dyn Error>> {
// We initialize the logger for the purpose of debugging. // We initialize the logger for the purpose of debugging.
// Set `RUST_LOG=debug` to see extra debug information. // Set `RUST_LOG=debug` to see extra debug information.
env_logger::init(); env_logger::init();
let exe_path = std::env::current_exe()?
.parent()
.unwrap()
.to_str()
.unwrap()
.to_owned();
let config_path = exe_path + "/eww";
println!("Path: {}", config_path);
// Try to connect to the Wayland server. // Try to connect to the Wayland server.
let conn = Connection::connect_to_env()?; let conn = Connection::connect_to_env()?;
@ -81,7 +72,7 @@ fn main() -> Result<(), Box<dyn Error>> {
"--arg", "--arg",
"height=30", "height=30",
"--config", "--config",
&config_path, CONFIG_DIR, //TODO make this path implicit
]) ])
.spawn() .spawn()
.expect("failed to execute process"); .expect("failed to execute process");