imported previous rust projects and cleaned up unused files

This commit is contained in:
willifan 2024-05-23 18:56:06 +02:00
parent 0166b32872
commit 10b8db251b
432 changed files with 874 additions and 1585 deletions

4
.gitignore vendored
View file

@ -1,2 +1,6 @@
scripts/clients/build/
.vscode/
# Added by cargo
/target

89
Cargo.lock generated Normal file
View file

@ -0,0 +1,89 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "ewwbar"
version = "0.1.0"
dependencies = [
"serde",
"serde_json",
]
[[package]]
name = "itoa"
version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
[[package]]
name = "proc-macro2"
version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b33eb56c327dec362a9e55b3ad14f9d2f0904fb5a5b03b513ab5465399e9f43"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
dependencies = [
"proc-macro2",
]
[[package]]
name = "ryu"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
[[package]]
name = "serde"
version = "1.0.202"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.202"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.117"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3"
dependencies = [
"itoa",
"ryu",
"serde",
]
[[package]]
name = "syn"
version = "2.0.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2863d96a84c6439701d7a38f9de935ec562c8832cc55d1dde0f513b52fad106"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"

8
Cargo.toml Normal file
View file

@ -0,0 +1,8 @@
[package]
name = "ewwbar"
version = "0.1.0"
edition = "2021"
[dependencies]
serde = "1.0.199"
serde_json = "1.0.116"

View file

@ -1,10 +0,0 @@
(defwindow example
:monitor 0
:geometry (geometry :x "0%"
:y "20px"
:width "50%"
:height "50px"
:anchor "top center")
:stacking "fg"
"example content")

View file

@ -1,70 +0,0 @@
.bar {
border-width: 2px;
border-color: #595959;
border-radius: 12.5px;
}
.calendar {
border-width: 2px;
border-color: #595959;
border-radius: 12.5px;
}
.power {
border-width: 2px;
border-color: #595959;
border-radius: 12.5px;
}
.activeWorkspace {
color: green;
}
.cpu {
color: red;
}
.ram {
color: green;
}
.volume {
color: lavender;
}
.brightness {
color: yellow;
}
.network {
color: orange;
}
.bluetooth {
color: lightblue;
}
.battery {
color: lightgreen;
}
.batteryLow {
color: red;
}
.power {
color: darkred;
}
.time {
}
.workspaces {
}
.playback {
}

View file

@ -1,242 +0,0 @@
;;Input values
(deflisten monitors
:initial "[]"
`scripts/monitors.sh`)
(defvar brightnessValue 96000)
(defpoll activeNetworks
:interval "2s"
`nmcli connection show --active | awk 'NR>1 && $3!="loopback" { print $1 }'`)
(deflisten workspaces
:initial "[]"
`scripts/workspaces.sh`)
(defpoll activeWorkspace
:interval "2s"
`hyprctl activeworkspace | awk 'NR==1{print $3}'`)
(deflisten bluetooth
:initial "[]"
`scripts/bluetooth.sh`)
(defvar volumeValue 100)
;; Widget templates
(defwidget icon [widgetclass ?hover percentage image]
(box
:class "${widgetclass}"
:space-evenly false
(overlay
:tooltip "${hover}"
(circular-progress
:width 20
:value "${percentage}"
:start-at 75
:thickness 2
:clockwise false)
(transform
:scale-x "50%"
:scale-y "50%"
:halign "center"
:valign "center"
:translate-x "16"
:translate-y "16"
(image
:path "${image}"
:image-width "32"
:image-height "32")))))
;; Widgets
(defwidget workspaces []
(box
(for workspace in workspaces
(label
:width "15"
:class {workspace.active == 1 ? "activeWorkspace" :""}
:visible {workspace.occupied == 1 ? "true" : "false"}
:text "${workspace.num}"))))
(defwidget time []
(eventbox
:onhover "eww open calendar"
:onhoverlost "eww close calendar"
{formattime(EWW_TIME, "%H:%M:%S")}))
(defwidget cpu []
(icon
:widgetclass "cpu"
:hover "${round(EWW_CPU.avg, 1)}%"
:percentage "${round(EWW_CPU.avg, 1)}"
:image "images/cpu.png"))
(defwidget ram []
(icon
:widgetclass "ram"
:hover "${round(EWW_RAM.used_mem_perc, 1)}%"
:percentage "${round(EWW_RAM.used_mem_perc, 1)}"
:image "images/ram.png"))
(defwidget volume []
(icon
:widgetclass "volume"
:hover "${volumeValue}%"
:percentage "${volumeValue}"
:image "images/volume.png"))
(defwidget brightness []
(icon
:widgetclass "brightness"
:hover "${brightnessValue / 960}%"
:percentage "${brightnessValue / 960}"
:image "images/brightness.png"))
(defwidget network []
(icon
:widgetclass "network"
:hover "${activeNetworks}"
:percentage "0"
:image "images/wifi.png"))
;;(defwidget bluetooth []
;; (icon
;; :widgetclass "bluetooth"
;; :hover "${bluetoothDevices}"
;; :percentage "${bluetoothBattery}"
;; :image "images/bluetooth.png"))
(defwidget battery []
(icon
:widgetclass {EWW_BATTERY.BAT1.status == "Charging" ? "battery" : EWW_BATTERY.total_avg > 25 ? "battery" : "batteryLow"}
:hover "${round(EWW_BATTERY.total_avg, 1)}%"
:percentage "${round(EWW_BATTERY.total_avg, 1)}"
:image {EWW_BATTERY.BAT1.status == "Charging" ? "images/charging.png" : EWW_BATTERY.total_avg > 25 ? "images/battery.png" : "images/batteryLow.png"}))
(defwidget power []
(icon
:widgetclass "power"
:hover "placeholder"
:percentage "0"
:image "images/power.png"))
(defwidget space []
(box
:width 5))
(defwidget seperator []
(box
:width 20
(label
:text "|"
)))
(defwidget cal []
(calendar
:day {formattime(EWW_TIME, "%d")}
:month {formattime(EWW_TIME, "%m")}
:year {formattime(EWW_TIME, "%y")}))
(defwidget winPower []
(box
:orientation "v"
(box
:halign "end"
(power))))
;; Widget blocks
(defwidget start []
(box
:orientation "h"
:space-evenly false
:halign "start"
(space)
(workspaces)))
(defwidget center []
(box
:orientation "h"
:space-evenly false
:halign "center"
(time)))
(defwidget end []
(box
:orientation "h"
:space-evenly false
:halign "end"
(cpu)
(space)
(ram)
(seperator)
(volume)
(space)
(brightness)
(seperator)
(network)
(space)
;; (bluetooth)
(seperator)
(battery)
(space)
(power)))
(defwidget bar []
(centerbox :orientation "h"
(start)
(center)
(end)))
;; Window definition
(defwindow bar
:monitor 0
:class "bar"
:geometry (geometry
:x "0%"
:y "5px"
:width "1279px"
:height "3%"
:anchor "top center")
:stacking "fg"
:exclusive true
(bar))
(defwindow calendar
:monitor 0
:class "calendar"
:geometry
(geometry
:x "0%"
:y "5px"
:width "0%"
:height "0%"
:anchor "top center")
:stacking "overlay"
(cal))
(defwindow power
:monitor 0
:class "bars"
:geometry
(geometry
:x "5px"
:y "5px"
:width "2%"
:height "3%"
:anchor "top right")
:stacking "fg"
(winPower))

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

View file

@ -1,22 +0,0 @@
#!/bin/bash
# Get the list of connected Bluetooth devices
devices=$(bluetoothctl devices Connected | awk '{print $2}')
# Iterate through each device and get its name and battery percentage
for device in $devices; do
# Get the device info using bluetoothctl
info=$(bluetoothctl info $device)
# Extract the name and battery percentage from the device info
name=$(echo "$info" | grep "Name" | awk '{ for(i=2; i<=NF; i++) printf "%s ", $i;}')
battery=$(echo "$info" | grep "Battery" | awk '{print $4}' | tr -d '()')
done
eww update bluetoothDevices="$name: $battery%"
eww update bluetoothBattery="$battery"
if [[ !$devices ]]; then
eww update bluetoothBattery="0"
fi

View file

@ -1,38 +0,0 @@
#!/bin/bash
brightness_file="/sys/class/backlight/intel_backlight/brightness"
min_brightness=1
max_brightness=96000
# Check if an argument is provided
if [[ -z $1 ]]; then
echo "Error: Number argument is missing."
exit 1
fi
# Retrieve the argument value
number_to_add=$1
# Validate if the argument is a number
if ! [[ $number_to_add =~ ^-?[0-9]+$ ]]; then
echo "Error: Invalid number argument."
exit 1
fi
# Read the current brightness value from the file
current_brightness=$(cat "$brightness_file")
# Add the desired number to the current brightness
new_brightness=$((current_brightness + number_to_add))
# Enforce minimum and maximum brightness values
if (( new_brightness < min_brightness )); then
new_brightness=$min_brightness
elif (( new_brightness > max_brightness )); then
new_brightness=$max_brightness
fi
# Write the new brightness value back to the file
echo "$new_brightness" >> "$brightness_file"
eww update brightnessValue="$new_brightness"

View file

@ -1,34 +0,0 @@
#!/bin/bash
declare -A id
declare -A horizontal
declare -A vertical
declare -A scale
generate() {
while read -r k h v s f; do
id[$k]="$k"
horizontal[$k]="$h"
vertical[$k]="$v"
scale[$k]="$s"
done < <(hyprctl monitors -j | jq -r '.[]|"\(.id) \(.width) \(.height) \(.scale)"')
echo -n '['
for ((i = 0; i < ${#id[@]}; i++)); do
echo -n ''$([ $i -eq 0 ] || echo ,)'{"id":"'$i'","width":"'${horizontal[$i]}'","height":"'${vertical[$i]}'",".scale":"'${scale[$i]}'"}'
done
echo ']'
}
generate
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | while read -r line; do
if [[ ${line%>>*} == "monitor"* ]]; then
generate
fi
done

View file

@ -1,3 +0,0 @@
#!/bin/bash
whoami > /home/willifan/text.txt

View file

@ -1,19 +0,0 @@
#!/bin/bash
#!/bin/bash
windows=()
workspaces=()
i=0
while read -r k v; do
windows[$i]="$k"
i=$i+1
workspaces[$i]="$v"
done < <(hyprctl clients -j | jq -r '.[]|"\(.pid) \(.workspace.id)"')
for window in ${!windows[@]}; do
echo $(ps -p ${windows[$window]} -o comm=)
done
test=$(ps -p ${windows[5]} -o comm=)
$(feh /usr/share/icons/Papirus-Dark/128x128/apps/${test}.svg)

View file

@ -1,36 +0,0 @@
#!/bin/bash
min_volume="0"
max_volume="100"
# Check if an argument is provided
if [[ -z $1 ]]; then
echo "Error: Number argument is missing."
exit 1
fi
# Retrieve the argument value
number_to_add=$1
# Validate if the argument is a number
if ! [[ $number_to_add =~ ^-?[0-9]+$ ]]; then
echo "Error: Invalid number argument."
exit 1
fi
# Read the current brightness value from the file
current_volume=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print $2 * 100}')
# Add the desired number to the current brightness
new_volume=$((current_volume + number_to_add))
# Enforce minimum and maximum brightness values
if (( new_volume < min_volume )); then
new_volume=$min_volume
elif (( new_volume > max_volume )); then
new_volume=$max_volume
fi
wpctl set-volume @DEFAULT_AUDIO_SINK@ "${new_volume}%"
eww update volumeValue="$new_volume"

View file

@ -1,113 +0,0 @@
#!/bin/bash
# get initial focused workspace
focusedws=$(hyprctl -j monitors | jq -r '.[] | select(.focused == true) | .activeWorkspace.id')
declare -A o=([1]=0 [2]=0 [3]=0 [4]=0 [5]=0 [6]=0 [7]=0 [8]=0 [9]=0 [10]=0)
declare -A monitormap
declare -A workspaces
# handle workspace create/destroy
workspace_event() {
if (( $1 <= 10 )); then
o[$1]=$2
while read -r k v; do workspaces[$k]="$v"; done < <(hyprctl -j workspaces | jq -r '.[]|"\(.id) \(.monitor)"')
fi
if [ "$2" == "0" ]; then
unset "workspaces[$1]"
fi
}
# handle monitor (dis)connects
monitor_event() {
while read -r k v; do monitormap["$k"]=$v; done < <(hyprctl -j monitors | jq -r '.[]|"\(.name) \(.id) "')
}
# generate the json for eww
generate() {
activeWorkspace=$(hyprctl -j monitors | jq -r '.[] | select(.focused == true) | .activeWorkspace.id')
echo -n '['
for i in {1..10}; do
active=0
if [[ $activeWorkspace == $i ]]; then
active=1
fi
echo -n ''$([ $i -eq 1 ] || echo ,)'{"num":"'$i'","occupied":"'${o[$i]}'","active":"'$active'"}'
# echo -n ''$([ $i -eq 1 ] || echo ,) '{ "number": "'"$i"'", "activity": "'"$(status_activity $i)"'", "color": "'$(status "$i")'" }'
done
# echo -n ',{"num":"'$focusedws'","clr":"'$(status "$focusedws")'"}'
echo ']'
}
# setup
# add monitors
monitor_event
# add workspaces
while read -r k v; do workspaces[$k]="$v"; done < <(hyprctl -j workspaces | jq -r '.[]|"\(.id) \(.monitor)"')
# get active workspace
activeWorkspace=$(hyprctl -j monitors | jq -r '.[] | select(.focused == true) | .activeWorkspace.id')
# check occupied workspaces
for num in "${!workspaces[@]}"; do
o[$num]=1
done
# generate initial widget
generate
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | while read -r line; do
# echo "${#workspaces[@]} ${#o[@]}"
# echo $line
case ${line%>>*} in
"focusedmon")
focusedws=${line#*,}
generate
;;
"createworkspace")
# workspace_event "${line#*>>}" 1
o=([1]=0 [2]=0 [3]=0 [4]=0 [5]=0 [6]=0 [7]=0 [8]=0 [9]=0 [10]=0)
workspaces=()
# add workspaces
while read -r k v; do workspaces[$k]="$v"; done < <(hyprctl -j workspaces | jq -r '.[]|"\(.id) \(.monitor)"')
# check occupied workspaces
for num in "${!workspaces[@]}"; do
o[$num]=1
done
# focusedws=${line#*>>}
generate
;;
"movewindow")
generate
;;
"destroyworkspace")
# workspace_event "${line#*>>}" 0
o=([1]=0 [2]=0 [3]=0 [4]=0 [5]=0 [6]=0 [7]=0 [8]=0 [9]=0 [10]=0)
workspaces=()
# add workspaces
while read -r k v; do workspaces[$k]="$v"; done < <(hyprctl -j workspaces | jq -r '.[]|"\(.id) \(.monitor)"')
# check occupied workspaces
for num in "${!workspaces[@]}"; do
o[$num]=1
done
generate
;;
"monitor"*)
monitor_event
generate
;;
"workspace")
generate
;;
esac
# echo $line
# generate
done

View file

@ -1,10 +0,0 @@
(defwindow example
:monitor 0
:geometry (geometry :x "0%"
:y "20px"
:width "50%"
:height "50px"
:anchor "top center")
:stacking "fg"
"example content")

View file

@ -1,70 +0,0 @@
.bar {
border-width: 2px;
border-color: #595959;
border-radius: 12.5px;
}
.calendar {
border-width: 2px;
border-color: #595959;
border-radius: 12.5px;
}
.power {
border-width: 2px;
border-color: #595959;
border-radius: 12.5px;
}
.activeWorkspace {
color: green;
}
.cpu {
color: red;
}
.ram {
color: green;
}
.volume {
color: lavender;
}
.brightness {
color: yellow;
}
.network {
color: orange;
}
.bluetooth {
color: lightblue;
}
.battery {
color: lightgreen;
}
.batteryLow {
color: red;
}
.power {
color: darkred;
}
.time {
}
.workspaces {
}
.playback {
}

View file

@ -1,242 +0,0 @@
;;Input values
(deflisten monitors
:initial "[]"
`scripts/monitors.sh`)
(defvar brightnessValue 96000)
(defpoll activeNetworks
:interval "2s"
`nmcli connection show --active | awk 'NR>1 && $3!="loopback" { print $1 }'`)
(deflisten workspaces
:initial "[]"
`scripts/workspaces.sh`)
(defpoll activeWorkspace
:interval "2s"
`hyprctl activeworkspace | awk 'NR==1{print $3}'`)
(deflisten bluetooth
:initial "[]"
`scripts/bluetooth.sh`)
(defvar volumeValue 100)
;; Widget templates
(defwidget icon [widgetclass ?hover percentage image]
(box
:class "${widgetclass}"
:space-evenly false
(overlay
:tooltip "${hover}"
(circular-progress
:width 20
:value "${percentage}"
:start-at 75
:thickness 2
:clockwise false)
(transform
:scale-x "50%"
:scale-y "50%"
:halign "center"
:valign "center"
:translate-x "16"
:translate-y "16"
(image
:path "${image}"
:image-width "32"
:image-height "32")))))
;; Widgets
(defwidget workspaces []
(box
(for workspace in workspaces
(label
:width "15"
:class {workspace.active == 1 ? "activeWorkspace" :""}
:visible {workspace.occupied == 1 ? "true" : "false"}
:text "${workspace.num}"))))
(defwidget time []
(eventbox
:onhover "eww open calendar"
:onhoverlost "eww close calendar"
{formattime(EWW_TIME, "%H:%M:%S")}))
(defwidget cpu []
(icon
:widgetclass "cpu"
:hover "${round(EWW_CPU.avg, 1)}%"
:percentage "${round(EWW_CPU.avg, 1)}"
:image "images/cpu.png"))
(defwidget ram []
(icon
:widgetclass "ram"
:hover "${round(EWW_RAM.used_mem_perc, 1)}%"
:percentage "${round(EWW_RAM.used_mem_perc, 1)}"
:image "images/ram.png"))
(defwidget volume []
(icon
:widgetclass "volume"
:hover "${volumeValue}%"
:percentage "${volumeValue}"
:image "images/volume.png"))
(defwidget brightness []
(icon
:widgetclass "brightness"
:hover "${brightnessValue / 960}%"
:percentage "${brightnessValue / 960}"
:image "images/brightness.png"))
(defwidget network []
(icon
:widgetclass "network"
:hover "${activeNetworks}"
:percentage "0"
:image "images/wifi.png"))
;;(defwidget bluetooth []
;; (icon
;; :widgetclass "bluetooth"
;; :hover "${bluetoothDevices}"
;; :percentage "${bluetoothBattery}"
;; :image "images/bluetooth.png"))
(defwidget battery []
(icon
:widgetclass {EWW_BATTERY.BAT1.status == "Charging" ? "battery" : EWW_BATTERY.total_avg > 25 ? "battery" : "batteryLow"}
:hover "${round(EWW_BATTERY.total_avg, 1)}%"
:percentage "${round(EWW_BATTERY.total_avg, 1)}"
:image {EWW_BATTERY.BAT1.status == "Charging" ? "images/charging.png" : EWW_BATTERY.total_avg > 25 ? "images/battery.png" : "images/batteryLow.png"}))
(defwidget power []
(icon
:widgetclass "power"
:hover "placeholder"
:percentage "0"
:image "images/power.png"))
(defwidget space []
(box
:width 5))
(defwidget seperator []
(box
:width 20
(label
:text "|"
)))
(defwidget cal []
(calendar
:day {formattime(EWW_TIME, "%d")}
:month {formattime(EWW_TIME, "%m")}
:year {formattime(EWW_TIME, "%y")}))
(defwidget winPower []
(box
:orientation "v"
(box
:halign "end"
(power))))
;; Widget blocks
(defwidget start []
(box
:orientation "h"
:space-evenly false
:halign "start"
(space)
(workspaces)))
(defwidget center []
(box
:orientation "h"
:space-evenly false
:halign "center"
(time)))
(defwidget end []
(box
:orientation "h"
:space-evenly false
:halign "end"
(cpu)
(space)
(ram)
(seperator)
(volume)
(space)
(brightness)
(seperator)
(network)
(space)
;; (bluetooth)
(seperator)
(battery)
(space)
(power)))
(defwidget bar []
(centerbox :orientation "h"
(start)
(center)
(end)))
;; Window definition
(defwindow bar
:monitor 0
:class "bar"
:geometry (geometry
:x "0%"
:y "5px"
:width "1279px"
:height "3%"
:anchor "top center")
:stacking "fg"
:exclusive true
(bar))
(defwindow calendar
:monitor 0
:class "calendar"
:geometry
(geometry
:x "0%"
:y "5px"
:width "0%"
:height "0%"
:anchor "top center")
:stacking "overlay"
(cal))
(defwindow power
:monitor 0
:class "bars"
:geometry
(geometry
:x "5px"
:y "5px"
:width "2%"
:height "3%"
:anchor "top right")
:stacking "fg"
(winPower))

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

View file

@ -1,3 +0,0 @@
#!/bin/bash
rsync -av --exclude='/backup/' /home/willifan/.config/eww /home/willifan/.config/eww/backup

View file

@ -1,22 +0,0 @@
#!/bin/bash
# Get the list of connected Bluetooth devices
devices=$(bluetoothctl devices Connected | awk '{print $2}')
# Iterate through each device and get its name and battery percentage
for device in $devices; do
# Get the device info using bluetoothctl
info=$(bluetoothctl info $device)
# Extract the name and battery percentage from the device info
name=$(echo "$info" | grep "Name" | awk '{ for(i=2; i<=NF; i++) printf "%s ", $i;}')
battery=$(echo "$info" | grep "Battery" | awk '{print $4}' | tr -d '()')
done
eww update bluetoothDevices="$name: $battery%"
eww update bluetoothBattery="$battery"
if [[ !$devices ]]; then
eww update bluetoothBattery="0"
fi

View file

@ -1,38 +0,0 @@
#!/bin/bash
brightness_file="/sys/class/backlight/intel_backlight/brightness"
min_brightness=1
max_brightness=96000
# Check if an argument is provided
if [[ -z $1 ]]; then
echo "Error: Number argument is missing."
exit 1
fi
# Retrieve the argument value
number_to_add=$1
# Validate if the argument is a number
if ! [[ $number_to_add =~ ^-?[0-9]+$ ]]; then
echo "Error: Invalid number argument."
exit 1
fi
# Read the current brightness value from the file
current_brightness=$(cat "$brightness_file")
# Add the desired number to the current brightness
new_brightness=$((current_brightness + number_to_add))
# Enforce minimum and maximum brightness values
if (( new_brightness < min_brightness )); then
new_brightness=$min_brightness
elif (( new_brightness > max_brightness )); then
new_brightness=$max_brightness
fi
# Write the new brightness value back to the file
echo "$new_brightness" >> "$brightness_file"
eww update brightnessValue="$new_brightness"

View file

@ -1,34 +0,0 @@
#!/bin/bash
declare -A id
declare -A horizontal
declare -A vertical
declare -A scale
generate() {
while read -r k h v s f; do
id[$k]="$k"
horizontal[$k]="$h"
vertical[$k]="$v"
scale[$k]="$s"
done < <(hyprctl monitors -j | jq -r '.[]|"\(.id) \(.width) \(.height) \(.scale)"')
echo -n '['
for ((i = 0; i < ${#id[@]}; i++)); do
echo -n ''$([ $i -eq 0 ] || echo ,)'{"id":"'$i'","width":"'${horizontal[$i]}'","height":"'${vertical[$i]}'",".scale":"'${scale[$i]}'"}'
done
echo ']'
}
generate
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | while read -r line; do
if [[ ${line%>>*} == "monitor"* ]]; then
generate
fi
done

View file

@ -1,3 +0,0 @@
#!/bin/bash
whoami > /home/willifan/text.txt

View file

@ -1,19 +0,0 @@
#!/bin/bash
#!/bin/bash
windows=()
workspaces=()
i=0
while read -r k v; do
windows[$i]="$k"
i=$i+1
workspaces[$i]="$v"
done < <(hyprctl clients -j | jq -r '.[]|"\(.pid) \(.workspace.id)"')
for window in ${!windows[@]}; do
echo $(ps -p ${windows[$window]} -o comm=)
done
test=$(ps -p ${windows[5]} -o comm=)
$(feh /usr/share/icons/Papirus-Dark/128x128/apps/${test}.svg)

View file

@ -1,36 +0,0 @@
#!/bin/bash
min_volume="0"
max_volume="100"
# Check if an argument is provided
if [[ -z $1 ]]; then
echo "Error: Number argument is missing."
exit 1
fi
# Retrieve the argument value
number_to_add=$1
# Validate if the argument is a number
if ! [[ $number_to_add =~ ^-?[0-9]+$ ]]; then
echo "Error: Invalid number argument."
exit 1
fi
# Read the current brightness value from the file
current_volume=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print $2 * 100}')
# Add the desired number to the current brightness
new_volume=$((current_volume + number_to_add))
# Enforce minimum and maximum brightness values
if (( new_volume < min_volume )); then
new_volume=$min_volume
elif (( new_volume > max_volume )); then
new_volume=$max_volume
fi
wpctl set-volume @DEFAULT_AUDIO_SINK@ "${new_volume}%"
eww update volumeValue="$new_volume"

View file

@ -1,113 +0,0 @@
#!/bin/bash
# get initial focused workspace
focusedws=$(hyprctl -j monitors | jq -r '.[] | select(.focused == true) | .activeWorkspace.id')
declare -A o=([1]=0 [2]=0 [3]=0 [4]=0 [5]=0 [6]=0 [7]=0 [8]=0 [9]=0 [10]=0)
declare -A monitormap
declare -A workspaces
# handle workspace create/destroy
workspace_event() {
if (( $1 <= 10 )); then
o[$1]=$2
while read -r k v; do workspaces[$k]="$v"; done < <(hyprctl -j workspaces | jq -r '.[]|"\(.id) \(.monitor)"')
fi
if [ "$2" == "0" ]; then
unset "workspaces[$1]"
fi
}
# handle monitor (dis)connects
monitor_event() {
while read -r k v; do monitormap["$k"]=$v; done < <(hyprctl -j monitors | jq -r '.[]|"\(.name) \(.id) "')
}
# generate the json for eww
generate() {
activeWorkspace=$(hyprctl -j monitors | jq -r '.[] | select(.focused == true) | .activeWorkspace.id')
echo -n '['
for i in {1..10}; do
active=0
if [[ $activeWorkspace == $i ]]; then
active=1
fi
echo -n ''$([ $i -eq 1 ] || echo ,)'{"num":"'$i'","occupied":"'${o[$i]}'","active":"'$active'"}'
# echo -n ''$([ $i -eq 1 ] || echo ,) '{ "number": "'"$i"'", "activity": "'"$(status_activity $i)"'", "color": "'$(status "$i")'" }'
done
# echo -n ',{"num":"'$focusedws'","clr":"'$(status "$focusedws")'"}'
echo ']'
}
# setup
# add monitors
monitor_event
# add workspaces
while read -r k v; do workspaces[$k]="$v"; done < <(hyprctl -j workspaces | jq -r '.[]|"\(.id) \(.monitor)"')
# get active workspace
activeWorkspace=$(hyprctl -j monitors | jq -r '.[] | select(.focused == true) | .activeWorkspace.id')
# check occupied workspaces
for num in "${!workspaces[@]}"; do
o[$num]=1
done
# generate initial widget
generate
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | while read -r line; do
# echo "${#workspaces[@]} ${#o[@]}"
# echo $line
case ${line%>>*} in
"focusedmon")
focusedws=${line#*,}
generate
;;
"createworkspace")
# workspace_event "${line#*>>}" 1
o=([1]=0 [2]=0 [3]=0 [4]=0 [5]=0 [6]=0 [7]=0 [8]=0 [9]=0 [10]=0)
workspaces=()
# add workspaces
while read -r k v; do workspaces[$k]="$v"; done < <(hyprctl -j workspaces | jq -r '.[]|"\(.id) \(.monitor)"')
# check occupied workspaces
for num in "${!workspaces[@]}"; do
o[$num]=1
done
# focusedws=${line#*>>}
generate
;;
"movewindow")
generate
;;
"destroyworkspace")
# workspace_event "${line#*>>}" 0
o=([1]=0 [2]=0 [3]=0 [4]=0 [5]=0 [6]=0 [7]=0 [8]=0 [9]=0 [10]=0)
workspaces=()
# add workspaces
while read -r k v; do workspaces[$k]="$v"; done < <(hyprctl -j workspaces | jq -r '.[]|"\(.id) \(.monitor)"')
# check occupied workspaces
for num in "${!workspaces[@]}"; do
o[$num]=1
done
generate
;;
"monitor"*)
monitor_event
generate
;;
"workspace")
generate
;;
esac
# echo $line
# generate
done

View file

@ -1,10 +0,0 @@
(defwindow example
:monitor 0
:geometry (geometry :x "0%"
:y "20px"
:width "50%"
:height "50px"
:anchor "top center")
:stacking "fg"
"example content")

1
codesettings Normal file
View file

@ -0,0 +1 @@
"explorer.confirmDelete": false

View file

@ -1,187 +0,0 @@
#!/bin/bash
ICON_THEME="ePapirus-Dark"
declare -A occupiedWorkspaces
declare -A workspaceActiveOn
declare -A workspaces
PIDs=()
workspaces=()
A=()
image=()
# get the monitors workspaces are active on and get workspaces that exist
workspace_event() {
unset workspaceActiveOn
unset occupiedWorkspaces
# store the monitor id in workspaceActiveOn with the index of the active workspace
while read -r m w; do
workspaceActiveOn[$w]=$m
done < <(hyprctl -j monitors | jq -r '.[]|"\(.id) \(.activeWorkspace.id)"')
# set occupiedWorkspaces with the workspace as its index true if the index exists
while read -r i; do
if (( $i > 0 )); then
occupiedWorkspaces[$i]=true
fi
done < <(hyprctl -j workspaces | jq -r '.[]|"\(.id)"')
}
client_event() {
unset clientOnWorkspace
unset PIDs
unset classes
unset icons
classes=()
clientOnWorkspace=()
images=()
numberOnWorkspace=()
area=()
i=0
while read -r p w x y c; do
if [[ $c ]]; then
# read PIDs of all clients in consecutive order
PIDs[$i]="$p"
# store class of process at index of its PID
classes[$p]="$c"
# store workspace process is on at index of its PID
clientOnWorkspace[$p]="$w"
# increment numberOnWorkspace by one to reflect amount of clients on it
((numberOnWorkspace[w]+=1))
# store area of the process at index of its PID
area[$p]=$((x * y))
# get icon in a hacky way
desktop=$(grep -l "StartupWMClass.*$c$" /usr/share/applications/*.desktop)
if [ -z $desktop ]; then
desktop=$(grep -Pl "Name\s*=\s*$c$" /usr/share/applications/*.desktop)
fi
if [ -z $desktop ]; then
desktop=$(ls /usr/share/applications | grep -l /usr/share/applications/${c}.desktop)
fi
if [ -z $desktop ]; then
process=$(ps -p ${p} -o comm=)
desktop=$(grep -Pl "$process" /usr/share/applications/*.desktop)
fi
if [ -z $desktop ]; then
desktop=$(grep -Pli "$c" /usr/share/applications/*.desktop)
fi
if [ -z $desktop ]; then
continue
fi
image=$(awk -F'[[:space:]]*=[[:space:]]*' '/Icon[[:space:]]*=/{print $2}' $desktop)
icons[$p]="/usr/share/icons/Papirus-Dark/128x128/apps/${image}.svg"
((i=$i+1))
fi
done < <(hyprctl clients -j | jq -r '.[]|"\(.pid) \(.workspace.id) \(.size[0]) \(.size[1]) \(.initialClass)"')
# store json string of all client information at the index of the clients pid
for ((i=0; i<${#PIDs[@]}; i++)); do
PID=${PIDs[$i]}
clientInfos[PID]='{"onWorkspace":"'${clientOnWorkspace[$PID]}'","pid":"'${PID}'","class":"'${classes[$PID]}'","mainOn":"''","icon":"'${icons[$PID]}'"}'
done
}
# generate the json for eww
generate() {
unset message
message='['
for i in {1..9}; do
message=$message''$([ $i -eq 1 ] || echo ,)'{"ID":"'$i'","occupied":"'${occupiedWorkspaces[$i]}'","activeID":"'${workspaceActiveOn[$i]}'","clients":['
firstClient=0
for ((j=0; j<${#PIDs[@]}; j++)); do
PID=${PIDs[j]}
if [[ $(echo ${clientInfos[$PID]} | jq '"\(.onWorkspace)"') == '"'${i}'"' ]]; then
message=$message''$([ $firstClient -eq 0 ] || echo ,)''${clientInfos[$PID]}''
firstClient=1
fi
done
message=$message']}'
done
message="${message}]"
echo $message
}
# setup
# generate initial widget
workspace_event
client_event
generate
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | while read -r line; do
case ${line%>>*} in
"workspace")
workspace_event
generate
;;
# "createworkspace")
# workspace_event
# generate
# ;;
# "destroyworkspace")
# workspace_event
# generate
# ;;
# "moveworkspace")
# workspace_event
# generate
# ;;
"openwindow")
client_event
generate
;;
"closewindow")
client_event
generate
;;
"movewindow")
client_event
workspace_event
generate
;;
esac
done

Binary file not shown.

View file

@ -1,43 +0,0 @@
#include <filesystem>
#include <iostream>
#include <string>
#include <fstream>
namespace fs = std::filesystem;
const std::string dir = "/usr/share/applications";
int main(int argc, char const *argv[])
{
for (const auto& entry : fs::directory_iterator(dir))
{
if (entry.path().extension() == ".desktop")
{
std::ifstream file(entry.path());
if (!file.is_open())
{
std::cerr << "file not opened" << std::endl;
return 1;
}
std::string output;
std::string line;
while (std::getline(file, line))
{
output += line + "\n";
}
std::cout << output << std::endl;
file.close();
}
}
return 0;
}

View file

@ -1,65 +0,0 @@
#!/bin/bash
PIDs=()
classes=()
clientOnWorkspace=()
images=()
numberOnWorkspace=()
area=()
i=0
while read -r p w x y c; do
if [[ $c ]]; then
PIDs[$i]="$p"
classes[$p]="$c"
clientOnWorkspace[$p]="$w"
((numberOnWorkspace[w]+=1))
area[$p]=$((x * y))
desktop=$(grep -l "StartupWMClass.*$c$" /usr/share/applications/*.desktop)
echo $c
if [ -z $desktop ]; then
desktop=$(grep -Pl "Name\s*=\s*$c$" /usr/share/applications/*.desktop)
fi
if [ -z $desktop ]; then
desktop=$(ls /usr/share/applications | grep -l /usr/share/applications/${c}.desktop)
fi
if [ -z $desktop ]; then
process=$(ps -p ${p} -o comm=)
desktop=$(grep -Pl "$process" /usr/share/applications/*.desktop)
fi
if [ -z $desktop ]; then
desktop=$(grep -Pli "$c" /usr/share/applications/*.desktop)
fi
if [ -z $desktop ]; then
continue
fi
images[$p]=$(awk -F'[[:space:]]*=[[:space:]]*' '/Icon[[:space:]]*=/{print $2}' $desktop)
ls /usr/share/icons/ePapirus-Dark/128x128/apps/${images[$p]}.svg
((i=$i+1))
fi
done < <(hyprctl clients -j | jq -r '.[]|"\(.pid) \(.workspace.id) \(.size[0]) \(.size[1]) \(.initialClass)"')
for ((i=0; i<${#PIDs[@]}; i++)); do
PID=${PIDs[$i]}
clientInfos[PID]='{"onWorkspace":"'${clientOnWorkspace[$PID]}'","pid":"'${PID}'","class":"'${classes[$PID]}'","mainOn":"''","icon":"'${images[$PID]}'"}'
echo ${clientInfos[$PID]}
done
#for window in ${!windows[@]}; do
# echo -n "${window} "
# echo $(ps -p ${windows[$window]} -o comm=)
#done
#test=$(ps -p ${windows[2]} -o comm=)
#$(feh /usr/share/icons/Papirus-Dark/128x128/apps/${test}.svg)

View file

@ -1,102 +0,0 @@
#!/bin/bash
# get initial focused workspace
focusedws=$(hyprctl -j monitors | jq -r '.[] | select(.focused == true) | .activeWorkspace.id')
declare -A o=([1]=0 [2]=0 [3]=0 [4]=0 [5]=0 [6]=0 [7]=0 [8]=0 [9]=0 [10]=0)
declare -A monitormap
declare -A workspaces
# handle workspace create/destroy
workspace_event() {
if (( $1 <= 10 )); then
o[$1]=$2
while read -r k v; do workspaces[$k]="$v"; done < <(hyprctl -j workspaces | jq -r '.[]|"\(.id) \(.monitor)"')
fi
if [ "$2" == "0" ]; then
unset "workspaces[$1]"
fi
}
# handle monitor (dis)connects
monitor_event() {
while read -r k v; do monitormap["$k"]=$v; done < <(hyprctl -j monitors | jq -r '.[]|"\(.name) \(.id) "')
}
# generate the json for eww
generate() {
unset activeWorkspaces
while read -r i w; do
activeWorkspaces[$w]=$i
done < <(hyprctl -j monitors | jq -r '.[]|"\(.id) \(.activeWorkspace.id)"')
echo -n '['
for i in {1..10}; do
echo -n ''$([ $i -eq 1 ] || echo ,)'{"ID":"'$i'","occupied":"'${o[$i]}'","activeID":"'${activeWorkspaces[$i]}'"}'
done
echo ']'
}
# setup
# add monitors
monitor_event
# add workspaces
while read -r k v; do workspaces[$k]="$v"; done < <(hyprctl -j workspaces | jq -r '.[]|"\(.id) \(.monitor)"')
# get active workspace
activeWorkspace=$(hyprctl -j monitors | jq -r '.[] | select(.focused == true) | .activeWorkspace.id')
# check occupied workspaces
for num in "${!workspaces[@]}"; do
o[$num]=1
done
# generate initial widget
generate
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | while read -r line; do
case ${line%>>*} in
"createworkspace")
o=([1]=0 [2]=0 [3]=0 [4]=0 [5]=0 [6]=0 [7]=0 [8]=0 [9]=0 [10]=0)
workspaces=()
# add workspaces
while read -r k v; do workspaces[$k]="$v"; done < <(hyprctl -j workspaces | jq -r '.[]|"\(.id) \(.monitor)"')
# check occupied workspaces
for num in "${!workspaces[@]}"; do
o[$num]=1
done
# focusedws=${line#*>>}
generate
;;
"movewindow")
generate
;;
"moveworkspace")
generate
;;
"destroyworkspace")
o=([1]=0 [2]=0 [3]=0 [4]=0 [5]=0 [6]=0 [7]=0 [8]=0 [9]=0 [10]=0)
workspaces=()
# add workspaces
while read -r k v; do workspaces[$k]="$v"; done < <(hyprctl -j workspaces | jq -r '.[]|"\(.id) \(.monitor)"')
# check occupied workspaces
for num in "${!workspaces[@]}"; do
o[$num]=1
done
generate
;;
"monitor"*)
monitor_event
generate
;;
"workspace")
generate
;;
esac
done

3
src/main.rs Normal file
View file

@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}

View file

@ -0,0 +1,89 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "hyprland_workspace_json"
version = "0.1.0"
dependencies = [
"serde",
"serde_json",
]
[[package]]
name = "itoa"
version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
[[package]]
name = "proc-macro2"
version = "1.0.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
dependencies = [
"proc-macro2",
]
[[package]]
name = "ryu"
version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1"
[[package]]
name = "serde"
version = "1.0.199"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c9f6e76df036c77cd94996771fb40db98187f096dd0b9af39c6c6e452ba966a"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.199"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11bd257a6541e141e42ca6d24ae26f7714887b47e89aa739099104c7e4d3b7fc"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.116"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813"
dependencies = [
"itoa",
"ryu",
"serde",
]
[[package]]
name = "syn"
version = "2.0.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"

View file

@ -0,0 +1,8 @@
[package]
name = "hyprland_workspace_json"
version = "0.1.0"
edition = "2021"
[dependencies]
serde = "1.0.199"
serde_json = "1.0.116"

View file

@ -0,0 +1,149 @@
//use serde::{Deserialize, Serialize};
//use serde_json::{self, json};
use std::collections::HashMap;
use std::env;
use std::fs;
use std::io::BufRead;
use std::io::BufReader;
use std::os::unix::net::UnixStream;
use std::process::Command;
use std::str;
use std::string::String;
use std::thread::sleep;
use std::time::Duration;
const DESKTOP_PATH: &str = "/usr/share/applications/";
const ENV_INSTANCE_SIGNATURE: &str = "HYPRLAND_INSTANCE_SIGNATURE";
//struct Workspace {
// id: i32,
// active_on: u32,
// num_windows: u32,
// icon: String,
//}
//fn fetch_workspaces() {}
fn fetch_monitors() {
let monitors = Command::new("hyprctl monitors")
.arg("-j")
.output()
.unwrap()
.stdout;
}
//fn fetch_clients() {}
fn generate_icon_map() -> HashMap<String, String> {
let files = fs::read_dir(DESKTOP_PATH).unwrap();
let mut vector = vec![];
let mut i = 0;
for file in files {
let file = match file {
Ok(file) => file,
Err(_) => continue,
};
let path = file.path();
let extension = path.extension().expect("error");
if extension != "desktop" {
continue;
}
let mut class = String::new();
let mut icon = String::new();
let file = fs::read_to_string(path).unwrap();
let mut got_icon = false;
let mut got_class = false;
for line in file.lines() {
let line = line.replace(' ', "");
match (got_icon, &line) {
(true, _) => (),
(false, line) if line.starts_with("Icon=") => {
icon = line.split_once('=').expect("error").1.to_string();
got_icon = true;
if got_class {
break;
}
continue;
}
_ => (),
}
match (got_class, &line) {
(true, _) => (),
(false, line) if line.starts_with("StartupWMClass=") => {
class = line.split_once('=').expect("error").1.to_string();
got_class = true;
if got_icon {
break;
}
continue;
}
(false, line) if line.starts_with("Name=") => {
class = line.split_once('=').expect("error").1.to_string();
continue;
}
_ => (),
}
}
vector.push((class, icon));
i += 1;
}
let mut icon_map: HashMap<String, String> = HashMap::with_capacity(i);
icon_map.extend(vector);
for (key, value) in &icon_map {
println!("Key: {}, Value: {}", key, value);
}
icon_map
}
fn handle_workspace() {
fetch_monitors();
}
fn handle_moveworkspace() {}
fn handle_activespecial() {}
fn handle_openwindow() {}
fn handle_closewindow() {}
fn handle_movewindow() {}
fn handle_activewindow() {}
fn handle(message: &str) {
println!("{}", message);
match message {
s if s.starts_with("workspacev2>>") => handle_workspace(),
s if s.starts_with("moveworkspacev2>>") => handle_moveworkspace(),
s if s.starts_with("activespecial>>") => handle_activespecial(),
s if s.starts_with("openwindow>>") => handle_openwindow(),
s if s.starts_with("closewindow>>") => handle_closewindow(),
s if s.starts_with("movewindowv2>>") => handle_movewindow(),
s if s.starts_with("activewindow>>v2") => handle_activewindow(),
_ => (),
};
}
fn main() {
let icon_map = generate_icon_map();
let hyprland_instance_signature = env::var(ENV_INSTANCE_SIGNATURE).unwrap();
let address = format!("/tmp/hypr/{}/.socket2.sock", hyprland_instance_signature);
let stream = UnixStream::connect(address).unwrap();
let mut reader = BufReader::new(stream);
loop {
let mut buf = String::new();
reader.read_line(&mut buf).unwrap();
handle(buf.trim());
sleep(Duration::from_millis(100));
}
}

View file

@ -0,0 +1 @@
{"rustc_fingerprint":10721803058081107973,"outputs":{"1185988223601034215":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/willifan/.rustup/toolchains/1.76.0-x86_64-unknown-linux-gnu\noff\npacked\nunpacked\n___\ndebug_assertions\nfeature=\"cargo-clippy\"\npanic=\"unwind\"\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n","stderr":""},"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.76.0 (07dca489a 2024-02-04)\nbinary: rustc\ncommit-hash: 07dca489ac2d933c78d3c5158e3f43beefeb02ce\ncommit-date: 2024-02-04\nhost: x86_64-unknown-linux-gnu\nrelease: 1.76.0\nLLVM version: 17.0.6\n","stderr":""}},"successes":{}}

View file

@ -0,0 +1,3 @@
Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by cargo.
# For information about cache directory tags see https://bford.info/cachedir/

View file

@ -0,0 +1 @@
{"rustc":18004373081649162931,"features":"[]","declared_features":"","target":4242516365433458241,"profile":5601947868832436996,"path":1684066648322511884,"deps":[[11756502991321056180,"serde",false,6543941702921472645],[16596247279872866912,"serde_json",false,481651981999974733]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/hyprland_workspace_json-1989689ce4226823/dep-bin-hyprland_workspace_json"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0}

View file

@ -0,0 +1 @@
This file has an mtime of when this was started.

View file

@ -0,0 +1,3 @@
{"$message_type":"diagnostic","message":"unused variable: `monitors`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"src/main.rs","byte_start":617,"byte_end":625,"line_start":29,"line_end":29,"column_start":9,"column_end":17,"is_primary":true,"text":[{"text":" let monitors = Command::new(\"hyprctl monitors\")","highlight_start":9,"highlight_end":17}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`#[warn(unused_variables)]` on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"if this is intentional, prefix it with an underscore","code":null,"level":"help","spans":[{"file_name":"src/main.rs","byte_start":617,"byte_end":625,"line_start":29,"line_end":29,"column_start":9,"column_end":17,"is_primary":true,"text":[{"text":" let monitors = Command::new(\"hyprctl monitors\")","highlight_start":9,"highlight_end":17}],"label":null,"suggested_replacement":"_monitors","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[33mwarning\u001b[0m\u001b[0m\u001b[1m: unused variable: `monitors`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/main.rs:29:9\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m29\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m let monitors = Command::new(\"hyprctl monitors\")\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[33m^^^^^^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[33mhelp: if this is intentional, prefix it with an underscore: `_monitors`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: `#[warn(unused_variables)]` on by default\u001b[0m\n\n"}
{"$message_type":"diagnostic","message":"unused variable: `icon_map`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"src/main.rs","byte_start":3662,"byte_end":3670,"line_start":136,"line_end":136,"column_start":9,"column_end":17,"is_primary":true,"text":[{"text":" let icon_map = generate_icon_map();","highlight_start":9,"highlight_end":17}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"if this is intentional, prefix it with an underscore","code":null,"level":"help","spans":[{"file_name":"src/main.rs","byte_start":3662,"byte_end":3670,"line_start":136,"line_end":136,"column_start":9,"column_end":17,"is_primary":true,"text":[{"text":" let icon_map = generate_icon_map();","highlight_start":9,"highlight_end":17}],"label":null,"suggested_replacement":"_icon_map","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[33mwarning\u001b[0m\u001b[0m\u001b[1m: unused variable: `icon_map`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/main.rs:136:9\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m136\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m let icon_map = generate_icon_map();\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[33m^^^^^^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[33mhelp: if this is intentional, prefix it with an underscore: `_icon_map`\u001b[0m\n\n"}
{"$message_type":"diagnostic","message":"2 warnings emitted","code":null,"level":"warning","spans":[],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[33mwarning\u001b[0m\u001b[0m\u001b[1m: 2 warnings emitted\u001b[0m\n\n"}

View file

@ -0,0 +1 @@
This file has an mtime of when this was started.

View file

@ -0,0 +1 @@
{"rustc":18004373081649162931,"features":"[]","declared_features":"","target":4242516365433458241,"profile":11983525691607113661,"path":1684066648322511884,"deps":[[16596247279872866912,"serde_json",false,4504624389509218668]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/hyprland_workspace_json-1f0f5989c50010df/dep-test-bin-hyprland_workspace_json"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0}

View file

@ -0,0 +1 @@
{"rustc":18004373081649162931,"features":"[]","declared_features":"","target":4242516365433458241,"profile":11597332650809196192,"path":1684066648322511884,"deps":[[11756502991321056180,"serde",false,2279579544486998568]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/hyprland_workspace_json-225fb1b9a1ca3f56/dep-bin-hyprland_workspace_json"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0}

View file

@ -0,0 +1 @@
This file has an mtime of when this was started.

Some files were not shown because too many files have changed in this diff Show more