forked from Shinonome/dots-hyprland
stuff
This commit is contained in:
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
hyprctl activewindow -j | gojq -c -M
|
||||
|
||||
if [ "$1" == "--once" ]; then
|
||||
exit 0
|
||||
else
|
||||
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | rg --line-buffered "window>>" | while read -r line; do
|
||||
hyprctl activewindow -j | gojq -c -M
|
||||
done
|
||||
fi
|
||||
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
focusedws=$(hyprctl activewindow -j | gojq -c -M '.workspace.id')
|
||||
echo $focusedws
|
||||
|
||||
if [[ "$focusedws" == 'null' ]]; then
|
||||
echo 1
|
||||
fi
|
||||
|
||||
if [ "$1" == "--once" ]; then
|
||||
exit 0
|
||||
else
|
||||
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | rg --line-buffered "workspace>>" | while read -r line; do
|
||||
case ${line%>>*} in
|
||||
"workspace")
|
||||
focusedws=${line#*>>}
|
||||
echo $focusedws
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
STATUS="$(rfkill list | sed -n 2p | awk '{print $3}')"
|
||||
|
||||
icon() {
|
||||
if [[ $STATUS == "no" ]]; then
|
||||
echo ""
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
toggle() {
|
||||
if [[ $STATUS == "no" ]]; then
|
||||
rfkill block all
|
||||
notify-send --urgency=normal -i airplane-mode-symbolic "Airplane Mode" "Airplane mode has been turned on!"
|
||||
else
|
||||
rfkill unblock all
|
||||
notify-send --urgency=normal -i airplane-mode-disabled-symbolic "Airplane Mode" "Airplane mode has been turned off!"
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ $1 == "toggle" ]]; then
|
||||
toggle
|
||||
else
|
||||
while true; do
|
||||
STATUS="$(rfkill list | sed -n 2p | awk '{print $3}')"
|
||||
icon
|
||||
sleep 3;
|
||||
done
|
||||
fi
|
||||
Executable
+137
@@ -0,0 +1,137 @@
|
||||
#include <pwd.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "nlohmann/json.hpp"
|
||||
using namespace std;
|
||||
using json = nlohmann::json;
|
||||
|
||||
// A simple struct to store the name and exec properties of a desktop entry
|
||||
struct DesktopEntry {
|
||||
string name;
|
||||
string exec;
|
||||
string icon;
|
||||
bool show;
|
||||
};
|
||||
|
||||
string username;
|
||||
vector<DesktopEntry> allApps;
|
||||
json apps;
|
||||
int mode = 0; // 0: Object, 1: Array
|
||||
|
||||
// A function that reads a .desktop file and returns a DesktopEntry struct
|
||||
DesktopEntry read_desktop_file(const string& filename) {
|
||||
DesktopEntry entry;
|
||||
entry.show = true;
|
||||
|
||||
ifstream file(filename);
|
||||
if (file.is_open()) {
|
||||
string line;
|
||||
while (getline(file, line)) {
|
||||
// Skip comments and empty lines
|
||||
if (line.empty() || line[0] == '#') {
|
||||
continue;
|
||||
}
|
||||
if (line.substr(0, 1) == "[" &&
|
||||
line.substr(0, 15) == "[Desktop Action")
|
||||
break;
|
||||
// Split the line by '=' and store the key-value pair
|
||||
size_t pos = line.find('=');
|
||||
if (pos != string::npos) {
|
||||
string key = line.substr(0, pos);
|
||||
string value = line.substr(pos + 1);
|
||||
// Store the name and exec properties
|
||||
if (key == "Name") {
|
||||
entry.name = value;
|
||||
} else if (key == "Exec") {
|
||||
entry.exec = value;
|
||||
} else if (key == "Icon") {
|
||||
entry.icon = value;
|
||||
} else if (key == "NoDisplay" && value == "true") {
|
||||
entry.show = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// cout << entry.name << " " << entry.exec << " " << entry.icon << "\n";
|
||||
file.close();
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
bool lf(DesktopEntry a, DesktopEntry b) { return a.name < b.name; }
|
||||
|
||||
// A function that prints out all desktop entry names and exec properties in a
|
||||
// given directory
|
||||
void get_desktop_entries(const string& dirname) {
|
||||
// Check if the directory exists
|
||||
if (!filesystem::exists(dirname) || !filesystem::is_directory(dirname)) {
|
||||
return;
|
||||
}
|
||||
// Iterate over all files in the directory
|
||||
for (const auto& entry : filesystem::directory_iterator(dirname)) {
|
||||
// Check if the file has a .desktop extension
|
||||
if (entry.path().extension() == ".desktop") {
|
||||
DesktopEntry thisEntry = read_desktop_file(entry.path());
|
||||
if (thisEntry.show) allApps.push_back(thisEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void to_json() {
|
||||
sort(allApps.begin(), allApps.end(), lf);
|
||||
for (const auto& entry : allApps) {
|
||||
json thisApp;
|
||||
thisApp["name"] = entry.name;
|
||||
thisApp["icon"] = entry.icon;
|
||||
thisApp["exec"] = entry.exec;
|
||||
// Get
|
||||
if (mode == 0)
|
||||
apps[entry.name] = thisApp;
|
||||
else
|
||||
apps.push_back(thisApp);
|
||||
}
|
||||
}
|
||||
|
||||
string get_username() {
|
||||
uid_t uid = geteuid();
|
||||
struct passwd* pw = getpwuid(uid);
|
||||
return pw->pw_name;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
if (argc == 3 && string(argv[1]) == "--mode") {
|
||||
if (string(argv[2]) == "object")
|
||||
mode = 0;
|
||||
else if (string(argv[2]) == "array")
|
||||
mode = 1;
|
||||
else
|
||||
mode = stoi(string(argv[2]));
|
||||
}
|
||||
|
||||
username = get_username();
|
||||
// Print all desktop entries in /usr/share/applications/
|
||||
string entryDirs[3] = {"/usr/share/applications/",
|
||||
"/home/" + username + "/.local/share/applications",
|
||||
"/var/lib/flatpak/exports/share/applications"};
|
||||
for (string directory : entryDirs) {
|
||||
if (filesystem::exists(directory))
|
||||
get_desktop_entries(directory);
|
||||
}
|
||||
|
||||
// Get em in the json object
|
||||
to_json();
|
||||
// Print
|
||||
for (const auto& entry : allApps) {
|
||||
cout << entry.name << '\n';
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Executable
+254
@@ -0,0 +1,254 @@
|
||||
#include <pwd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "nlohmann/json.hpp"
|
||||
using namespace std;
|
||||
using json = nlohmann::json;
|
||||
|
||||
// A simple struct to store the name and exec properties of a desktop entry
|
||||
struct DesktopEntry {
|
||||
string name;
|
||||
string exec;
|
||||
string icon;
|
||||
string filename;
|
||||
string filepath;
|
||||
bool show;
|
||||
};
|
||||
|
||||
string username;
|
||||
vector<DesktopEntry> allApps;
|
||||
json apps;
|
||||
int mode = 0; // 0: Object, 1: Array, 2: Start (Contains JSON for letters)
|
||||
string iconTheme = "";
|
||||
|
||||
// Returns the file name from a path
|
||||
std::string getFileName(const std::string& path) {
|
||||
// Find the last position of '/' or '\' in the path
|
||||
size_t pos = path.find_last_of("/\\");
|
||||
// If none is found, return the whole path
|
||||
if (pos == std::string::npos) return path;
|
||||
// Otherwise, return the substring after the last slash
|
||||
return path.substr(pos + 1);
|
||||
}
|
||||
|
||||
// Returns the file name without extension from a path
|
||||
string getFileNameNoExt(const string& path) {
|
||||
string filename = getFileName(path); // Get file name (with extension)
|
||||
size_t pos = filename.find_last_of(".");
|
||||
if (pos == string::npos) return filename; // Name found
|
||||
return filename.substr(0, pos);
|
||||
}
|
||||
|
||||
// Function to check if file exists, if yes read it
|
||||
string readIfExists(const string& name) {
|
||||
ifstream f(name.c_str());
|
||||
stringstream buffer;
|
||||
if (f) { // check if the file was opened successfully
|
||||
buffer << f.rdbuf(); // read the whole file into a string stream
|
||||
f.close(); // close the file when done
|
||||
}
|
||||
return buffer.str(); // return the string stream as a string
|
||||
}
|
||||
|
||||
void writeToFile(const string& name, const string& content) {
|
||||
ofstream f(name.c_str(), ios::app); // open the file in append mode
|
||||
if (f) { // check if the file was opened successfully
|
||||
f << content << "\n"; // write the content to the file
|
||||
f.close(); // close the file when done
|
||||
} else {
|
||||
cerr << "Error: could not open " << name
|
||||
<< "\n"; // print an error message to the standard error
|
||||
}
|
||||
}
|
||||
|
||||
string exec(const char* cmd) {
|
||||
array<char, 128> buffer;
|
||||
string result;
|
||||
unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
|
||||
if (!pipe) {
|
||||
throw runtime_error("popen() failed!");
|
||||
}
|
||||
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
|
||||
result += buffer.data();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
string getIconPath(string iconname) {
|
||||
if (iconTheme == "") {
|
||||
iconTheme =
|
||||
exec(string("gsettings get org.gnome.desktop.interface icon-theme")
|
||||
.c_str());
|
||||
iconTheme.pop_back();
|
||||
// cout << "icon theme: " << iconTheme << '\n';
|
||||
}
|
||||
if (iconname.size() == 0) {
|
||||
return "";
|
||||
} else if (iconname[0] == '/') {
|
||||
return iconname; // Already absolute path
|
||||
} else if (iconname[0] == '\n') {
|
||||
return ""; // wtf
|
||||
}
|
||||
string path = readIfExists("/home/" + username + "/.config/eww/scripts/cache/" + iconname);
|
||||
if (path == "") {
|
||||
path = exec(string("geticons -t " + iconTheme + " " + string(iconname) +
|
||||
" | head -n 1")
|
||||
.c_str());
|
||||
// cout << "path: " << path << '\n';
|
||||
writeToFile("/home/" + username + "/.config/eww/scripts/cache/" + iconname, path);
|
||||
// cout << "icon name: " << iconname << '\n';
|
||||
// cout << "path: " << path << '\n';
|
||||
}
|
||||
while (path.size() > 0 && *path.rbegin() == '\n')
|
||||
path.pop_back(); // Remove '\n'
|
||||
return path;
|
||||
}
|
||||
|
||||
// A function that reads a .desktop file and returns a DesktopEntry struct
|
||||
DesktopEntry readDesktopFile(const string& filename) {
|
||||
DesktopEntry entry;
|
||||
entry.show = true;
|
||||
entry.filename = getFileNameNoExt(filename);
|
||||
entry.filepath = filename;
|
||||
|
||||
ifstream file(filename);
|
||||
if (file.is_open()) {
|
||||
string line;
|
||||
while (getline(file, line)) {
|
||||
// Skip comments and empty lines
|
||||
if (line.empty() || line[0] == '#') {
|
||||
continue;
|
||||
}
|
||||
if (line.substr(0, 1) == "[" &&
|
||||
line.substr(0, 15) == "[Desktop Action")
|
||||
break;
|
||||
// Split the line by '=' and store the key-value pair
|
||||
size_t pos = line.find('=');
|
||||
if (pos != string::npos) {
|
||||
string key = line.substr(0, pos);
|
||||
string value = line.substr(pos + 1);
|
||||
// Store properties
|
||||
if (key == "Name") {
|
||||
entry.name = value;
|
||||
} else if (key == "Exec") {
|
||||
entry.exec = value;
|
||||
} else if (key == "Icon") {
|
||||
entry.icon = getIconPath(value);
|
||||
} else if (key == "NoDisplay" && value == "true") {
|
||||
entry.show = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
string lowercaseOf(string s) {
|
||||
for (char& c : s) {
|
||||
c = tolower(c);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
bool lf(DesktopEntry a, DesktopEntry b) {
|
||||
if (tolower(a.name[0]) == tolower(b.name[0]))
|
||||
return a.name < b.name;
|
||||
else
|
||||
return tolower(a.name[0]) < tolower(b.name[0]);
|
||||
}
|
||||
|
||||
// A function that prints out all desktop entry names and exec properties in a
|
||||
// given directory
|
||||
void getDesktopEntries(const string& dirname) {
|
||||
// Iterate over all files in the directory
|
||||
for (const auto& entry : filesystem::directory_iterator(dirname)) {
|
||||
// Check if the file has a .desktop extension
|
||||
if (entry.path().extension() == ".desktop") {
|
||||
// Read the file and print its name and exec properties
|
||||
DesktopEntry thisEntry = readDesktopFile(entry.path());
|
||||
// cout << thisEntry.name << " [icon: " << thisEntry.icon << "]\n";
|
||||
if (thisEntry.show) allApps.push_back(thisEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void toJson() {
|
||||
sort(allApps.begin(), allApps.end(), lf);
|
||||
int i = -1;
|
||||
for (const auto& entry : allApps) {
|
||||
i++;
|
||||
// cout << entry.name << ", ";
|
||||
json thisApp;
|
||||
thisApp["name"] = entry.name;
|
||||
thisApp["icon"] = entry.icon;
|
||||
thisApp["exec"] = entry.exec;
|
||||
if (mode != 2) {
|
||||
thisApp["filename"] = entry.filename;
|
||||
thisApp["filepath"] = entry.filepath;
|
||||
}
|
||||
// Get
|
||||
if (mode == 0)
|
||||
apps[entry.name] = thisApp;
|
||||
else if (mode == 1)
|
||||
apps.push_back(thisApp);
|
||||
else if (mode == 2) {
|
||||
apps.push_back(thisApp);
|
||||
}
|
||||
}
|
||||
cout << apps << '\n';
|
||||
}
|
||||
|
||||
string getUsername() {
|
||||
uid_t uid = geteuid();
|
||||
struct passwd* pw = getpwuid(uid);
|
||||
return pw->pw_name;
|
||||
}
|
||||
|
||||
void addLetters() {
|
||||
for (char c = 'A'; c <= 'Z'; c++) {
|
||||
DesktopEntry thisLetter;
|
||||
thisLetter.name = c;
|
||||
thisLetter.exec = "";
|
||||
thisLetter.icon = "_letter";
|
||||
allApps.push_back(thisLetter);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
if (argc == 3 && string(argv[1]) == "--mode") {
|
||||
if (string(argv[2]) == "object")
|
||||
mode = 0;
|
||||
else if (string(argv[2]) == "array")
|
||||
mode = 1;
|
||||
else if (string(argv[2]) == "start")
|
||||
mode = 2;
|
||||
else
|
||||
mode = stoi(string(argv[2]));
|
||||
}
|
||||
|
||||
username = getUsername();
|
||||
// Print all desktop entries in common locations
|
||||
string entryDirs[3] = {"/usr/share/applications/",
|
||||
"/home/" + username + "/.local/share/applications",
|
||||
"/var/lib/flatpak/exports/share/applications"};
|
||||
for (string directory : entryDirs) {
|
||||
if (filesystem::exists(directory))
|
||||
getDesktopEntries(directory);
|
||||
}
|
||||
if (mode == 2) addLetters();
|
||||
// Get a json and print
|
||||
toJson();
|
||||
}
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
cp -r images/svg/dark/* images/svg/
|
||||
|
||||
filelist=$(ls 'images/svg' -p | grep -v /)
|
||||
|
||||
IFS=$'\n'
|
||||
filearr=($(echo "$filelist"))
|
||||
|
||||
c0=$(cat css/_iconcolor.txt | head -1)
|
||||
c1=$(cat css/_iconcolor.txt | head -2 | tail -1)
|
||||
c2=$(cat css/_iconcolor.txt | head -3 | tail -1)
|
||||
c3=$(cat css/_iconcolor.txt | head -2 | tail -1)
|
||||
c4=$(cat css/_iconcolor.txt | head -5 | tail -1)
|
||||
c5=$(cat css/_iconcolor.txt | head -6 | tail -1)
|
||||
|
||||
if [[ "$(cat scripts/workdir/__mode_colors.txt | head -1)" == "one" ]]; then
|
||||
c1=$c0
|
||||
c2=$c0
|
||||
c3=$c0
|
||||
c4=$c0
|
||||
c5=$c0
|
||||
fi
|
||||
|
||||
sed -i "s/white/$c1/gi" "images/svg/beatmappacks.svg"
|
||||
sed -i "s/white/$c2/gi" "images/svg/forum.svg"
|
||||
sed -i "s/white/$c3/gi" "images/svg/search.svg"
|
||||
sed -i "s/white/$c4/gi" "images/svg/settings.svg"
|
||||
sed -i "s/white/$c5/gi" "images/svg/tournaments.svg"
|
||||
|
||||
for i in "${!filearr[@]}"; do
|
||||
# echo "images/svg/${filearr[$i]}"
|
||||
sed -i "s/white/$1/gi" "images/svg/${filearr[$i]}"
|
||||
done
|
||||
Executable
+203
@@ -0,0 +1,203 @@
|
||||
#include <array>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "nlohmann/json.hpp"
|
||||
using namespace std;
|
||||
using json = nlohmann::json;
|
||||
|
||||
string searchTerm;
|
||||
string results;
|
||||
vector<string> entryNames;
|
||||
json appEntries;
|
||||
|
||||
bool updateInfo = false;
|
||||
|
||||
void splitString(const std::string& str, const char delimiter,
|
||||
std::vector<std::string>& result) {
|
||||
std::string line;
|
||||
std::istringstream stream(str);
|
||||
while (std::getline(stream, line)) {
|
||||
if (!line.empty()) {
|
||||
if (line.back() == delimiter) {
|
||||
line.pop_back();
|
||||
}
|
||||
result.push_back(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string exec(const char* cmd) {
|
||||
array<char, 128> buffer;
|
||||
string result;
|
||||
unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
|
||||
if (!pipe) {
|
||||
throw runtime_error("popen() failed!");
|
||||
}
|
||||
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
|
||||
result += buffer.data();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool likelyNotMath(const string& expression) {
|
||||
char firstChar = expression[0];
|
||||
if (firstChar >= '0' && firstChar <= '9') return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void calcPrompt() {
|
||||
cout << "[{\"name\":\"Calculator - Type "
|
||||
"something!\",\"icon\":\"images/svg/dark/"
|
||||
"calculator.svg\",\"exec\":\"wl-copy \\\"Clipboard contents "
|
||||
";)\\\"\"}]";
|
||||
exec(
|
||||
"eww update winsearch_actions='{\"name\":\"Calculator - Type "
|
||||
"something!\",\"icon\":\"images/svg/dark/"
|
||||
"calculator.svg\",\"exec\":\"wl-copy \\\"Clipboard contents "
|
||||
";)\\\"\"}' &");
|
||||
exec("eww update winsearch_actions_type='Math result' &");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void getAppNames() {
|
||||
string searchCommand =
|
||||
"cat 'scripts/cache/entrynames.txt' | fzf --filter=\"" + searchTerm +
|
||||
"\" | head -n 10";
|
||||
string results = exec(&searchCommand[0]);
|
||||
splitString(results, '\n', entryNames);
|
||||
}
|
||||
|
||||
void getAppJson() {
|
||||
ifstream file("scripts/cache/entries.txt");
|
||||
file >> appEntries;
|
||||
}
|
||||
|
||||
void tryThemeCmd() {
|
||||
if (searchTerm.size() >= 6)
|
||||
searchTerm = searchTerm.substr(6);
|
||||
else
|
||||
searchTerm = " ";
|
||||
string searchCommand =
|
||||
"ls css/savedcolors/ | grep .txt | sed 's/_iconcolor_//g' | sed "
|
||||
"'s/.txt//g' | fzf --filter='" +
|
||||
searchTerm + "'";
|
||||
string results = exec(&searchCommand[0]);
|
||||
splitString(results, '\n', entryNames);
|
||||
cout << '[';
|
||||
for (int i = 0; i < entryNames.size(); i++) {
|
||||
string entryName = entryNames[i];
|
||||
cout << '{';
|
||||
cout << "\"name\":\"" << entryName << "\",\"exec\":\">load "
|
||||
<< entryName << "\"";
|
||||
cout << '}';
|
||||
if (i < entryNames.size() - 1) cout << ',';
|
||||
}
|
||||
cout << ']' << endl;
|
||||
if (updateInfo) {
|
||||
string entryName = entryNames[0];
|
||||
string updateCmd = "eww update winsearch_actions='{\"name\":\"" +
|
||||
entryName + "\",\"exec\":\">load " + entryName +
|
||||
"\"}'";
|
||||
exec(&updateCmd[0]);
|
||||
exec("eww update winsearch_actions_type='Color theme'");
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void tryAppSearch() {
|
||||
if (entryNames.size() == 0) return; // No app found, skip it
|
||||
cout << '[';
|
||||
for (int i = 0; i < entryNames.size(); i++) {
|
||||
string entryName = entryNames[i];
|
||||
cout << appEntries[entryName];
|
||||
if (i < entryNames.size() - 1) cout << ',';
|
||||
}
|
||||
cout << ']' << endl;
|
||||
if (updateInfo) {
|
||||
string updateCmd = "eww update winsearch_actions='" +
|
||||
string(appEntries[entryNames[0]].dump()) + "'";
|
||||
exec(&updateCmd[0]);
|
||||
exec("eww update winsearch_actions_type='Application'");
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void tryCalculate() {
|
||||
if (likelyNotMath(searchTerm)) return;
|
||||
string calcCommand = "qalc '" + searchTerm + "'";
|
||||
string results = exec(&calcCommand[0]);
|
||||
results = results.substr(results.find_first_of("=") + 2);
|
||||
if(results.back() == '\n') results.pop_back();
|
||||
// cout << results << '\n';
|
||||
cout
|
||||
<< "[{\"name\":\"" << results
|
||||
<< "\",\"icon\":\"images/svg/dark/calculator.svg\",\"exec\":\"wl-copy '"
|
||||
<< results << "'\"}]" << endl;
|
||||
if (updateInfo) {
|
||||
string updateCmd =
|
||||
"eww update "
|
||||
"winsearch_actions='{\"name\":\"'\"" +
|
||||
results +
|
||||
"\"'\",\"icon\":\"images/svg/dark/"
|
||||
"calculator.svg\",\"exec\":\"wl-copy '" +
|
||||
results + "'\"}'";
|
||||
exec(&updateCmd[0]);
|
||||
exec("eww update winsearch_actions_type='Math result'");
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void commandOnly() {
|
||||
cout << "[]" << endl;
|
||||
if (updateInfo) {
|
||||
string updateCmd =
|
||||
"eww update "
|
||||
"winsearch_actions='{\"name\":\"'\"" +
|
||||
searchTerm +
|
||||
"\"'\",\"icon\":\"images/svg/dark/"
|
||||
"protocol.svg\",\"exec\":\"" +
|
||||
searchTerm + "\"}'";
|
||||
exec(&updateCmd[0]);
|
||||
exec("eww update winsearch_actions_type='Run command'");
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
// Arguments
|
||||
if (argc == 1) {
|
||||
cout << "[{\"name\": \"Type something!\"}]";
|
||||
return 0;
|
||||
}
|
||||
if (argc > 2 && string(argv[2]) == "--updateinfo") updateInfo = true;
|
||||
searchTerm = argv[1];
|
||||
|
||||
// Special commands
|
||||
if (searchTerm == "--calculator") calcPrompt();
|
||||
if (searchTerm[0] == '>') {
|
||||
if (searchTerm.find(">load") != string::npos)
|
||||
tryThemeCmd();
|
||||
else {
|
||||
cout << "[]" << endl;
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
// Get app names and entries
|
||||
getAppNames();
|
||||
getAppJson();
|
||||
// Attempt searches in order. Each search will exit if success
|
||||
tryCalculate();
|
||||
tryAppSearch();
|
||||
commandOnly();
|
||||
|
||||
cout << results;
|
||||
}
|
||||
Executable
+146
@@ -0,0 +1,146 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
IFS=$'\n'
|
||||
entrynames=( $(cat 'scripts/cache/entrynames.txt' | fzf --filter="$1" | head -n 10) )
|
||||
entries=( $(cat 'scripts/cache/entries.txt') )
|
||||
|
||||
addedNewActions=false
|
||||
|
||||
geticonof() {
|
||||
clientclass=''
|
||||
clientclass=$1
|
||||
iconpath=''
|
||||
# Get app icon
|
||||
if [ -f "scripts/cache/$clientclass" ]; then
|
||||
iconpath=$(cat scripts/cache/$clientclass)
|
||||
if [ ! -f "${iconpath}" ]; then # Cache refresh if icon doesnt exist
|
||||
iconpath=$(geticons -t "$(gsettings get org.gnome.desktop.interface icon-theme | sed "s/'//g")" "$clientclass" | head -n 1)
|
||||
echo "${iconpath}" > "scripts/cache/$clientclass"
|
||||
fi
|
||||
else
|
||||
iconpath=$(geticons -t "$(gsettings get org.gnome.desktop.interface icon-theme | sed "s/'//g")" "$clientclass" | head -n 1)
|
||||
echo "${iconpath}" > "scripts/cache/$clientclass"
|
||||
fi
|
||||
if [[ ${iconpath} == "" ]]; then
|
||||
# Retry with lowercase if icon not found
|
||||
iconpath=$(geticons -t "$(gsettings get org.gnome.desktop.interface icon-theme | sed "s/'//g")" $(echo "$clientclass" | tr '[:upper:]' '[:lower:]' | sed 's/\ /-/g') | head -n 1)
|
||||
|
||||
if [[ ! ${iconpath} = "" ]]; then
|
||||
rm "scripts/cache/$clientclass"
|
||||
echo "${iconpath}" > "scripts/cache/$clientclass"
|
||||
else
|
||||
newname=$(scripts/iconpatch $clientclass)
|
||||
iconpath=$(geticons -t "$(gsettings get org.gnome.desktop.interface icon-theme | sed "s/'//g")" "$newname" | head -n 1)
|
||||
if [[ ! ${iconpath} = "" ]]; then
|
||||
rm "scripts/cache/$clientclass"
|
||||
echo "${iconpath}" > "scripts/cache/$clientclass"
|
||||
else
|
||||
# Fallback app icon, replace the path below to the fallback icon of your choice
|
||||
# iconpath="/usr/share/icons/Win11-dark/mimes/48/application-x-executable.svg"
|
||||
iconpath=$(geticons -t "$(gsettings get org.gnome.desktop.interface icon-theme | sed "s/'//g")" "application-x-executable" | head -n 1)
|
||||
rm "scripts/cache/$clientclass"
|
||||
echo "${iconpath}" > "scripts/cache/$clientclass"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
echo "$iconpath"
|
||||
}
|
||||
|
||||
quiteSureNotMath() {
|
||||
if [[ ${1:0:1} != "0" \
|
||||
&& ${1:0:1} != "1" \
|
||||
&& ${1:0:1} != "2" \
|
||||
&& ${1:0:1} != "3" \
|
||||
&& ${1:0:1} != "4" \
|
||||
&& ${1:0:1} != "5" \
|
||||
&& ${1:0:1} != "6" \
|
||||
&& ${1:0:1} != "7" \
|
||||
&& ${1:0:1} != "8" \
|
||||
&& ${1:0:1} != "9" \
|
||||
&& ${1:0:1} != "(" \
|
||||
&& ${1:0:1} != ")" \
|
||||
]]; then
|
||||
echo 'true'
|
||||
else
|
||||
echo 'false'
|
||||
fi
|
||||
}
|
||||
|
||||
# Search inits: math
|
||||
if [[ "$1" == "--calculator" ]]; then
|
||||
echo -n '[{"name":"Calculator - Type something!","icon":"images/svg/dark/calculator.svg","exec":"wl-copy \"Clipboard contents ;)\""}]'
|
||||
eww update winsearch_actions='{"name":"Calculator - Type something!","icon":"images/svg/dark/calculator.svg","exec":"wl-copy \"Clipboard contents ;)\""}'
|
||||
eww update winsearch_actions_type='Math result'
|
||||
addedNewActions=true
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Quick commands
|
||||
if [[ "$1" == ">"* ]]; then
|
||||
cd ~/.config/eww
|
||||
if [[ "$1" == ">load"* ]]; then
|
||||
searching=$(echo "$1" | sed 's/>load //g' | sed 's/>load//g')
|
||||
profilenames=( $(ls css/savedcolors/ | grep .txt | sed 's/_iconcolor_//g' | sed 's/.txt//g' | fzf --filter="$searching") )
|
||||
echo -n '['
|
||||
for x in "${!profilenames[@]}"; do
|
||||
if [ "$x" != "0" ]; then
|
||||
printf ','
|
||||
fi
|
||||
profilejson='{"name": "'"${profilenames[x]}"'", "exec": ">load '"${profilenames[x]}"'"}'
|
||||
if (( x == 0 )); then
|
||||
eww update winsearch_actions="$profilejson"
|
||||
eww update winsearch_actions_type='Color theme'
|
||||
addedNewActions=true
|
||||
fi
|
||||
|
||||
echo -n "$profilejson"
|
||||
done
|
||||
echo -n ']'
|
||||
else
|
||||
echo '[]'
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Do math
|
||||
if [[ $(quiteSureNotMath "$1") == "false" ]]; then
|
||||
mathAns=$(qalc $1 | head -n 1)
|
||||
mathAns="${mathAns#*= }"
|
||||
mathAns="${mathAns#*≈ }"
|
||||
if [[ "$mathAns" == *"error"* || "$mathAns" == *"warning"* ]]; then
|
||||
echo '[{"name":"Invalid math","icon":"images/svg/dark/calculator.svg","exec":"wl-copy \"Clipboard contents ;)\""}]'
|
||||
exit 0
|
||||
else
|
||||
ansjson='{"name": "'"$mathAns"'","icon":"images/svg/dark/calculator.svg","exec": "wl-copy \"'"$mathAns"'\""}'
|
||||
eww update winsearch_actions="$ansjson"
|
||||
eww update winsearch_actions_type='Math result'
|
||||
addedNewActions=true
|
||||
echo '['"$ansjson"']'
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Application search
|
||||
printf '['
|
||||
|
||||
for x in "${!entrynames[@]}"; do
|
||||
if [ "$x" != "0" ]; then
|
||||
printf ','
|
||||
fi
|
||||
appjson=$(echo $entries | gojq -c -M '."'"${entrynames[x]}"'"')
|
||||
if (( x == 0 )); then
|
||||
eww update winsearch_actions="$appjson"
|
||||
eww update winsearch_actions_type='Application'
|
||||
addedNewActions=true
|
||||
fi
|
||||
# iconname=$(echo "$appjson" | gojq -r -c -M '.icon')
|
||||
# appjson=$(echo "$appjson" | gojq '.icon = "'$(geticonof "$iconname")'"')
|
||||
echo -n "$appjson"
|
||||
done
|
||||
|
||||
printf ']'
|
||||
|
||||
if [[ "$addedNewActions" == "false" ]]; then
|
||||
eww update winsearch_actions='{"name":"'"$1"'","icon":"images/svg/dark/protocol.svg","exec":"wl-copy \"Clipboard contents ;)\""}'
|
||||
eww update winsearch_actions_type='Run command'
|
||||
fi
|
||||
Executable
+133
@@ -0,0 +1,133 @@
|
||||
#include <array>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "nlohmann/json.hpp"
|
||||
using namespace std;
|
||||
using json = nlohmann::json;
|
||||
|
||||
string clients;
|
||||
json clientjson, apps;
|
||||
string iconTheme = "";
|
||||
|
||||
string exec(const char* cmd) {
|
||||
array<char, 128> buffer;
|
||||
string result;
|
||||
unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
|
||||
if (!pipe) {
|
||||
throw runtime_error("popen() failed!");
|
||||
}
|
||||
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
|
||||
result += buffer.data();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Function to check if file exists, if yes read it
|
||||
string readIfExists(const string& name) {
|
||||
ifstream f(name.c_str());
|
||||
stringstream buffer;
|
||||
if (f) { // check if the file was opened successfully
|
||||
buffer << f.rdbuf(); // read the whole file into a string stream
|
||||
f.close(); // close the file when done
|
||||
}
|
||||
return buffer.str(); // return the string stream as a string
|
||||
}
|
||||
|
||||
void writeToFile(const string& name, const string& content) {
|
||||
ofstream f(name.c_str(), ios::app); // open the file in append mode
|
||||
if (f) { // check if the file was opened successfully
|
||||
f << content << "\n"; // write the content to the file
|
||||
f.close(); // close the file when done
|
||||
} else {
|
||||
cerr << "Error: could not open " << name
|
||||
<< "\n"; // print an error message to the standard error
|
||||
}
|
||||
}
|
||||
|
||||
string getIconPath(string iconname) {
|
||||
if (iconTheme == "") {
|
||||
iconTheme =
|
||||
exec(string("gsettings get org.gnome.desktop.interface icon-theme")
|
||||
.c_str());
|
||||
iconTheme.pop_back();
|
||||
// cout << "icon theme: " << iconTheme << '\n';
|
||||
}
|
||||
if (iconname.size() == 0) {
|
||||
return "";
|
||||
} else if (iconname[0] == '/') {
|
||||
return iconname; // Already absolute path
|
||||
} else if (iconname[0] == '\n') {
|
||||
return ""; // wtf
|
||||
}
|
||||
string path = readIfExists("scripts/cache/" + iconname);
|
||||
if (path == "") {
|
||||
path = exec(
|
||||
string("geticons -t " + iconTheme + " " + string(iconname) + " | head -n 1").c_str());
|
||||
writeToFile("scripts/cache/" + iconname, path);
|
||||
// cout << "icon name: " << iconname << '\n';
|
||||
// cout << "path: " << path << '\n';
|
||||
}
|
||||
while (path.size() > 0 && *path.rbegin() == '\n')
|
||||
path.pop_back(); // Remove '\n'
|
||||
return path;
|
||||
}
|
||||
|
||||
void addApp(json& client) {
|
||||
string volumestr = client["volume"]["front-left"]["value_percent"];
|
||||
volumestr.pop_back();
|
||||
int volume = stoi(volumestr);
|
||||
client = client["properties"];
|
||||
|
||||
bool found = false;
|
||||
for (json& obj : apps) {
|
||||
auto it = obj.find("name");
|
||||
if (it != obj.end() && *it == client["application.name"]) {
|
||||
found = true;
|
||||
obj["count"] = int(obj["count"]) + 1;
|
||||
obj["volume"].push_back(
|
||||
json::array({client["object.serial"], volume}));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
json newApp =
|
||||
R"({"name": "", "count": 1, "volume": [], "icon": ""})"_json;
|
||||
newApp["name"] = client["application.name"];
|
||||
newApp["volume"].push_back(
|
||||
json::array({client["object.serial"], volume}));
|
||||
|
||||
string iconpath;
|
||||
auto it = client.find("application.icon_name");
|
||||
if (it != client.end())
|
||||
iconpath = getIconPath(client["application.icon_name"]);
|
||||
else {
|
||||
iconpath = getIconPath(client["application.process.binary"]);
|
||||
}
|
||||
newApp["icon"] = iconpath;
|
||||
|
||||
apps.push_back(newApp);
|
||||
}
|
||||
}
|
||||
|
||||
void getAudioClients() {
|
||||
clients = exec("pactl --format json list sink-inputs");
|
||||
clientjson = json::parse(clients);
|
||||
for (json client : clientjson) {
|
||||
addApp(client);
|
||||
// cout << client << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
getAudioClients();
|
||||
cout << apps << '\n';
|
||||
}
|
||||
Executable
+84
@@ -0,0 +1,84 @@
|
||||
#!/usr/bin/bash
|
||||
dostuff(){
|
||||
sinks=$(pactl list sink-inputs \
|
||||
| grep -e "Sink Input" \
|
||||
| sed 's/Sink Input #//')
|
||||
names=$(pactl list sink-inputs \
|
||||
| sed 's/"//g' \
|
||||
| sed 's/application-name://' \
|
||||
| grep -e "application.name" \
|
||||
| sed 's/application.name = //' \
|
||||
| sed 's/\t\t//' )
|
||||
vols=$(pactl list sink-inputs \
|
||||
| grep -e "Volume:" \
|
||||
| sed 's/Volume: front-left: //' \
|
||||
| sed 's/front-right: //' \
|
||||
| sed 's/front-right: //' \
|
||||
| tr " " "\n" \
|
||||
| grep -e % \
|
||||
| sed 's/%//g' )
|
||||
binaries=$(pactl list sink-inputs \
|
||||
| grep -e 'application.process.binary' -e 'application.icon_name' \
|
||||
| sed 's/\t//g' \
|
||||
| sed 's/application.process.binary = //g' \
|
||||
| sed 's/application.icon_name = //g' \
|
||||
| sed 's/"//g' )
|
||||
|
||||
# echo "-=-=-=-=-=-=-=-=- Debug: Raw value -=-=-=-=-=-=-=-=-"
|
||||
# echo "$sinks"
|
||||
# echo "$names"
|
||||
# echo "$vols"
|
||||
|
||||
IFS=$'\n'
|
||||
sinkarr=($(echo "$sinks"))
|
||||
namearr=($(echo "$names"))
|
||||
volarr=($(echo "$vols"))
|
||||
iconarr=($(echo "$binaries"))
|
||||
|
||||
# Get icons
|
||||
for i in "${!iconarr[@]}"; do
|
||||
iconarr[$i]=$(geticons -t "$(gsettings get org.gnome.desktop.interface icon-theme | sed "s/'//g")" ${iconarr[i]} | head -n 1)
|
||||
done
|
||||
|
||||
# Functions
|
||||
sanitize() {
|
||||
echo "$1" | sed 's/"/\"/g'
|
||||
}
|
||||
|
||||
geticon() {
|
||||
# notify-send "${volarr[$((i*2))]}"
|
||||
if [ "${volarr[$(($1*2))]}" -eq "0" ]; then
|
||||
echo ""
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
# Print final JSON
|
||||
printf '['
|
||||
for i in "${!sinkarr[@]}"; do
|
||||
if [ $i -ne 0 ]; then
|
||||
printf ', '
|
||||
fi
|
||||
echo -n '{''"sink": "'"${sinkarr[$i]}"'", "name": "'"${namearr[$i]}"'", "volume": "'"${volarr[$((i*2))]}"'"}'
|
||||
# echo -n '{''"sink": "'"${sinkarr[$i]}"'", "icon": "'"${iconarr[$i]}"'", "name": "'"${namearr[$i]}"'", "volume": "'"${volarr[$((i*2))]}"'"}'
|
||||
done
|
||||
printf ']\n'
|
||||
|
||||
# echo "$sinks"
|
||||
# echo "$names"
|
||||
# echo "$vols"
|
||||
}
|
||||
|
||||
|
||||
cd ~/.config/eww
|
||||
# dostuff
|
||||
scripts/audioapps
|
||||
|
||||
if [ "$1" == "--once" ]; then
|
||||
exit 0
|
||||
else
|
||||
pactl subscribe | rg --line-buffered "on sink" | while read -r _; do
|
||||
scripts/audioapps
|
||||
done
|
||||
fi
|
||||
Executable
+133
@@ -0,0 +1,133 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
icons=("" "" "" "" "" "" "" "")
|
||||
|
||||
gettime() {
|
||||
FULL=$(cat /sys/class/power_supply/BATT/charge_full)
|
||||
NOW=$(cat /sys/class/power_supply/BATT/charge_now)
|
||||
|
||||
if [ "$RATE" -gt 0 ]; then
|
||||
if [ "$STATE" = "Discharging" ]; then
|
||||
EX="$NOW / $RATE"
|
||||
else
|
||||
EX="($FULL - $NOW) / $RATE"
|
||||
fi
|
||||
date -u -d@"$(bc -l <<< "$EX * 3600")" +%H:%M
|
||||
fi
|
||||
}
|
||||
|
||||
geticon() {
|
||||
if [ "$STATE" = "Charging" ]; then
|
||||
level=$(awk -v n="$CAPACITY" 'BEGIN{print int((n-1)/12)}')
|
||||
echo "${icons[$level]}"
|
||||
else
|
||||
level=$(awk -v n="$CAPACITY" 'BEGIN{print int((n-1)/12)}')
|
||||
echo "${icons[$level]}"
|
||||
fi
|
||||
}
|
||||
|
||||
status() {
|
||||
if [ "$STATE" = "Charging" ]; then
|
||||
echo -n "charging"
|
||||
|
||||
if [ "$RATE" -gt 0 ]; then
|
||||
echo ", $(gettime) left"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
elif [ "$STATE" = "Discharging" ]; then
|
||||
echo "$(gettime)h left"
|
||||
else
|
||||
echo "fully charged"
|
||||
fi
|
||||
}
|
||||
|
||||
statch() {
|
||||
if [ "$STATE" = "Discharging" ]; then #Not charging, below 20%
|
||||
if [ "$CAPACITY" -le 5 ]; then
|
||||
echo 'deadly'
|
||||
elif [ "$CAPACITY" -le 10 ]; then
|
||||
echo 'critical'
|
||||
elif [ "$CAPACITY" -le 30 ]; then
|
||||
echo 'low'
|
||||
else
|
||||
echo 'normal'
|
||||
fi
|
||||
else
|
||||
echo 'charging'
|
||||
fi
|
||||
}
|
||||
|
||||
chargestatus() {
|
||||
if [ "$STATE" = "Charging" ]; then
|
||||
echo -n ""
|
||||
elif [ "$STATE" = "Discharging" ]; then
|
||||
echo -n ""
|
||||
fi
|
||||
}
|
||||
|
||||
circolor() {
|
||||
if [[ "$CAPACITY" -le 20 && "$STATE" = "Discharging" ]]; then
|
||||
cat images/svg/color.txt
|
||||
else
|
||||
cat images/svg/color.txt
|
||||
fi
|
||||
}
|
||||
|
||||
cirbgcolor() {
|
||||
if [[ "$CAPACITY" -le 20 && "$STATE" = "Discharging" ]]; then
|
||||
echo '#EF738A'
|
||||
else
|
||||
echo 'transparent'
|
||||
fi
|
||||
}
|
||||
|
||||
color() {
|
||||
if [ "$CAPACITY" -le 20 ]; then
|
||||
echo '#EF738A'
|
||||
else
|
||||
echo 'white'
|
||||
fi
|
||||
}
|
||||
|
||||
bgcolor() {
|
||||
if [ "$CAPACITY" -le 20 ]; then
|
||||
echo '#EF738A'
|
||||
else
|
||||
echo 'transparent'
|
||||
fi
|
||||
}
|
||||
|
||||
wattage() {
|
||||
echo "$(bc -l <<< "scale=1; $RATE / 1000000") W"
|
||||
}
|
||||
|
||||
warnedlow=0
|
||||
|
||||
while true; do
|
||||
RATE=$(cat /sys/class/power_supply/BATT/voltage_now)
|
||||
CAPACITY=$(cat /sys/class/power_supply/BATT/capacity)
|
||||
STATE=$(cat /sys/class/power_supply/BATT/status)
|
||||
|
||||
if [[ "$CAPACITY" -le 5 && "$STATE" = "Discharging" ]]; then
|
||||
if [ $warnedlow == 0 ]; then
|
||||
warnedlow=1
|
||||
notify-send 'FREAKING PLUG IN THE CHARGER ALREADY' '!!111!!1!123!!!' -u critical -a 'eww'
|
||||
fi
|
||||
elif [[ "$CAPACITY" -le 10 && "$STATE" = "Discharging" ]]; then
|
||||
if [ $warnedlow == 0 ]; then
|
||||
warnedlow=1
|
||||
notify-send 'Battery verrry low' 'Hello?' -u critical -a 'eww'
|
||||
fi
|
||||
elif [[ "$CAPACITY" -le 20 && "$STATE" = "Discharging" ]]; then
|
||||
if [ $warnedlow == 0 ]; then
|
||||
warnedlow=1
|
||||
notify-send 'Battery low' 'Plug in your charger pweeeeaaase :>' -u critical -a 'eww'
|
||||
fi
|
||||
else
|
||||
warnedlow=0
|
||||
fi
|
||||
|
||||
echo '{"quickicon": "'"$(chargestatus)"'", "icon": "'"$(geticon)"'", "percentage": '"$CAPACITY"', "wattage": "'"$(wattage)"'", "status": "'"$(status)"'", "circolor": "'"$(circolor)"'", "cirbgcolor": "'"$(cirbgcolor)"'", "color": "'"$(color)"'", "bgcolor": "'"$(bgcolor)"'" }'
|
||||
sleep 3
|
||||
done
|
||||
Executable
+51
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
declare -A baticon=([10]="" [20]="" [30]="" [40]="" [50]="" [60]="" [70]="" [80]="" [90]="" [100]="")
|
||||
|
||||
toggle() {
|
||||
status=$(rfkill -J | jq -r '.rfkilldevices[] | select(.type == "bluetooth") | .soft' | head -1)
|
||||
|
||||
if [ "$status" = "unblocked" ]; then
|
||||
rfkill block bluetooth
|
||||
else
|
||||
rfkill unblock bluetooth
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$1" = "toggle" ]; then
|
||||
toggle
|
||||
else
|
||||
while true; do
|
||||
powered=$(bluetoothctl show | rg Powered | cut -f 2- -d ' ')
|
||||
status=$(bluetoothctl info)
|
||||
name=$(echo "$status" | rg Name | cut -f 2- -d ' ')
|
||||
mac=$(echo "$status" | head -1 | awk '{print $2}' | tr ':' '_')
|
||||
|
||||
if [[ "$(echo "$status" | rg Percentage)" != "" ]]; then
|
||||
battery=$(upower -i /org/freedesktop/UPower/devices/headset_dev_"$mac" | rg percentage | awk '{print $2}' | cut -f 1 -d '%')
|
||||
batt_icon=${baticon[$battery]}
|
||||
else
|
||||
batt_icon=""
|
||||
fi
|
||||
|
||||
if [ "$powered" = "yes" ]; then
|
||||
if [ "$status" != "Missing device address argument" ]; then
|
||||
text="$name"
|
||||
icon=""
|
||||
color="#89b4fa"
|
||||
else
|
||||
icon=""
|
||||
text="Disconnected"
|
||||
color="#45475a"
|
||||
fi
|
||||
else
|
||||
icon=""
|
||||
text="Bluetooth off"
|
||||
color="#45475a"
|
||||
fi
|
||||
|
||||
echo '{ "icon": "'"$icon"'", "batt_icon": "'"$batt_icon"'", "text": "'"$text"'", "color": "'"$color"'" }'
|
||||
|
||||
sleep 3
|
||||
done
|
||||
fi
|
||||
Executable
+59
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
cd ~/.config/eww
|
||||
|
||||
icons=("" "" "")
|
||||
XDG_CACHE_HOME="$HOME/.cache"
|
||||
date="$XDG_CACHE_HOME/eww/osd_brightness.date"
|
||||
lock=0
|
||||
|
||||
showhide() {
|
||||
# get dates
|
||||
rundate=$(cat "$date")
|
||||
currentdate=$(date +%s)
|
||||
|
||||
# handle showing
|
||||
if [ "$rundate" = "$currentdate" ] && [ "$lock" -eq 0 ]; then
|
||||
scripts/toggle-osd-bright.sh --open
|
||||
lock=1
|
||||
elif [ $((currentdate - rundate)) -ge 2 ] && [ "$lock" -eq 1 ]; then
|
||||
scripts/toggle-osd-bright.sh --close > /dev/null
|
||||
lock=0
|
||||
fi
|
||||
}
|
||||
|
||||
osd() {
|
||||
if [ ! -f "$date" ]; then
|
||||
mkdir -p "$XDG_CACHE_HOME/eww"
|
||||
fi
|
||||
date +%s > "$date"
|
||||
# showhide
|
||||
}
|
||||
|
||||
osd_handler() {
|
||||
lock=0
|
||||
rundate=0
|
||||
if [ ! -f "$date" ]; then
|
||||
mkdir -p "$XDG_CACHE_HOME/eww"
|
||||
echo 0 > "$date"
|
||||
fi
|
||||
|
||||
while true; do
|
||||
showhide
|
||||
sleep 0.1
|
||||
done
|
||||
}
|
||||
|
||||
if [ "$1" = "osd" ]; then
|
||||
osd
|
||||
else
|
||||
# initial
|
||||
icon=${icons[$(awk -v n="$(light)" 'BEGIN{print int(n/34)}')]}
|
||||
echo '{ "level": '"$(light)"', "icon": "'"$icon"'" }'
|
||||
|
||||
osd_handler &
|
||||
udevadm monitor | rg --line-buffered "backlight" | while read -r _; do
|
||||
icon="${icons[$(awk -v n="$(light)" 'BEGIN{print int(n/34)}')]}"
|
||||
|
||||
echo '{ "level": '"$(light)"', "icon": "'"$icon"'" }'
|
||||
done
|
||||
fi
|
||||
Executable
+138
@@ -0,0 +1,138 @@
|
||||
#include <chrono>
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
int year, month, day, weekday, weekdayOfMonthFirst;
|
||||
bool leapYear;
|
||||
int daysInMonth, daysInLastMonth, daysInNextMonth;
|
||||
bool highlight = true;
|
||||
|
||||
int calendar[6][7];
|
||||
int today[6][7];
|
||||
|
||||
void getTime() {
|
||||
// Time
|
||||
time_t now = time(0);
|
||||
tm* ltm = localtime(&now);
|
||||
// To vars
|
||||
year = 1900 + ltm->tm_year;
|
||||
month = 1 + ltm->tm_mon;
|
||||
day = ltm->tm_mday;
|
||||
weekday = ltm->tm_wday - 1;
|
||||
weekdayOfMonthFirst = (weekday + 35 - (day - 1)) % 7;
|
||||
// cout << weekday << ", " << day << '/' << month << '/' << year << '\n';
|
||||
}
|
||||
|
||||
void setTime(int wd, int d, int m, int y) {
|
||||
wd--;
|
||||
highlight = false;
|
||||
year = y;
|
||||
month = m;
|
||||
day = d;
|
||||
weekday = wd;
|
||||
weekdayOfMonthFirst = (weekday + 35 - (day - 1)) % 7;
|
||||
// cout << weekday << ", " << day << '/' << month << '/' << year << '\n';
|
||||
}
|
||||
|
||||
void checkLeapYear() {
|
||||
if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
|
||||
leapYear = true;
|
||||
else
|
||||
leapYear = false;
|
||||
}
|
||||
|
||||
void getMonthDays() {
|
||||
// Days in this month
|
||||
if ((month <= 7 && month % 2 == 1) || (month >= 8 && month % 2 == 0))
|
||||
daysInMonth = 31;
|
||||
else if (month == 2 && leapYear)
|
||||
daysInMonth = 29;
|
||||
else if (month == 2 && !leapYear)
|
||||
daysInMonth = 28;
|
||||
else
|
||||
daysInMonth = 30;
|
||||
// Days in next month
|
||||
if (month == 1 && leapYear)
|
||||
daysInNextMonth = 29;
|
||||
else if (month == 1 && !leapYear)
|
||||
daysInNextMonth = 28;
|
||||
else if ((month <= 7 && month % 2 == 1) || (month >= 8 && month % 2 == 0))
|
||||
daysInNextMonth = 30;
|
||||
else
|
||||
daysInNextMonth = 31;
|
||||
// Days in last month
|
||||
if (month == 3 && leapYear)
|
||||
daysInLastMonth = 29;
|
||||
else if (month == 3 && !leapYear)
|
||||
daysInLastMonth = 28;
|
||||
else if ((month <= 7 && month % 2 == 1) || (month >= 8 && month % 2 == 0))
|
||||
daysInLastMonth = 30;
|
||||
else
|
||||
daysInLastMonth = 31;
|
||||
}
|
||||
|
||||
void calcCalendar() {
|
||||
int monthDiff = (weekdayOfMonthFirst == 0 ? 0 : -1);
|
||||
int dim = daysInLastMonth;
|
||||
int i = 0, j = 0;
|
||||
int toFill = (weekdayOfMonthFirst == 0
|
||||
? 1
|
||||
: (daysInLastMonth - (weekdayOfMonthFirst - 1)));
|
||||
|
||||
while (i < 6 && j < 7) {
|
||||
// Fill it
|
||||
calendar[i][j] = toFill;
|
||||
if (toFill == day && monthDiff == 0 && highlight)
|
||||
today[i][j] = 1;
|
||||
else if (monthDiff == 0)
|
||||
today[i][j] = 0;
|
||||
else
|
||||
today[i][j] = -1;
|
||||
// Next day
|
||||
toFill++;
|
||||
if (toFill > dim) {
|
||||
monthDiff++;
|
||||
if (monthDiff == 0)
|
||||
dim = daysInMonth;
|
||||
else if (monthDiff == 1)
|
||||
dim = daysInNextMonth;
|
||||
toFill = 1;
|
||||
}
|
||||
// Next tile
|
||||
j++;
|
||||
if (j == 7) {
|
||||
j = 0;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void printCalendar() {
|
||||
cout << '[';
|
||||
for (int i = 0; i < 6; i++) {
|
||||
cout << '[';
|
||||
for (int j = 0; j < 7; j++) {
|
||||
cout << "{\"day\":" << calendar[i][j]
|
||||
<< ",\"today\":" << today[i][j] << "}";
|
||||
if (j < 7 - 1) cout << ',';
|
||||
}
|
||||
cout << ']';
|
||||
if (i < 6 - 1) cout << ',';
|
||||
}
|
||||
cout << ']';
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
if (argc == 1)
|
||||
getTime();
|
||||
else if(argc == 5)
|
||||
setTime(stoi(argv[1]), stoi(argv[2]), stoi(argv[3]), stoi(argv[4]));
|
||||
else
|
||||
cout << " - Run \"calendarlayout\" to get calendar for today\n - Run\"calendarlayout <weekday> <day> <month> <year>\" to get calendar of the day specified";
|
||||
checkLeapYear();
|
||||
getMonthDays();
|
||||
calcCalendar();
|
||||
printCalendar();
|
||||
}
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#include <boost/iostreams/device/file_descriptor.hpp>
|
||||
#include <boost/iostreams/stream.hpp>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
void cavaToJson(std::string& s) {
|
||||
for(int i = 0; i < s.size(); i++){
|
||||
if(s[i] == ';') s[i] = ',';
|
||||
}
|
||||
s.pop_back();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen("cava -p ~/.config/eww/scripts/custom_configs/cava", "r"), pclose);
|
||||
if (!pipe) {
|
||||
throw std::runtime_error("popen() failed!");
|
||||
}
|
||||
boost::iostreams::file_descriptor_source fd(fileno(pipe.get()), boost::iostreams::never_close_handle);
|
||||
boost::iostreams::stream<boost::iostreams::file_descriptor_source> is(fd);
|
||||
std::string line;
|
||||
while (std::getline(is, line)) {
|
||||
cavaToJson(line);
|
||||
std::cout << '[' << line << ']' << std::endl; // print the output line by line
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/bin/python3
|
||||
|
||||
# Import the re module
|
||||
import re
|
||||
|
||||
# Define a function that takes a string as an argument and returns True if it contains CJK characters, False otherwise
|
||||
def check_cjk(string):
|
||||
# Use a regular expression that matches any of these Unicode ranges: U+3040 - U+30FF (hiragana and katakana), U+3400 - U+4DBF (CJK unified ideographs extension A), U+4E00 - U+9FFF (CJK unified ideographs), U+F900 - U+FAFF (CJK compatibility ideographs), U+FF66 - U+FF9F (half-width katakana)
|
||||
pattern = r' [\\u3040-\\u30ff\\u3400-\\u4dbf\\u4e00-\\u9fff\\uf900-\\ufaff\\uff66-\\uff9f]'
|
||||
# Search for the pattern in the string
|
||||
match = re.search(pattern, string)
|
||||
# Return True if there is a match, False otherwise
|
||||
return bool(match)
|
||||
|
||||
# Read a string from standard input
|
||||
input = input("Enter a string: ")
|
||||
|
||||
# Call the function and print the result
|
||||
if check_cjk(input):
|
||||
print("The string contains CJK characters.")
|
||||
else:
|
||||
print("The string does not contain CJK characters.")
|
||||
|
||||
・インザナイト
|
||||
Executable
+95
@@ -0,0 +1,95 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
OPACITY=0.75
|
||||
|
||||
IMGPATH=$1
|
||||
coverurl=$2
|
||||
|
||||
coverpath="$IMGPATH"
|
||||
# Generate colors
|
||||
wal -c
|
||||
lightdark=$(cat scripts/workdir/__mode_light_dark.txt)
|
||||
wal -i "$IMGPATH" -n -t -s -e $lightdark -q
|
||||
|
||||
themejson=$(cat ~/.cache/wal/colors.json | gojq -c -M)
|
||||
themejson="${themejson::-1}"
|
||||
themejson="$themejson"',"source":"'"$3"'"}'
|
||||
echo $themejson
|
||||
|
||||
maincol="$(printf "$themejson" | gojq -c -M -r '.colors.color4')"
|
||||
# scripts/material_colors.py --path "$IMGPATH" $lightdark > tmp/_material.colorpallete
|
||||
scripts/material_colors.py --color "$maincol" "$lightdark" > tmp/_material.colorpallete &
|
||||
accent=$(scripts/material_colors.py --color "$maincol" "$lightdark" | grep '$onPrimaryContainer: ' | sed 's/$onPrimaryContainer: //g' | sed 's/;//g')
|
||||
tertiary=$(scripts/material_colors.py --color "$maincol" "$lightdark" | grep '$tertiary: ' | sed 's/$tertiary: //g' | sed 's/;//g')
|
||||
|
||||
printf '{"image": "'"$coverpath"'", "color": '"$themejson"'}\n'
|
||||
|
||||
# Get color in rgb
|
||||
colorsreg=$(cat ~/.cache/wal/colors-putty.reg)
|
||||
rgb_bg=$(echo $colorsreg | tr ' ' '\n' | grep 'Colour3')
|
||||
rgb_bg="${rgb_bg#*=}"
|
||||
rgb_bg="${rgb_bg#*\"}"
|
||||
rgb_bg="${rgb_bg::-1}"
|
||||
rgb_bg='rgba('"$rgb_bg"','"$OPACITY"')'
|
||||
# echo $rgb_bg
|
||||
|
||||
# notify-send 'eww' 'i found a url!'
|
||||
|
||||
# Write to scss
|
||||
echo '//Auto generated color theme for image at:' "$coverurl" > './tmp/_colorscheme.colorpallete'
|
||||
printf '$colorbarbg: ' >> './tmp/_colorscheme.colorpallete'
|
||||
printf "$themejson" | gojq -r '.special.background' | tr '\n' ';' >> './tmp/_colorscheme.colorpallete'
|
||||
echo '' >> './tmp/_colorscheme.colorpallete'
|
||||
printf '$colorbg: ' >> './tmp/_colorscheme.colorpallete'
|
||||
printf "$rgb_bg"';' >> './tmp/_colorscheme.colorpallete'
|
||||
echo '' >> './tmp/_colorscheme.colorpallete'
|
||||
printf '$colortext: ' >> './tmp/_colorscheme.colorpallete'
|
||||
printf "$themejson" | gojq -r '.special.foreground' | tr '\n' ';' >> './tmp/_colorscheme.colorpallete'
|
||||
echo '' >> './tmp/_colorscheme.colorpallete'
|
||||
printf '$color0: ' >> './tmp/_colorscheme.colorpallete'
|
||||
printf "$themejson" | gojq -r '.colors.color1' | tr '\n' ';' >> './tmp/_colorscheme.colorpallete'
|
||||
echo '' >> './tmp/_colorscheme.colorpallete'
|
||||
printf '$color1: ' >> './tmp/_colorscheme.colorpallete'
|
||||
printf "$themejson" | gojq -r '.colors.color2' | tr '\n' ';' >> './tmp/_colorscheme.colorpallete'
|
||||
echo '' >> './tmp/_colorscheme.colorpallete'
|
||||
printf '$color2: ' >> './tmp/_colorscheme.colorpallete'
|
||||
printf "$themejson" | gojq -r '.colors.color3' | tr '\n' ';' >> './tmp/_colorscheme.colorpallete'
|
||||
echo '' >> './tmp/_colorscheme.colorpallete'
|
||||
printf '$color3: ' >> './tmp/_colorscheme.colorpallete'
|
||||
printf "$themejson" | gojq -r '.colors.color4' | tr '\n' ';' >> './tmp/_colorscheme.colorpallete'
|
||||
echo '' >> './tmp/_colorscheme.colorpallete'
|
||||
printf '$color4: ' >> './tmp/_colorscheme.colorpallete'
|
||||
printf "$themejson" | gojq -r '.colors.color5' | tr '\n' ';' >> './tmp/_colorscheme.colorpallete'
|
||||
echo '' >> './tmp/_colorscheme.colorpallete'
|
||||
printf '$color5: ' >> './tmp/_colorscheme.colorpallete'
|
||||
printf "$themejson" | gojq -r '.colors.color6' | tr '\n' ';' >> './tmp/_colorscheme.colorpallete'
|
||||
echo '' >> './tmp/_colorscheme.colorpallete'
|
||||
printf '$color6: ' >> './tmp/_colorscheme.colorpallete'
|
||||
printf "$themejson" | gojq -r '.colors.color7' | tr '\n' ';' >> './tmp/_colorscheme.colorpallete'
|
||||
echo '' >> './tmp/_colorscheme.colorpallete'
|
||||
printf '$color7: ' >> './tmp/_colorscheme.colorpallete'
|
||||
printf "$themejson" | gojq -r '.colors.color4' | tr '\n' ';' >> './tmp/_colorscheme.colorpallete'
|
||||
echo '' >> './tmp/_colorscheme.colorpallete'
|
||||
|
||||
|
||||
gradient1=$(echo -n "$themejson" | gojq -r '.colors.color1')
|
||||
gradient2=$(echo -n "$themejson" | gojq -r '.colors.color2')
|
||||
gradient3=$(echo -n "$themejson" | gojq -r '.colors.color4')
|
||||
|
||||
# Write hyprland color config
|
||||
echo '# Auto generated color theme for image at:' "$coverurl" > './tmp/colors_generated.conf'
|
||||
echo 'general {' >> './tmp/colors_generated.conf'
|
||||
echo ' col.active_border = rgba('"${gradient1#*#}FF"') rgba('"${gradient2#*#}FF"') rgba('"${gradient3#*#}FF"') 45deg' >> './tmp/colors_generated.conf'
|
||||
echo ' col.inactive_border = rgba('"${gradient1#*#}66"')' >> './tmp/colors_generated.conf'
|
||||
echo '}' >> './tmp/colors_generated.conf'
|
||||
|
||||
# Print json to stdout
|
||||
echo "$accent" > 'tmp/_iconcolor.txt'
|
||||
echo "$tertiary" >> 'tmp/_iconcolor.txt'
|
||||
printf "$themejson" | gojq -r '.colors.color2' >> 'tmp/_iconcolor.txt'
|
||||
printf "$themejson" | gojq -r '.colors.color4' >> 'tmp/_iconcolor.txt'
|
||||
printf "$themejson" | gojq -r '.colors.color5' >> 'tmp/_iconcolor.txt'
|
||||
printf "$themejson" | gojq -r '.colors.color5' >> 'tmp/_iconcolor.txt'
|
||||
|
||||
# beatmappacks tertiary, forum color1, search color3, search color4, tournaments color4
|
||||
#
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
cd ~/.config/eww/ || exit
|
||||
|
||||
if [ $1 == "get" ]; then
|
||||
hyprctl keyword misc:disable_autoreload true
|
||||
cp './tmp/_iconcolor.txt' './css/_iconcolor.txt'
|
||||
cp './tmp/_colorscheme.colorpallete' './css/_colorscheme.scss'
|
||||
cp './tmp/_material.colorpallete' './css/_material.scss'
|
||||
cp './tmp/colors_generated.conf' ~/.config/hypr/colors.conf
|
||||
applycolor=$(cat './css/_iconcolor.txt' | head -1)
|
||||
scripts/applycolor "$applycolor"
|
||||
elif [ $1 == "default" ]; then
|
||||
hyprctl keyword misc:disable_autoreload true
|
||||
cp './css/_iconcolor_default.txt' './css/_iconcolor.txt'
|
||||
cp css/_colorscheme_default.scss css/_colorscheme.scss
|
||||
cp css/_material_default.scss css/_material.scss
|
||||
cp ~/.config/hypr/colors_default.conf ~/.config/hypr/colors.conf
|
||||
applycolor=$(cat css/_iconcolor.txt | head -1)
|
||||
scripts/applycolor "$applycolor"
|
||||
elif [ $1 == "save" ]; then
|
||||
eww close themer 2>/dev/null
|
||||
eww update themer_open=false
|
||||
cp "css/_iconcolor.txt" "css/savedcolors/_iconcolor_$2.txt"
|
||||
cp "css/_colorscheme.scss" "css/savedcolors/_colorscheme_$2.scss"
|
||||
cp "css/_material.scss" "css/savedcolors/_material_$2.scss"
|
||||
cp ~/.config/hypr/colors.conf ~/.config/hypr/savedcolors/colors_$2.conf
|
||||
elif [ $1 == "load" ]; then
|
||||
hyprctl keyword misc:disable_autoreload true
|
||||
eww close themer 2>/dev/null
|
||||
eww update themer_open=false
|
||||
cp "css/savedcolors/_iconcolor_$2.txt" "css/_iconcolor.txt"
|
||||
cp "css/savedcolors/_colorscheme_$2.scss" "css/_colorscheme.scss"
|
||||
cp "css/savedcolors/_material_$2.scss" "css/_material.scss"
|
||||
cp ~/.config/hypr/savedcolors/colors_$2.conf ~/.config/hypr/colors.conf
|
||||
applycolor=$(cat css/_iconcolor.txt | head -1)
|
||||
scripts/applycolor "$applycolor"
|
||||
fi
|
||||
|
||||
hyprctl reload
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
[general]
|
||||
|
||||
mode = normal
|
||||
framerate = 60
|
||||
autosens = 1
|
||||
bars = 70
|
||||
|
||||
[output]
|
||||
|
||||
method = raw
|
||||
raw_target = /dev/stdout
|
||||
data_format = ascii
|
||||
|
||||
[color]
|
||||
|
||||
gradient = 1
|
||||
|
||||
gradient_color_1 = '#99B5DE'
|
||||
gradient_color_2 = '#92CBF6'
|
||||
gradient_color_3 = '#ACD7F7'
|
||||
gradient_color_4 = '#B0E2F7'
|
||||
gradient_color_5 = '#DFEDF5'
|
||||
gradient_color_6 = '#FDEBD4'
|
||||
gradient_color_7 = '#E7D2D7'
|
||||
gradient_color_8 = '#C1838E'
|
||||
|
||||
[smoothing]
|
||||
monstercat = 1
|
||||
gravity = 1000000
|
||||
noise_reduction = 0.5
|
||||
@@ -0,0 +1,78 @@
|
||||
{
|
||||
"layer": "top",
|
||||
"height": 30,
|
||||
"position": "bottom",
|
||||
"spacing": 0,
|
||||
"exclusive": false,
|
||||
"margin-bottom": 50,
|
||||
"margin-right": 253,
|
||||
"margin-left": 1556,
|
||||
"fixed-center": false,
|
||||
|
||||
"modules-left": [
|
||||
|
||||
],
|
||||
|
||||
"modules-center": [
|
||||
"tray",
|
||||
],
|
||||
|
||||
"modules-right": [
|
||||
],
|
||||
|
||||
"custom/weather": {
|
||||
"exec": "curl 'https://wttr.in/?format=1' | tr -d '+'",
|
||||
"interval": 1800
|
||||
},
|
||||
|
||||
"custom/start": {
|
||||
"format": " ",
|
||||
"on-click": "~/.config/eww/scripts/toggle-overview.sh"
|
||||
},
|
||||
|
||||
"wlr/taskbar": {
|
||||
"format": "{icon}",
|
||||
"icon-size": 24,
|
||||
"tooltip-format": "{title}",
|
||||
"on-click": "activate",
|
||||
"on-click-middle": "close",
|
||||
},
|
||||
|
||||
"clock": {
|
||||
"format": " {:%I:%M %p%n%e/%m/%G}",
|
||||
"tooltip-format": "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>",
|
||||
"format-alt": " {:%Y-%m-%d}"
|
||||
},
|
||||
|
||||
"tray": {
|
||||
"spacing": 8
|
||||
},
|
||||
|
||||
"pulseaudio": {
|
||||
"format": "{icon}",
|
||||
"format-bluetooth": "{volume}% {icon} {format_source}",
|
||||
"format-bluetooth-muted": " {icon} {format_source}",
|
||||
"format-muted": " {format_source}",
|
||||
"format-source": " {volume}",
|
||||
"format-source-muted": "",
|
||||
"format-icons": {
|
||||
"headphone": "",
|
||||
"hands-free": "",
|
||||
"headset": "",
|
||||
"phone": "",
|
||||
"portable": "",
|
||||
"car": "",
|
||||
"default": ["", "", ""]
|
||||
},
|
||||
"tooltip-format": "{format_source}%",
|
||||
"on-click": "easyeffects"
|
||||
},
|
||||
"network": {
|
||||
"format-wifi": "",
|
||||
"format-ethernet": "",
|
||||
"tooltip-format": "{ifname} via {gwaddr} ",
|
||||
"format-linked": "{ifname} (No IP) ",
|
||||
"format-disconnected": "Disconnected ⚠",
|
||||
"on-click": "alacritty -e nmtui"
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
* {
|
||||
color: #f3f9ff;
|
||||
font-size: 11px;
|
||||
font-family: Segoe-Fluent-Icons, Segoe-UI;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
window#waybar {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
tooltip {
|
||||
background: #141414;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
#tray {
|
||||
min-width: 20px;
|
||||
min-height: 20px;
|
||||
font-size: 20px;
|
||||
font-weight: 200;
|
||||
padding: 4px;
|
||||
min-width: 100px;
|
||||
min-height: 37px;
|
||||
background: rgba(45, 46, 48, 1);
|
||||
background-image: url('images/textures/acrylic.png');
|
||||
border-radius: 9px;
|
||||
border: 1px solid rgba(34, 35, 38, 0.5);
|
||||
margin: 14px;
|
||||
box-shadow: 0px 2px 3px rgba(0, 0, 0, 0.65);
|
||||
}
|
||||
|
||||
#window,
|
||||
#pulseaudio,
|
||||
#network,
|
||||
#bluetooth {
|
||||
font-size: 14px;
|
||||
font-weight: 200;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
#custom-weather {
|
||||
padding-left: 12px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
#custom-start {
|
||||
background-image: url("./win.png");
|
||||
background-size: 24px 24px;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
#taskbar {
|
||||
border-radius: 6px;
|
||||
min-width: 45px;
|
||||
min-height: 45px;
|
||||
/* border-top: 1px solid rgba(64, 64, 64, 0.8); */
|
||||
}
|
||||
|
||||
#tray,
|
||||
#pulseaudio {
|
||||
padding-right: 12px;
|
||||
}
|
||||
|
||||
#clock {
|
||||
padding-left: 3px;
|
||||
padding-right: 18px;
|
||||
}
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
cd ~
|
||||
eww close dashboard 2>/dev/null
|
||||
|
||||
if [[ "$1" == "--web" ]]; then
|
||||
app=$2
|
||||
eval "${app%\%*}" &
|
||||
else
|
||||
app=$1
|
||||
eval "${app%\%*}" &
|
||||
pkill dashactivate
|
||||
fi
|
||||
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/bash
|
||||
if [ "$1" == "enable" ]; then
|
||||
hyprctl keyword bindm ,mouse:273,resizewindow
|
||||
hyprctl keyword bindm ,mouse:274,movewindow
|
||||
hyprctl keyword bind ,mouse_up,workspace,+1
|
||||
hyprctl keyword bind ,mouse_down,workspace,-1
|
||||
eww update editing=true
|
||||
elif [ "$1" == "disable" ]; then
|
||||
hyprctl keyword unbind ,mouse:273
|
||||
hyprctl keyword unbind ,mouse:274
|
||||
hyprctl keyword unbind ,mouse_up
|
||||
hyprctl keyword unbind ,mouse_down
|
||||
eww update editing=false
|
||||
fi
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/bash
|
||||
if [[ $1 == '_none' ]]; then
|
||||
hyprctl dispatch workspace $2
|
||||
else
|
||||
hyprctl dispatch focuswindow address:$1
|
||||
fi
|
||||
Executable
+77
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
cd ~/.config/eww
|
||||
|
||||
getwins() {
|
||||
hyprctlclients=$(hyprctl clients -j \
|
||||
| grep -v '"mapped": ' \
|
||||
| grep -v '"hidden": ' \
|
||||
| grep -v '"floating": ' \
|
||||
| grep -v '"monitor": ' \
|
||||
| grep -v '"pid": ' \
|
||||
| grep -v '"xwayland": ' \
|
||||
| grep -v '"pinned":' \
|
||||
| grep -v '"fullscreen": ' \
|
||||
| grep -v '"fullscreenMode": ' \
|
||||
| grep -v '"fakeFullscreen": ' \
|
||||
| grep -v '"grouped": ')
|
||||
|
||||
# echo $hyprctlclients | gojq -c '.[]'
|
||||
|
||||
IFS=$'\n'
|
||||
clientsarr=( $(echo $hyprctlclients | gojq -c -M '.[]') )
|
||||
|
||||
#For every window
|
||||
for client in "${clientsarr[@]}"; do
|
||||
iconpath=''
|
||||
clientclass=$(echo "$client" | gojq -r '.class')
|
||||
if [[ "$clientclass" == "" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Get app icon
|
||||
if [ -f "scripts/cache/$clientclass" ]; then
|
||||
iconpath=$(cat scripts/cache/$clientclass)
|
||||
if [ ! -f "${iconpath}" ]; then # Cache refresh if icon doesnt exist
|
||||
iconpath=$(geticons -t $(gsettings get org.gnome.desktop.interface icon-theme | sed "s/'//g") "$clientclass" | head -n 1)
|
||||
echo "${iconpath}" > "scripts/cache/$clientclass"
|
||||
fi
|
||||
else
|
||||
iconpath=$(geticons -t $(gsettings get org.gnome.desktop.interface icon-theme | sed "s/'//g") "$clientclass" | head -n 1)
|
||||
echo "${iconpath}" > "scripts/cache/$clientclass"
|
||||
fi
|
||||
if [[ ${iconpath} == "" ]]; then
|
||||
# Retry with lowercase if icon not found
|
||||
iconpath=$(geticons -t $(gsettings get org.gnome.desktop.interface icon-theme | sed "s/'//g") $(echo "$clientclass" | tr '[:upper:]' '[:lower:]' | sed 's/\ /-/g') | head -n 1)
|
||||
|
||||
if [[ ! ${iconpath} = "" ]]; then
|
||||
rm "scripts/cache/$clientclass"
|
||||
echo "${iconpath}" > "scripts/cache/$clientclass"
|
||||
else
|
||||
newname=$(scripts/iconpatch $clientclass)
|
||||
iconpath=$(geticons -t $(gsettings get org.gnome.desktop.interface icon-theme | sed "s/'//g") "$newname" | head -n 1)
|
||||
if [[ ! ${iconpath} = "" ]]; then
|
||||
rm "scripts/cache/$clientclass"
|
||||
echo "${iconpath}" > "scripts/cache/$clientclass"
|
||||
else
|
||||
# Fallback app icon, replace the path below to the fallback icon of your choice
|
||||
# iconpath="/usr/share/icons/Win11-dark/mimes/48/application-x-executable.svg"
|
||||
iconpath=$(geticons -t $(gsettings get org.gnome.desktop.interface icon-theme | sed "s/'//g") "application-x-executable" | head -n 1)
|
||||
rm "scripts/cache/$clientclass"
|
||||
echo "${iconpath}" > "scripts/cache/$clientclass"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Do stuff here
|
||||
getwins
|
||||
|
||||
if [ "$1" == "--once" ]; then
|
||||
exit 0
|
||||
else
|
||||
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | rg --line-buffered "window>>" | while read -r line; do
|
||||
getwins
|
||||
done
|
||||
fi
|
||||
Executable
+39
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
# Thanks Bing!
|
||||
|
||||
# Check if the argument is a valid number
|
||||
if [[ ! $1 =~ ^-?[0-9]+$ ]]; then
|
||||
echo "Invalid argument: $1"
|
||||
echo "Usage: getfirstdayofmonth [NUMBER]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the current month and year
|
||||
current_month=$(date +%m)
|
||||
current_year=$(date +%Y)
|
||||
|
||||
# Add the argument to the current month and adjust the year if needed
|
||||
if [[ $1 -gt 0 ]]; then
|
||||
next_month=$((current_month + $1))
|
||||
next_year=$((current_year + ((next_month-1) / 12)))
|
||||
next_month=$((current_month + ($1 % 12)))
|
||||
else
|
||||
next_month=$((current_month + $1))
|
||||
next_year=$((current_year + ((next_month-12) / 12)))
|
||||
next_month=$((current_month + ($1 % 12)))
|
||||
fi
|
||||
|
||||
if ((next_month > 12)); then
|
||||
next_month=$((next_month % 12))
|
||||
elif ((next_month == 0)); then
|
||||
next_month=12
|
||||
# next_year=$((next_year - 1))
|
||||
elif ((next_month < 1)); then
|
||||
next_month=$(( (next_month + 12) % 12 ))
|
||||
fi
|
||||
|
||||
# Get the weekday name (%A), day number (%d), month name (%B) and year (%Y) of the first day of the next month
|
||||
first_day=$(date -d "$next_year-$next_month-01" '+%u %d %m %Y')
|
||||
|
||||
# Print the result
|
||||
echo $first_day
|
||||
Executable
+51
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/bash
|
||||
getoptions(){
|
||||
rounding=$(hyprctl getoption decoration:rounding -j | gojq -r -c '.int')
|
||||
gaps_in=$(hyprctl getoption general:gaps_in -j | gojq -r -c '.int')
|
||||
gaps_out=$(hyprctl getoption general:gaps_out -j | gojq -r -c '.int')
|
||||
border_size=$(hyprctl getoption general:border_size -j | gojq -r -c '.int')
|
||||
force_no_accel=$(hyprctl getoption input:force_no_accel -j | gojq -r -c '.int')
|
||||
input_sensitivity=$(hyprctl getoption input:sensitivity -j | gojq -r -c '.float')
|
||||
touchpad_disable_while_typing=$(hyprctl getoption input:touchpad:disable_while_typing -j | gojq -r -c '.int')
|
||||
touchpad_clickfinger_behavior=$(hyprctl getoption input:touchpad:clickfinger_behavior -j | gojq -r -c '.int')
|
||||
blur=$(hyprctl getoption decoration:blur -j | gojq -r -c '.int')
|
||||
blur_size=$(hyprctl getoption decoration:blur_size -j | gojq -r -c '.int')
|
||||
blur_passes=$(hyprctl getoption decoration:blur_passes -j | gojq -r -c '.int')
|
||||
blur_xray=$(hyprctl getoption decoration:blur_xray -j | gojq -r -c '.int')
|
||||
nightlight=$(hyprctl getoption decoration:screen_shader -j | gojq -r -c '.str')
|
||||
if [[ "$nightlight" == *"nothing.frag" || "$nightlight" == "[[EMPTY]]" || "$nightlight" == "" ]]; then
|
||||
nightlight='false'
|
||||
else
|
||||
nightlight='true'
|
||||
fi
|
||||
|
||||
echo -n '{'
|
||||
echo -n "\"rounding\":$rounding,"
|
||||
echo -n "\"gaps_in\":$gaps_in,"
|
||||
echo -n "\"gaps_out\":$gaps_out,"
|
||||
echo -n "\"border_size\":$border_size,"
|
||||
echo -n "\"force_no_accel\":$force_no_accel,"
|
||||
echo -n "\"input_sensitivity\":$input_sensitivity,"
|
||||
echo -n "\"touchpad_disable_while_typing\":$touchpad_disable_while_typing,"
|
||||
echo -n "\"touchpad_clickfinger_behavior\":$touchpad_clickfinger_behavior,"
|
||||
echo -n "\"blur\":$blur,"
|
||||
echo -n "\"blur_size\":$blur_size,"
|
||||
echo -n "\"blur_passes\":$blur_passes,"
|
||||
echo -n "\"blur_xray\":$blur_xray,"
|
||||
echo -n "\"nightlight\":$nightlight,"
|
||||
|
||||
echo '"dummy":0}'
|
||||
}
|
||||
|
||||
getoptions
|
||||
|
||||
if [ "$1" == "--once" ]; then
|
||||
exit 0
|
||||
elif [ "$1" == "tickle" ]; then
|
||||
hyprctl keyword input:force_no_accel $(hyprctl getoption input:force_no_accel -j | gojq -r -c '.int')
|
||||
else
|
||||
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | rg --line-buffered "activelayout>>" | while read -r line; do
|
||||
# echo $line
|
||||
getoptions
|
||||
done
|
||||
fi
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
geticons -t $(gsettings get org.gnome.desktop.interface icon-theme | sed "s/'//g") "firefox" | head -n 1
|
||||
|
||||
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | while read -r line; do
|
||||
echo "$line"
|
||||
done
|
||||
|
||||
|
||||
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
if [[ "$1" == "--close" ]]; then
|
||||
hyprctl keyword monitor eDP-1,1920x1080@60,0x0,1
|
||||
hyprctl keyword monitor eDP-1,addreserved,61,0,0,0
|
||||
else
|
||||
hyprctl keyword monitor eDP-1,1920x1080@60,0x0,0.5
|
||||
hyprctl keyword monitor eDP-1,addreserved,533,600,960,960
|
||||
fi
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
appname=$1
|
||||
|
||||
if [[ "$1" == "code-url-handler" ]];then
|
||||
echo 'code'
|
||||
elif [[ "$1" == "gnome-tweaks" ]];then
|
||||
echo 'org.gnome.tweaks'
|
||||
elif [[ "$1" == "org."* ]];then
|
||||
appname="${appname#*.}"
|
||||
appname="${appname#*.}"
|
||||
echo $appname
|
||||
fi
|
||||
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
getopen(){
|
||||
ans=$(eww windows | grep -e "$1")
|
||||
if [ "${ans:0:1}" == "*" ]; then
|
||||
echo "true"
|
||||
else
|
||||
echo "false"
|
||||
fi
|
||||
}
|
||||
|
||||
getopen $1
|
||||
Executable
+99
@@ -0,0 +1,99 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include "nlohmann/json.hpp"
|
||||
|
||||
#define SLEEP_SECONDS 5
|
||||
|
||||
using namespace std;
|
||||
using json = nlohmann::json;
|
||||
|
||||
string fileContents, currentLang;
|
||||
json languages;
|
||||
|
||||
string readIfExists(const string& name) {
|
||||
ifstream f(name.c_str());
|
||||
stringstream buffer;
|
||||
if (f) { // check if the file was opened successfully
|
||||
buffer << f.rdbuf(); // read the whole file into a string stream
|
||||
f.close(); // close the file when done
|
||||
}
|
||||
return buffer.str(); // return the string stream as a string
|
||||
}
|
||||
|
||||
string exec(const char* cmd) {
|
||||
array<char, 128> buffer;
|
||||
string result;
|
||||
unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
|
||||
if (!pipe) {
|
||||
throw runtime_error("popen() failed!");
|
||||
}
|
||||
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
|
||||
result += buffer.data();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void switchLang(const json& langJson) {
|
||||
string cmd;
|
||||
cmd = "ibus engine " + string(langJson["name_ibus"]);
|
||||
exec(&cmd[0]);
|
||||
cmd = "eww update lang_ibus='" + string(langJson.dump()) + "'";
|
||||
exec(&cmd[0]);
|
||||
}
|
||||
|
||||
void cycleLang() {
|
||||
for (int i = 0; i < languages.size(); i++) {
|
||||
json lang = languages[i];
|
||||
if (string(lang["name_ibus"]) == currentLang) {
|
||||
json toSwitchTo = languages[(i + 1) % int(languages.size())];
|
||||
switchLang(toSwitchTo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void getCurrentLang() {
|
||||
for (json lang : languages) {
|
||||
if (string(lang["name_ibus"]) == currentLang) {
|
||||
cout << lang << '\n';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
// Change workdir
|
||||
string workdir = string(getenv("HOME")) + "/.config/eww";
|
||||
chdir(&workdir[0]);
|
||||
// Get lang list, current lang
|
||||
fileContents = readIfExists("modules/langs.json");
|
||||
languages = json::parse(fileContents);
|
||||
currentLang = exec("ibus engine");
|
||||
currentLang.pop_back(); // Remove trailing newline
|
||||
// Cycle?
|
||||
if (argc > 1 && string(argv[1]) == "--cycle") {
|
||||
cycleLang();
|
||||
return 0;
|
||||
}
|
||||
if (argc > 2 && string(argv[1]) == "--switch") {
|
||||
switchLang(json::parse(string(argv[2])));
|
||||
return 0;
|
||||
}
|
||||
|
||||
cout << "{\"name\":\"English (United "
|
||||
"States)\",\"name_abbr\":\"ENG\",\"name_ibus\":\"xkb:us::eng\"}\n";
|
||||
while (true) {
|
||||
getCurrentLang();
|
||||
sleep(5);
|
||||
}
|
||||
}
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
~/.config/eww/scripts/toggle-overview.sh --close &
|
||||
~/.config/eww/scripts/toggle-winstart.sh --close &
|
||||
|
||||
if [[ "$1" == ">"* ]]; then
|
||||
args=( $1 )
|
||||
if [[ "${args[0]}" == ">music" ]]; then
|
||||
scripts/colormanage get
|
||||
elif [[ "${args[0]}" == ">load" ]]; then
|
||||
scripts/colormanage load "${args[1]}"
|
||||
elif [[ "${args[0]}" == ">save" ]]; then
|
||||
scripts/colormanage save "${args[1]}"
|
||||
elif [[ "${args[0]}" == ">light" ]]; then
|
||||
scripts/togglelight light
|
||||
elif [[ "${args[0]}" == ">dark" ]]; then
|
||||
scripts/togglelight dark
|
||||
elif [[ "${args[0]}" == ">multi" ]]; then
|
||||
echo -n 'multi' > 'scripts/workdir/__mode_colors.txt'
|
||||
elif [[ "${args[0]}" == ">one" ]]; then
|
||||
echo -n 'one' > 'scripts/workdir/__mode_colors.txt'
|
||||
elif [[ "${args[0]}" == ">wall" ]]; then
|
||||
scripts/colorgen 'images/wallpaper/wallpaper' '[Local wallpaper]' ''
|
||||
scripts/colormanage get
|
||||
elif [[ "${args[0]}" == ">segs" ]]; then
|
||||
python3 scripts/waifupics.py --segs
|
||||
elif [[ "${args[0]}" == ">uwu" ]]; then
|
||||
python3 scripts/waifupics.py
|
||||
elif [[ "${args[0]}" == ">r" ]]; then
|
||||
pkill eww && eww daemon && eww open bar && eww open bottomline
|
||||
else
|
||||
# notify-send 'eww' 'Invalid command!'
|
||||
false
|
||||
fi
|
||||
else
|
||||
cd ~
|
||||
app=$1
|
||||
eval "${app%\%*}" &
|
||||
pkill launchapp
|
||||
fi
|
||||
|
||||
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/bin/python3
|
||||
import sys
|
||||
|
||||
def limit_length(s, newlength):
|
||||
# Use len() function to get number of characters in s
|
||||
char_count = 0
|
||||
newstr = ''
|
||||
# Use unicodedata.east_asian_width() function to check for double-width characters
|
||||
import unicodedata
|
||||
for c in s:
|
||||
char_count += 1
|
||||
if unicodedata.east_asian_width(c) == 'W':
|
||||
char_count += 1
|
||||
if char_count <= newlength:
|
||||
newstr += c
|
||||
else:
|
||||
newstr = newstr + '...'
|
||||
break
|
||||
# Add double-width count to character count to get display length
|
||||
return newstr
|
||||
|
||||
original = sys.argv[1]
|
||||
newlen = int(sys.argv[2])
|
||||
newstr = limit_length(original, newlen)
|
||||
|
||||
print(newstr)
|
||||
Executable
+71
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import desktop_entry_lib
|
||||
import os
|
||||
import json
|
||||
import subprocess
|
||||
|
||||
full_output = {}
|
||||
|
||||
def read(target_file) -> None:
|
||||
entry = desktop_entry_lib.DesktopEntry.from_file(target_file)
|
||||
|
||||
print("Name: " + str(entry.Name.default_text))
|
||||
print("Comment: " + str(entry.Comment.default_text))
|
||||
print("Exec: " + str(entry.Exec))
|
||||
|
||||
|
||||
def getProperties(target_file) -> None:
|
||||
entry = desktop_entry_lib.DesktopEntry.from_file(target_file)
|
||||
|
||||
# iconcmd = "/usr/bin/geticons " + str(entry.Icon)
|
||||
# iconcmd = "/usr/bin/geticons"
|
||||
# iconpath = str(subprocess.check_output(str(iconcmd), shell=True))
|
||||
dirs = target_file.split('/')
|
||||
entryname = dirs[-1]
|
||||
|
||||
# return
|
||||
props = {
|
||||
"name": str(entry.Name.default_text),
|
||||
# "icon": str(entry.Icon),
|
||||
"exec": str('gtk-launch ' + entryname)
|
||||
}
|
||||
return props
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
entryFile = open("scripts/cache/entries.txt", "w")
|
||||
# Get files
|
||||
entries = list(str(s) for s in os.listdir("/usr/share/applications"))
|
||||
entries_flatpak = list(str(s) for s in os.listdir("/var/lib/flatpak/exports/share/applications"))
|
||||
entries_local = list(str('../../.local/share/applications/' + s) for s in os.listdir("../../.local/share/applications/"))
|
||||
|
||||
for app in entries:
|
||||
alreadythere = False
|
||||
for localized in entries_local:
|
||||
if app in localized:
|
||||
alreadythere = True
|
||||
|
||||
if not(alreadythere):
|
||||
entries_local.append(str('/usr/share/applications/'+app))
|
||||
|
||||
for app in entries_flatpak:
|
||||
alreadythere = False
|
||||
for localized in entries_local:
|
||||
if app in localized:
|
||||
alreadythere = True
|
||||
|
||||
if not(alreadythere):
|
||||
entries_local.append(str('/var/lib/flatpak/exports/share/applications/'+app))
|
||||
|
||||
# Get properties
|
||||
for app in entries_local:
|
||||
if app.find('.desktop') == -1: # Skip files that aren't desktop entries
|
||||
continue
|
||||
this_entry = getProperties(app)
|
||||
|
||||
full_output[this_entry['name']] = (this_entry)
|
||||
|
||||
# output=json.dumps(this_entry)
|
||||
# print(output)
|
||||
entryFile.write(json.dumps(full_output))
|
||||
Executable
+63
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import desktop_entry_lib
|
||||
import os
|
||||
import json
|
||||
# from fuzzysearch import find_near_matches
|
||||
|
||||
def read(target_file) -> None:
|
||||
entry = desktop_entry_lib.DesktopEntry.from_file(target_file)
|
||||
|
||||
print("Name: " + str(entry.Name.default_text))
|
||||
print("Comment: " + str(entry.Comment.default_text))
|
||||
print("Exec: " + str(entry.Exec))
|
||||
|
||||
|
||||
def getProperties(target_file) -> None:
|
||||
entry = desktop_entry_lib.DesktopEntry.from_file(target_file)
|
||||
|
||||
# return
|
||||
props = {
|
||||
"name": str(entry.Name.default_text),
|
||||
"comment": str(entry.Comment.default_text),
|
||||
"exec": str(entry.Exec),
|
||||
"icon": str(entry.Icon)
|
||||
}
|
||||
return props
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
entryFile = open("scripts/cache/entrynames.txt", "w")
|
||||
# Get files
|
||||
entries = list(str(s) for s in os.listdir("/usr/share/applications"))
|
||||
entries_flatpak = list(str(s) for s in os.listdir("/var/lib/flatpak/exports/share/applications"))
|
||||
entries_local = list(str('../../.local/share/applications/' + s) for s in os.listdir("../../.local/share/applications/"))
|
||||
|
||||
for app in entries:
|
||||
alreadythere = False
|
||||
for localized in entries_local:
|
||||
if app in localized:
|
||||
alreadythere = True
|
||||
|
||||
if not(alreadythere):
|
||||
entries_local.append(str('/usr/share/applications/'+app))
|
||||
|
||||
for app in entries_flatpak:
|
||||
alreadythere = False
|
||||
for localized in entries_local:
|
||||
if app in localized:
|
||||
alreadythere = True
|
||||
|
||||
if not(alreadythere):
|
||||
entries_local.append(str('/var/lib/flatpak/exports/share/applications/'+app))
|
||||
|
||||
# Get properties
|
||||
for app in entries_local:
|
||||
if app.find('.desktop') == -1: # Skip files that aren't desktop entries
|
||||
continue
|
||||
|
||||
thisEntry = getProperties(app)
|
||||
|
||||
entryFile.write(thisEntry['name'])
|
||||
entryFile.write('\n')
|
||||
|
||||
Executable
+87
@@ -0,0 +1,87 @@
|
||||
#!/bin/python3
|
||||
from material_color_utilities_python import *
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
img = 0
|
||||
newtheme=0
|
||||
if len(sys.argv) > 1 and sys.argv[1] == '--path':
|
||||
img = Image.open(sys.argv[2])
|
||||
basewidth = 64
|
||||
wpercent = (basewidth/float(img.size[0]))
|
||||
hsize = int((float(img.size[1])*float(wpercent)))
|
||||
img = img.resize((basewidth,hsize),Image.Resampling.LANCZOS)
|
||||
newtheme = themeFromImage(img)
|
||||
elif len(sys.argv) > 1 and sys.argv[1] == '--color':
|
||||
colorstr = sys.argv[2]
|
||||
newtheme = themeFromSourceColor(argbFromHex(colorstr))
|
||||
else:
|
||||
img = Image.open(str(Path.home())+'/.config/eww/images/wallpaper/wallpaper')
|
||||
basewidth = 64
|
||||
wpercent = (basewidth/float(img.size[0]))
|
||||
hsize = int((float(img.size[1])*float(wpercent)))
|
||||
img = img.resize((basewidth,hsize),Image.Resampling.LANCZOS)
|
||||
newtheme = themeFromImage(img)
|
||||
|
||||
colorscheme=0
|
||||
if("-l" in sys.argv):
|
||||
colorscheme = newtheme.get('schemes').get('light')
|
||||
else:
|
||||
colorscheme = newtheme.get('schemes').get('dark')
|
||||
|
||||
primary = colorscheme.get_primary()
|
||||
onPrimary = colorscheme.get_onPrimary()
|
||||
primaryContainer = colorscheme.get_primaryContainer()
|
||||
onPrimaryContainer = colorscheme.get_onPrimaryContainer()
|
||||
secondary = colorscheme.get_secondary()
|
||||
onSecondary = colorscheme.get_onSecondary()
|
||||
secondaryContainer = colorscheme.get_secondaryContainer()
|
||||
onSecondaryContainer = colorscheme.get_onSecondaryContainer()
|
||||
tertiary = colorscheme.get_tertiary()
|
||||
onTertiary = colorscheme.get_onTertiary()
|
||||
tertiaryContainer = colorscheme.get_tertiaryContainer()
|
||||
onTertiaryContainer = colorscheme.get_onTertiaryContainer()
|
||||
error = colorscheme.get_error()
|
||||
onError = colorscheme.get_onError()
|
||||
errorContainer = colorscheme.get_errorContainer()
|
||||
onErrorContainer = colorscheme.get_onErrorContainer()
|
||||
background = colorscheme.get_background()
|
||||
onBackground = colorscheme.get_onBackground()
|
||||
surface = colorscheme.get_surface()
|
||||
onSurface = colorscheme.get_onSurface()
|
||||
surfaceVariant = colorscheme.get_surfaceVariant()
|
||||
onSurfaceVariant = colorscheme.get_onSurfaceVariant()
|
||||
outline = colorscheme.get_outline()
|
||||
shadow = colorscheme.get_shadow()
|
||||
inverseSurface = colorscheme.get_inverseSurface()
|
||||
inverseOnSurface = colorscheme.get_inverseOnSurface()
|
||||
inversePrimary = colorscheme.get_inversePrimary()
|
||||
|
||||
|
||||
print('$primary: ' + hexFromArgb(primary) + ';')
|
||||
print('$onPrimary: ' + hexFromArgb(onPrimary) + ';')
|
||||
print('$primaryContainer: ' + hexFromArgb(primaryContainer) + ';')
|
||||
print('$onPrimaryContainer: ' + hexFromArgb(onPrimaryContainer) + ';')
|
||||
print('$secondary: ' + hexFromArgb(secondary) + ';')
|
||||
print('$onSecondary: ' + hexFromArgb(onSecondary) + ';')
|
||||
print('$secondaryContainer: ' + hexFromArgb(secondaryContainer) + ';')
|
||||
print('$onSecondaryContainer: ' + hexFromArgb(onSecondaryContainer) + ';')
|
||||
print('$tertiary: ' + hexFromArgb(tertiary) + ';')
|
||||
print('$onTertiary: ' + hexFromArgb(onTertiary) + ';')
|
||||
print('$tertiaryContainer: ' + hexFromArgb(tertiaryContainer) + ';')
|
||||
print('$onTertiaryContainer: ' + hexFromArgb(onTertiaryContainer) + ';')
|
||||
print('$error: ' + hexFromArgb(error) + ';')
|
||||
print('$onError: ' + hexFromArgb(onError) + ';')
|
||||
print('$errorContainer: ' + hexFromArgb(errorContainer) + ';')
|
||||
print('$onErrorContainer: ' + hexFromArgb(onErrorContainer) + ';')
|
||||
print('$colorbarbg: ' + hexFromArgb(background) + ';')
|
||||
print('$onBackground: ' + hexFromArgb(onBackground) + ';')
|
||||
print('$surface: ' + hexFromArgb(surface) + ';')
|
||||
print('$onSurface: ' + hexFromArgb(onSurface) + ';')
|
||||
print('$surfaceVariant: ' + hexFromArgb(surfaceVariant) + ';')
|
||||
print('$onSurfaceVariant: ' + hexFromArgb(onSurfaceVariant) + ';')
|
||||
print('$outline: ' + hexFromArgb(outline) + ';')
|
||||
print('$shadow: ' + hexFromArgb(shadow) + ';')
|
||||
print('$inverseSurface: ' + hexFromArgb(inverseSurface) + ';')
|
||||
print('$inverseOnSurface: ' + hexFromArgb(inverseOnSurface) + ';')
|
||||
print('$inversePrimary: ' + hexFromArgb(inversePrimary) + ';')
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
while true; do
|
||||
# human-readable
|
||||
freeH=$(free -h --si | rg "Mem:")
|
||||
swapfreeH=$(free -h --si | rg "Swap:")
|
||||
# non-human-readable
|
||||
freeN=$(free --mega | rg "Mem:")
|
||||
swapfreeN=$(free --mega | rg "Swap:")
|
||||
|
||||
total="$(echo "$freeH" | awk '{ print $2 }')"
|
||||
used="$(echo "$freeH" | awk '{ print $3 }')"
|
||||
t="$(echo "$freeN" | awk '{ print $2 }')"
|
||||
u="$(echo "$freeN" | awk '{ print $3 }')"
|
||||
|
||||
swaptotal="$(echo "$swapfreeH" | awk '{ print $2 }')"
|
||||
swapused="$(echo "$swapfreeH" | awk '{ print $3 }')"
|
||||
swapt="$(echo "$swapfreeN" | awk '{ print $2 }')"
|
||||
swapu="$(echo "$swapfreeN" | awk '{ print $3 }')"
|
||||
|
||||
free=$(printf '%.1fG' "$(bc -l <<< "($t - $u) / 1000")")
|
||||
perc=$(printf '%.1f' "$(free -m | rg Mem | awk '{print ($3/$2)*100}')")
|
||||
|
||||
swapfree=$(printf '%.1fG' "$(bc -l <<< "($swapt - $swapu) / 1000")")
|
||||
swapperc=$(printf '%.1f' "$(free -m | rg Swap | awk '{print ($3/$2)*100}')")
|
||||
|
||||
echo '{ "total": "'"$total"'", "used": "'"$used"'", "free": "'"$free"'", "swaptotal": "'"$swaptotal"'", "swapused": "'"$swapused"'", "swappercentage": '"$swapperc"', "swapfree": "'"$swapfree"'", "percentage": '"$perc"' }'
|
||||
|
||||
sleep 3
|
||||
done
|
||||
Executable
+52
@@ -0,0 +1,52 @@
|
||||
#include <boost/iostreams/device/file_descriptor.hpp>
|
||||
#include <boost/iostreams/stream.hpp>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
void cavaToJson(std::string& s) {
|
||||
for(int i = 0; i < s.size(); i++){
|
||||
if(s[i] == ';') s[i] = ',';
|
||||
}
|
||||
s.pop_back();
|
||||
}
|
||||
|
||||
void cursorPosToJson(std::string& s) {
|
||||
for(int i = 0; i < s.size(); i++){
|
||||
if(s[i] == ';') s[i] = ',';
|
||||
}
|
||||
s.pop_back();
|
||||
}
|
||||
|
||||
string exec(const char* cmd) {
|
||||
array<char, 128> buffer;
|
||||
string result;
|
||||
unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
|
||||
if (!pipe) {
|
||||
throw runtime_error("popen() failed!");
|
||||
}
|
||||
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
|
||||
result += buffer.data();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen("cava -p ~/.config/eww/scripts/custom_configs/cava", "r"), pclose);
|
||||
if (!pipe) {
|
||||
throw std::runtime_error("popen() failed!");
|
||||
}
|
||||
boost::iostreams::file_descriptor_source fd(fileno(pipe.get()), boost::iostreams::never_close_handle);
|
||||
boost::iostreams::stream<boost::iostreams::file_descriptor_source> is(fd);
|
||||
std::string line;
|
||||
while (std::getline(is, line)) {
|
||||
string st = exec("hyprctl cursorpos");
|
||||
st.pop_back();
|
||||
cout << '[' << st << ']' << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Executable
+168
@@ -0,0 +1,168 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
prevtitle=''
|
||||
prevartist=''
|
||||
|
||||
get_status() {
|
||||
s=$1
|
||||
if [ "$s" = "Playing" ]; then
|
||||
echo ""
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
get_length_sec() {
|
||||
len=$1
|
||||
if [ -z "$len" ]; then
|
||||
echo 0
|
||||
else
|
||||
bc <<< "$len / 1000000"
|
||||
fi
|
||||
}
|
||||
|
||||
get_length_time() {
|
||||
len=$1
|
||||
if [ -n "$len" ]; then
|
||||
len=$(bc <<< "$len / 1000000 + 1")
|
||||
date -d@"$len" +%M:%S
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
get_position() {
|
||||
pos=$1
|
||||
len=$2
|
||||
if [ -n "$pos" ]; then
|
||||
bc -l <<< "$pos / $len * 100"
|
||||
else
|
||||
echo 0
|
||||
fi
|
||||
}
|
||||
|
||||
get_position_time() {
|
||||
pos=$1
|
||||
if [ -n "$pos" ]; then
|
||||
date -d@"$(bc <<< "$pos / 1000000")" +%M:%S
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
get_cover() {
|
||||
# COVER_URL=$1
|
||||
mkdir -p "eww_covers"
|
||||
cd "eww_covers" || exit
|
||||
|
||||
IMGPATH="cover_art"
|
||||
echo '{"image": "eww_covers/cover_art_default", "color": {"alpha":"100","colors":{"color0":"#111215","color1":"#2B698F","color10":"#597591","color11":"#447CC0","color12":"#3A9FB7","color13":"#6192A6","color14":"#60ABCC","color15":"#c4c6ca","color2":"#597591","color3":"#447CC0","color4":"#3A9FB7","color5":"#6192A6","color6":"#60ABCC","color7":"#c4c6ca","color8":"#898a8d","color9":"#2B698F"},"special":{"background":"#111215","cursor":"#c4c6ca","foreground":"#c4c6ca"},"wallpaper":"~/.config/eww/eww_covers/cover_art","source":""}}'
|
||||
|
||||
playerctl -F metadata mpris:artUrl 2>/dev/null | while read -r COVER_URL; do
|
||||
music_source=''
|
||||
if [[ "$COVER_URL" = https* ]]; then
|
||||
music_source=''
|
||||
coverurl="$(playerctl metadata mpris:artUrl)"
|
||||
coverurl_highres_yt="$(echo $coverurl | sed 's/hqdefault/maxresdefault/g')"
|
||||
coverurl_highres_soundcloud="$(echo $coverurl | sed 's/80x80/500x500/g')"
|
||||
|
||||
# SoundCloud
|
||||
if [[ "$coverurl" == *"sndcdn"* ]]; then
|
||||
music_source=''
|
||||
curl --silent --output "$IMGPATH""_soundcloud" "$coverurl_highres_soundcloud" -q –read-timeout=0.1
|
||||
cp "$IMGPATH""_soundcloud" "$IMGPATH"
|
||||
imgsize=$(echo $(du -b ~/.config/eww/eww_covers/cover_art | tr '\t' '\n' | grep -v 'cover_art'))
|
||||
# Youtube
|
||||
elif [[ "$coverurl" == *"ytimg"* ]]; then
|
||||
music_source=''
|
||||
curl --silent --output "$IMGPATH""_yt" "$coverurl_highres_yt" -q –read-timeout=0.1
|
||||
cp "$IMGPATH""_yt" "$IMGPATH"
|
||||
imgsize=$(echo $(du -b ~/.config/eww/eww_covers/cover_art | tr '\t' '\n' | grep -v 'cover_art'))
|
||||
# Likely YT Music
|
||||
elif [[ "$coverurl" == *"googleusercontent"* ]]; then
|
||||
music_source=''
|
||||
curl --silent --output "$IMGPATH""_other" "$coverurl" -q –read-timeout=0.1
|
||||
cp "$IMGPATH""_other" "$IMGPATH"
|
||||
imgsize=$(echo $(du -b ~/.config/eww/eww_covers/cover_art | tr '\t' '\n' | grep -v 'cover_art'))
|
||||
# Any other
|
||||
else
|
||||
curl --silent --output "$IMGPATH""_other" "$coverurl" -q –read-timeout=0.1
|
||||
cp "$IMGPATH""_other" "$IMGPATH"
|
||||
imgsize=$(echo $(du -b ~/.config/eww/eww_covers/cover_art | tr '\t' '\n' | grep -v 'cover_art'))
|
||||
fi
|
||||
# Fallback
|
||||
if [ "$imgsize" == "0" ] || [ ! "$(diff ~/.config/eww/eww_covers/cover_art ~/.config/eww/eww_covers/cover_art_error)" ]; then
|
||||
curl --silent --output "$IMGPATH""_lowres" "$coverurl" -q –read-timeout=0.1
|
||||
cp "$IMGPATH""_lowres" "$IMGPATH"
|
||||
fi
|
||||
|
||||
#Generate colors
|
||||
cd ..
|
||||
scripts/colorgen 'eww_covers/'$IMGPATH $coverurl "$music_source"
|
||||
cd "eww_covers"
|
||||
elif [ "$COVER_URL" = "" ]; then
|
||||
echo '{"image": "", "color": "$bg"}'
|
||||
else
|
||||
COVER_URL="${COVER_URL:7}"
|
||||
cp "$COVER_URL" "$IMGPATH"
|
||||
|
||||
cd ..
|
||||
scripts/colorgen '"eww_covers/'$IMGPATH'"' $coverurl "$music_source"
|
||||
cd "eww_covers"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# SANITIZE FIX
|
||||
sanitize() {
|
||||
echo "$1" | sed 's/"/\"/g'
|
||||
}
|
||||
|
||||
if [ "$1" = "cover" ]; then
|
||||
get_cover
|
||||
elif [ "$1" == "name" ]; then
|
||||
lentolimit=41
|
||||
if [ "$2" != "" ]; then
|
||||
lentolimit=$2
|
||||
fi
|
||||
echo '{"artist": "", "title": ""}'
|
||||
playerctl -F metadata -f '{{title}}\{{artist}}\' 2>/dev/null | while IFS="$(printf '\\')" read -r title artist; do
|
||||
|
||||
if [[ "$title" == *" - YouTube"* && "$artist" == "" ]]; then
|
||||
continue
|
||||
elif [[ "$title" == *"YouTube Music" && "$artist" == "" ]]; then
|
||||
continue
|
||||
fi
|
||||
title=$(scripts/limitlen.py "$title" "$lentolimit")
|
||||
artist=$(scripts/limitlen.py "$artist" "$lentolimit")
|
||||
|
||||
gojq --null-input -r -c \
|
||||
--arg artist "$(sanitize "$artist")" \
|
||||
--arg title "$(sanitize "$title")" \
|
||||
'{"artist": $artist, "title": $title}'
|
||||
|
||||
done
|
||||
else
|
||||
echo '{"artist": "", "title": "", "status": "", "position": "", "position_time": "", "length": ""}'
|
||||
playerctl -F metadata -f '{{title}}\{{artist}}\{{status}}\{{position}}\' 2>/dev/null | while IFS="$(printf '\\')" read -r title artist status position; do
|
||||
|
||||
if [[ "$title" == *" - YouTube" && "$artist" == "" ]]; then
|
||||
continue
|
||||
elif [[ "$title" == *"YouTube Music" && "$artist" == "" ]]; then
|
||||
continue
|
||||
fi
|
||||
len=$(playerctl metadata mpris:length)
|
||||
title=$(scripts/limitlen.py "$title" 40)
|
||||
artist=$(scripts/limitlen.py "$artist" 40)
|
||||
|
||||
gojq --null-input -r -c \
|
||||
--arg artist "$(sanitize "$artist")" \
|
||||
--arg title "$(sanitize "$title")" \
|
||||
--arg status "$(get_status "$status")" \
|
||||
--arg pos "$(get_position "$position" "$len")" \
|
||||
--arg pos_time "$(get_position_time "$position")" \
|
||||
--arg length "$(get_length_time "$len")" \
|
||||
'{"artist": $artist, "title": $title, "status": $status, "position": $pos, "position_time": $pos_time, "length": $length}'
|
||||
|
||||
done
|
||||
fi
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
toggle() {
|
||||
status=$(rfkill -J | jaq -r '.rfkilldevices[] | select(.type == "wlan") | .soft' | head -1)
|
||||
|
||||
if [ "$status" = "unblocked" ]; then
|
||||
rfkill block wlan
|
||||
else
|
||||
rfkill unblock wlan
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$1" = "toggle" ]; then
|
||||
toggle
|
||||
else
|
||||
while true; do
|
||||
status=$(nmcli g | tail -n 1 | awk '{print $1}')
|
||||
signal=$(nmcli -f in-use,signal dev wifi | rg "\*" | awk '{ print $2 }')
|
||||
essid=$(nmcli -t -f NAME connection show --active | head -n1 | sed 's/\"/\\"/g')
|
||||
|
||||
icons=("" "" "" "" "")
|
||||
|
||||
if [ "$status" = "disconnected" ] ; then
|
||||
icon=""
|
||||
color="#988ba2"
|
||||
else
|
||||
level=$(awk -v n="$signal" 'BEGIN{print int((n-1)/20)}')
|
||||
if [ "$level" -gt 4 ]; then
|
||||
level=4
|
||||
fi
|
||||
|
||||
icon=${icons[$level]}
|
||||
color="#cba6f7"
|
||||
fi
|
||||
|
||||
echo '{ "essid": "'"$essid"'", "icon": "'"$icon"'", "color": "'"$color"'", "level": "'"$level"'" }'
|
||||
|
||||
sleep 4
|
||||
done
|
||||
fi
|
||||
Executable
+95
@@ -0,0 +1,95 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
tmp=scripts/cache/dunst-history.json
|
||||
lock="scripts/cache/dunst-toggle.lock"
|
||||
lockinfo="scripts/cache/dunst-lock-info"
|
||||
cd ~/.config/eww
|
||||
|
||||
touch $lockinfo
|
||||
|
||||
declare ids
|
||||
export toggle_icon=""
|
||||
|
||||
sanitize() {
|
||||
retstr=$(echo $1 | sed 's/\\\\/\\\\\\\\/g' | sed 's/"/\\"/g')
|
||||
|
||||
# echo "original: $1"
|
||||
echo "$retstr"
|
||||
# echo 'sanitized'
|
||||
}
|
||||
|
||||
get_ids() {
|
||||
mapfile -t ids < <(dunstctl history | gojq -r ".data[] | .[] | select(.appname.data != \"Spotify\") | .id.data")
|
||||
}
|
||||
|
||||
get_notif() {
|
||||
echo -n '['
|
||||
|
||||
for id in "${ids[@]}"; do
|
||||
mapfile -t n < <(gojq -r ".data[] | .[] | select(.id.data == $id) | .appname.data, .summary.data, .body.data" "$tmp" | sed -r '/^\s*$/d' | sed -e 's/\%/ percent/g')
|
||||
ohkay=$(sanitize "${n[1]}")
|
||||
# echo $ohkay
|
||||
echo -n ''$([ $id -eq ${ids[0]} ] || echo ,)' { '
|
||||
echo -n '"id": "'"$id"'", "appname": "'"${n[0]}"'", "summary": "'"$ohkay"'", "body": "'"${n[2]}"'"'
|
||||
echo -n '}'
|
||||
done
|
||||
|
||||
echo ']'
|
||||
}
|
||||
|
||||
toggle() {
|
||||
dunstctl set-paused toggle
|
||||
|
||||
if [ ! -f "$lock" ]; then
|
||||
export toggle_icon=""
|
||||
touch "$lock"
|
||||
else
|
||||
export toggle_icon=""
|
||||
rm "$lock"
|
||||
fi
|
||||
|
||||
echo "icon_change" > $lockinfo
|
||||
}
|
||||
|
||||
clear() {
|
||||
dunstctl history-clear
|
||||
echo "icon_change" > $lockinfo
|
||||
}
|
||||
|
||||
get_icon() {
|
||||
if [ ${#ids[@]} -eq 0 ]; then
|
||||
echo ""
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$1" == "--once" ]; then
|
||||
dunstctl history > "$tmp"
|
||||
get_ids
|
||||
get_notif
|
||||
elif [ "$1" == "toggle" ]; then
|
||||
toggle
|
||||
dunstctl history > "$tmp"
|
||||
elif [ "$1" == "clear" ]; then
|
||||
clear
|
||||
dunstctl history > "$tmp"
|
||||
elif [ "$1" == "icons" ]; then
|
||||
dunstctl history > "$tmp"
|
||||
get_ids
|
||||
is_paused=$(dunstctl is-paused)
|
||||
echo '{"toggle_icon": "'"$toggle_icon"'", "paused": '"$is_paused"', "icon": "'"$(get_icon)"'"}'
|
||||
tail -f "$lockinfo" | while read -r; do
|
||||
get_ids
|
||||
is_paused=$(dunstctl is-paused)
|
||||
echo '{"toggle_icon": "'"$toggle_icon"'", "paused": '"$is_paused"', "icon": "'"$(get_icon)"'"}'
|
||||
done
|
||||
else
|
||||
dunstctl history > "$tmp"
|
||||
get_ids
|
||||
get_notif
|
||||
tail -f "$tmp" 2>/dev/null | rg --line-buffered "aa\{sv\}" | while read -r; do
|
||||
get_ids
|
||||
get_notif
|
||||
done
|
||||
fi
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
#!/usr/bin/bash
|
||||
dummy='{"thumbnail": null}'
|
||||
|
||||
getwins() {
|
||||
overviewopen=$(scripts/isopen.sh overview)
|
||||
if [ "$overviewopen" == "true" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
focusedws=$(hyprctl -j monitors | gojq -r '.[] | select(.focused == true) | .activeWorkspace.id')
|
||||
hyprctlclients=$(hyprctl clients -j \
|
||||
| grep -v '"xwayland": ' \
|
||||
| grep -v '"grouped": ' \
|
||||
| grep -v '"pid": ' \
|
||||
| grep -v '"fullscreenMode": ' \
|
||||
| grep -v '"monitor": ' \
|
||||
| grep -v '"floating": ' \
|
||||
| grep -v '"fullscreen": ' \
|
||||
| grep -v '"pinned":') # | grep -v ""name":")
|
||||
# echo '-=-=-=- final output -=-=-=-'
|
||||
# echo "$toprint"
|
||||
# echo $(echo "$hyprctlclients") # Print on one line only
|
||||
|
||||
workspace=('[' '[' '[' '[' '[' '[' '[' '[' '[' '[')
|
||||
workspacecnt=(1 1 1 1 1 1 1 1 1 1)
|
||||
outputstring='{'
|
||||
|
||||
wsid=0
|
||||
|
||||
# echo $hyprctlclients | gojq -c '.[]'
|
||||
|
||||
IFS=$'\n'
|
||||
clientsarr=( $(echo $hyprctlclients | gojq -c -M '.[]') )
|
||||
|
||||
#For every window
|
||||
for client in "${clientsarr[@]}"; do
|
||||
wsid=$(echo $client | gojq -c -M '.workspace.id')
|
||||
((wsid-=1))
|
||||
if [[ "$wsid" == "-100" ]]; then
|
||||
continue
|
||||
fi
|
||||
if [[ "${workspacecnt[wsid]}" != "0" ]]; then
|
||||
workspace[wsid]+=","
|
||||
fi
|
||||
|
||||
clientclass=$(echo $client | gojq -r '.class')
|
||||
iconpath=''
|
||||
thumbnailpath=''
|
||||
|
||||
# Get thumbnail
|
||||
clientaddress=$(echo $client | gojq -r '.address')
|
||||
atx=$(echo $client | gojq -c '.at[0]')
|
||||
aty=$(echo $client | gojq -c '.at[1]')
|
||||
sizex=$(echo $client | gojq -c '.size[0]')
|
||||
sizey=$(echo $client | gojq -c '.size[1]')
|
||||
if [ "$(( wsid + 1 ))" == "$focusedws" ]; then
|
||||
grim -g "$atx,$aty ""$sizex"'x'"$sizey" "scripts/cache/thumbnails/$clientaddress.png" -q 1 -t png -l 9
|
||||
fi
|
||||
|
||||
# If thumbnail available
|
||||
if [ -f "scripts/cache/thumbnails/$clientaddress.png" ]; then
|
||||
thumbnailpath="scripts/cache/thumbnails/$clientaddress.png"
|
||||
fi
|
||||
|
||||
client="\"$clientaddress\": \"$thumbnailpath\","
|
||||
outputstring+="$client"
|
||||
|
||||
# echo -n "Window: $clientclass"
|
||||
# echo '; icon path: '"$iconpath"
|
||||
|
||||
|
||||
# echo "Count: ${workspacecnt[wsid]}"
|
||||
# echo 'ADDED TO: workspace '"$wsid"
|
||||
# echo ' --> '"${workspace[wsid]}"
|
||||
((workspacecnt[wsid]+=1))
|
||||
done
|
||||
|
||||
outputstring=${outputstring::-1}
|
||||
outputstring+='}'
|
||||
|
||||
# echo $outputstring
|
||||
}
|
||||
|
||||
# Do stuff here
|
||||
getwins
|
||||
|
||||
if [ "$1" == "--once" ]; then
|
||||
exit 0
|
||||
else
|
||||
while true; do
|
||||
getwins
|
||||
sleep 0.8
|
||||
done
|
||||
fi
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
scripts/overview "$1"
|
||||
|
||||
if [ "$1" == "--once" ]; then
|
||||
exit 0
|
||||
else
|
||||
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | while read -r line; do
|
||||
scripts/overview "$1"
|
||||
done
|
||||
fi
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
scripts/overview --row 1
|
||||
|
||||
if [ "$1" == "--once" ]; then
|
||||
exit 0
|
||||
else
|
||||
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | rg --line-buffered "window>>" | while read -r line; do
|
||||
# This sleep is necessary
|
||||
# It prevents the script from being faster than hyprctl
|
||||
sleep 0.025
|
||||
scripts/overview --row 1
|
||||
done
|
||||
fi
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
scripts/overview --row 2
|
||||
|
||||
if [ "$1" == "--once" ]; then
|
||||
exit 0
|
||||
else
|
||||
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | rg --line-buffered "window>>" | while read -r line; do
|
||||
# This sleep is necessary
|
||||
# It prevents the script from being faster than hyprctl
|
||||
sleep 0.025
|
||||
scripts/overview --row 2
|
||||
done
|
||||
fi
|
||||
Executable
+104
@@ -0,0 +1,104 @@
|
||||
#include <array>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <regex>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include "nlohmann/json.hpp"
|
||||
using namespace std;
|
||||
using json = nlohmann::json;
|
||||
|
||||
#define ROWS 2
|
||||
#define COLS 5
|
||||
|
||||
string clients;
|
||||
json clientjson, apps;
|
||||
json workspaces;
|
||||
string workspaceInitTemplate =
|
||||
"[{\"address\":\"_none\",\"at\":[0,0],\"class\":\"workspace\",\"size\":["
|
||||
"1920,1080],\"title\":\"__WORKSPACE_ID\",\"workspace\":{\"id\":__WORKSPACE_"
|
||||
"ID,\"name\":\"__WORKSPACE_ID\"}}]";
|
||||
vector<string> appnames;
|
||||
|
||||
string exec(const char* cmd) {
|
||||
array<char, 128> buffer;
|
||||
string result;
|
||||
unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
|
||||
if (!pipe) {
|
||||
throw runtime_error("popen() failed!");
|
||||
}
|
||||
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
|
||||
result += buffer.data();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void initWorkspaces() {
|
||||
for (int i = 0; i < ROWS; i++) {
|
||||
workspaces.push_back(json::array({})); // []
|
||||
for (int j = 0; j < COLS; j++) {
|
||||
int workspaceNum = i * COLS + j + 1; // Note: Workspaces are 1-base
|
||||
string workspaceInitString =
|
||||
regex_replace(workspaceInitTemplate, regex("__WORKSPACE_ID"),
|
||||
to_string(workspaceNum));
|
||||
json thisWorkspaceInit = json::parse(workspaceInitString);
|
||||
workspaces[i].push_back(thisWorkspaceInit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void addApp(json& client) {
|
||||
if(string(client["class"]).size() == 0) return;
|
||||
|
||||
// Calculate position in overview tile
|
||||
int workspaceNum = int(client["workspace"]["id"]) - 1; // 1-base to 0-base
|
||||
if(workspaceNum < 0) return; //Skip scratchpads/specials, as they have negative ids
|
||||
int i = workspaceNum / COLS, j = workspaceNum % COLS;
|
||||
|
||||
// New JSON for app
|
||||
json newApp =
|
||||
R"({"class": "", "workspace": {"id": 8, "name": "8"}, "title": "", "at": [0, 0], "size": [0, 0], "address": [], "icon": ""})"_json;
|
||||
// Add normal stuff
|
||||
newApp["class"] = client["class"];
|
||||
newApp["address"] = client["address"];
|
||||
newApp["workspace"] = client["workspace"];
|
||||
newApp["title"] = client["title"];
|
||||
newApp["at"] = client["at"];
|
||||
newApp["size"] = client["size"];
|
||||
// Icon path
|
||||
string filename = string("./scripts/cache/" + string(client["class"]));
|
||||
std::ifstream ifs(filename);
|
||||
std::string iconpath((std::istreambuf_iterator<char>(ifs)),
|
||||
(std::istreambuf_iterator<char>()));
|
||||
while (iconpath.size() > 0 && *iconpath.rbegin() == '\n') iconpath.pop_back(); // Remove '\n'
|
||||
newApp["icon"] = iconpath;
|
||||
|
||||
workspaces[i][j].push_back(newApp);
|
||||
}
|
||||
|
||||
void getApps() {
|
||||
// Get clients
|
||||
clients = exec("hyprctl clients -j | gojq -c -M");
|
||||
clientjson = json::parse(clients);
|
||||
|
||||
// Access the values
|
||||
for (json client : clientjson) {
|
||||
addApp(client);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
initWorkspaces();
|
||||
getApps();
|
||||
if (argc == 2) cout << workspaces[0][stoi(argv[1]) - 1] << '\n';
|
||||
if (argc == 3 && string(argv[1]) == "--row" && stoi(argv[2]) >= 1 && stoi(argv[2]) <= ROWS) {
|
||||
cout << workspaces[stoi(argv[2]) - 1] << '\n';
|
||||
} else
|
||||
cout << workspaces << '\n';
|
||||
}
|
||||
Executable
+129
@@ -0,0 +1,129 @@
|
||||
#!/usr/bin/bash
|
||||
dummy='{"address":"_none","at":[0,0],"class":"workspace","size":[1920,1080],"title":"<___overview_workspace>","workspace":{"id":<___overview_workspace>, "name": "<___overview_workspace>"}}'
|
||||
|
||||
getwins() {
|
||||
hyprctlclients=$(hyprctl clients -j \
|
||||
| grep -v '"mapped": ' \
|
||||
| grep -v '"hidden": ' \
|
||||
| grep -v '"floating": ' \
|
||||
| grep -v '"monitor": ' \
|
||||
| grep -v '"pid": ' \
|
||||
| grep -v '"xwayland": ' \
|
||||
| grep -v '"pinned":' \
|
||||
| grep -v '"fullscreen": ' \
|
||||
| grep -v '"fullscreenMode": ' \
|
||||
| grep -v '"fakeFullscreen": ' \
|
||||
| grep -v '"grouped": ')
|
||||
|
||||
workspace=('[' '[' '[' '[' '[' '[' '[' '[' '[' '[')
|
||||
workspacecnt=(1 1 1 1 1 1 1 1 1 1)
|
||||
|
||||
wsid=0
|
||||
for i in 0 1 2 3 4; do
|
||||
workspace[i]+=$(echo $dummy | sed "s/<___overview_workspace>/$((i+1))/g")
|
||||
done
|
||||
|
||||
# echo $hyprctlclients | gojq -c '.[]'
|
||||
|
||||
IFS=$'\n'
|
||||
clientsarr=( $(echo $hyprctlclients | gojq -c -M '.[]') )
|
||||
|
||||
#For every window
|
||||
for client in "${clientsarr[@]}"; do
|
||||
wsid=$(echo $client | gojq -c -M '.workspace.id')
|
||||
if [[ $wsid -gt 5 ]]; then
|
||||
continue
|
||||
fi
|
||||
((wsid-=1))
|
||||
iconpath=''
|
||||
clientclass=$(echo "$client" | gojq -r '.class')
|
||||
if [[ "$clientclass" == "" ]]; then
|
||||
continue
|
||||
fi
|
||||
if [[ "$wsid" == "-100" ]]; then
|
||||
continue
|
||||
fi
|
||||
if [[ "${workspacecnt[wsid]}" != "0" ]]; then
|
||||
workspace[wsid]+=","
|
||||
fi
|
||||
|
||||
# If thumbnail available
|
||||
# if [ -f "scripts/cache/thumbnails/$clientaddress.png" ]; then
|
||||
# thumbnailpath="scripts/cache/thumbnails/$clientaddress.png"
|
||||
# fi
|
||||
|
||||
# Get app icon
|
||||
if [ -f "scripts/cache/$clientclass" ]; then
|
||||
iconpath=$(cat scripts/cache/$clientclass)
|
||||
if [ ! -f "${iconpath}" ]; then # Cache refresh if icon doesnt exist
|
||||
iconpath=$(geticons -t $(gsettings get org.gnome.desktop.interface icon-theme | sed "s/'//g") "$clientclass" | head -n 1)
|
||||
echo "${iconpath}" > "scripts/cache/$clientclass"
|
||||
fi
|
||||
else
|
||||
iconpath=$(geticons -t $(gsettings get org.gnome.desktop.interface icon-theme | sed "s/'//g") "$clientclass" | head -n 1)
|
||||
echo "${iconpath}" > "scripts/cache/$clientclass"
|
||||
fi
|
||||
if [[ ${iconpath} == "" ]]; then
|
||||
# Retry with lowercase if icon not found
|
||||
iconpath=$(geticons -t $(gsettings get org.gnome.desktop.interface icon-theme | sed "s/'//g") $(echo "$clientclass" | tr '[:upper:]' '[:lower:]' | sed 's/\ /-/g') | head -n 1)
|
||||
|
||||
if [[ ! ${iconpath} = "" ]]; then
|
||||
rm "scripts/cache/$clientclass"
|
||||
echo "${iconpath}" > "scripts/cache/$clientclass"
|
||||
else
|
||||
newname=$(scripts/iconpatch $clientclass)
|
||||
iconpath=$(geticons -t $(gsettings get org.gnome.desktop.interface icon-theme | sed "s/'//g") "$newname" | head -n 1)
|
||||
if [[ ! ${iconpath} = "" ]]; then
|
||||
rm "scripts/cache/$clientclass"
|
||||
echo "${iconpath}" > "scripts/cache/$clientclass"
|
||||
else
|
||||
# Fallback app icon, replace the path below to the fallback icon of your choice
|
||||
# iconpath="/usr/share/icons/Win11-dark/mimes/48/application-x-executable.svg"
|
||||
iconpath=$(geticons -t $(gsettings get org.gnome.desktop.interface icon-theme | sed "s/'//g") "application-x-executable" | head -n 1)
|
||||
rm "scripts/cache/$clientclass"
|
||||
echo "${iconpath}" > "scripts/cache/$clientclass"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
client=${client::-1}
|
||||
client+=",\"icon\": \"$iconpath\"}"
|
||||
workspace[wsid]+="$client" # Add window to workspace JSON
|
||||
|
||||
# echo -n "Window: $clientclass"
|
||||
# echo '; icon path: '"$iconpath"
|
||||
|
||||
|
||||
# echo "Count: ${workspacecnt[wsid]}"
|
||||
# echo 'ADDED TO: workspace '"$wsid"
|
||||
# echo ' --> '"${workspace[wsid]}"
|
||||
((workspacecnt[wsid]+=1))
|
||||
done
|
||||
|
||||
for i in 0 1 2 3 4; do
|
||||
workspace[i]+=']'
|
||||
done
|
||||
|
||||
# echo '-=-=-=-=-=- Summary -=-=-=-=-=-'
|
||||
|
||||
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=- PRINT STUFF HERE -=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||
echo -n '['
|
||||
for i in 0 1 2 3 4; do
|
||||
if [[ $i != 0 ]]; then
|
||||
echo -n ','
|
||||
fi
|
||||
echo -n "${workspace[i]}"
|
||||
done
|
||||
echo ']'
|
||||
}
|
||||
|
||||
# Do stuff here
|
||||
getwins
|
||||
|
||||
if [ "$1" == "--once" ]; then
|
||||
exit 0
|
||||
else
|
||||
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | rg --line-buffered "window>>" | while read -r line; do
|
||||
getwins
|
||||
done
|
||||
fi
|
||||
Executable
+123
@@ -0,0 +1,123 @@
|
||||
#!/usr/bin/bash
|
||||
dummy='{"address":"_none","at":[0,0],"class":"workspace","size":[1920,1080],"title":"<___overview_workspace>","workspace":{"id":<___overview_workspace>, "name": "<___overview_workspace>"}}'
|
||||
|
||||
getwins() {
|
||||
hyprctlclients=$(hyprctl clients -j \
|
||||
| grep -v '"mapped": ' \
|
||||
| grep -v '"hidden": ' \
|
||||
| grep -v '"floating": ' \
|
||||
| grep -v '"monitor": ' \
|
||||
| grep -v '"pid": ' \
|
||||
| grep -v '"xwayland": ' \
|
||||
| grep -v '"pinned":' \
|
||||
| grep -v '"fullscreen": ' \
|
||||
| grep -v '"fullscreenMode": ' \
|
||||
| grep -v '"fakeFullscreen": ' \
|
||||
| grep -v '"grouped": ')
|
||||
|
||||
|
||||
|
||||
workspace=('[' '[' '[' '[' '[' '[' '[' '[' '[' '[')
|
||||
workspacecnt=(1 1 1 1 1 1 1 1 1 1)
|
||||
|
||||
wsid=0
|
||||
for i in 5 6 7 8 9; do
|
||||
workspace[i]+=$(echo $dummy | sed "s/<___overview_workspace>/$((i+1))/g")
|
||||
done
|
||||
|
||||
# echo $hyprctlclients | gojq -c '.[]'
|
||||
|
||||
IFS=$'\n'
|
||||
clientsarr=( $(echo $hyprctlclients | gojq -c -M '.[]') )
|
||||
for client in "${clientsarr[@]}"; do
|
||||
wsid=$(echo $client | gojq -c -M '.workspace.id')
|
||||
if [[ $wsid -lt 6 ]]; then
|
||||
continue
|
||||
fi
|
||||
((wsid-=1))
|
||||
iconpath=''
|
||||
clientclass=$(echo $client | gojq -r '.class')
|
||||
if [[ "$clientclass" == "" ]]; then
|
||||
continue
|
||||
fi
|
||||
if [[ "$wsid" == "-100" ]]; then
|
||||
continue
|
||||
fi
|
||||
if [[ "${workspacecnt[wsid]}" != "0" ]]; then
|
||||
workspace[wsid]+=","
|
||||
fi
|
||||
|
||||
# Get app icon
|
||||
if [ -f "scripts/cache/$clientclass" ]; then
|
||||
iconpath=$(cat scripts/cache/$clientclass)
|
||||
if [ ! -f "${iconpath}" ]; then # Cache refresh if icon doesnt exist
|
||||
iconpath=$(geticons -t $(gsettings get org.gnome.desktop.interface icon-theme | sed "s/'//g") "$clientclass" | head -n 1)
|
||||
echo "${iconpath}" > "scripts/cache/$clientclass"
|
||||
fi
|
||||
else
|
||||
iconpath=$(geticons -t $(gsettings get org.gnome.desktop.interface icon-theme | sed "s/'//g") "$clientclass" | head -n 1)
|
||||
echo "${iconpath}" > "scripts/cache/$clientclass"
|
||||
fi
|
||||
if [[ ${iconpath} == "" ]]; then
|
||||
# Retry with lowercase if icon not found
|
||||
iconpath=$(geticons -t $(gsettings get org.gnome.desktop.interface icon-theme | sed "s/'//g") $(echo "$clientclass" | tr '[:upper:]' '[:lower:]' | sed 's/\ /-/g') | head -n 1)
|
||||
if [[ ! ${iconpath} = "" ]]; then
|
||||
rm "scripts/cache/$clientclass"
|
||||
echo "${iconpath}" > "scripts/cache/$clientclass"
|
||||
else
|
||||
newname=$(scripts/iconpatch $clientclass)
|
||||
iconpath=$(geticons -t $(gsettings get org.gnome.desktop.interface icon-theme | sed "s/'//g") "$newname" | head -n 1)
|
||||
if [[ ! ${iconpath} = "" ]]; then
|
||||
rm "scripts/cache/$clientclass"
|
||||
echo "${iconpath}" > "scripts/cache/$clientclass"
|
||||
else
|
||||
# Fallback app icon, replace the path below to the fallback icon of your choice
|
||||
# iconpath="/usr/share/icons/Win11-dark/mimes/48/application-x-executable.svg"
|
||||
iconpath=$(geticons -t $(gsettings get org.gnome.desktop.interface icon-theme | sed "s/'//g") "application-x-executable" | head -n 1)
|
||||
rm "scripts/cache/$clientclass"
|
||||
echo "${iconpath}" > "scripts/cache/$clientclass"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
client=${client::-1}
|
||||
client+=",\"icon\": \"$iconpath\"}"
|
||||
workspace[wsid]+="$client" # Add window to workspace JSON
|
||||
|
||||
# echo -n "Window: $clientclass"
|
||||
# echo '; icon path: '"$iconpath"
|
||||
|
||||
|
||||
# echo "Count: ${workspacecnt[wsid]}"
|
||||
# echo 'ADDED TO: workspace '"$wsid"
|
||||
# echo ' --> '"${workspace[wsid]}"
|
||||
((workspacecnt[wsid]+=1))
|
||||
done
|
||||
|
||||
for i in 5 6 7 8 9; do
|
||||
workspace[i]+=']'
|
||||
done
|
||||
|
||||
# echo '-=-=-=-=-=- Summary -=-=-=-=-=-'
|
||||
|
||||
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=- PRINT STUFF HERE -=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||
echo -n '['
|
||||
for i in 5 6 7 8 9; do
|
||||
if [[ $i != 5 ]]; then
|
||||
echo -n ','
|
||||
fi
|
||||
echo -n "${workspace[i]}"
|
||||
done
|
||||
echo ']'
|
||||
}
|
||||
|
||||
# Do stuff here
|
||||
getwins
|
||||
|
||||
if [ "$1" == "--once" ]; then
|
||||
exit 0
|
||||
else
|
||||
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | rg --line-buffered "window>>" | while read -r line; do
|
||||
getwins
|
||||
done
|
||||
fi
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Get month diff
|
||||
diffmonth=$(eww get monthshift)
|
||||
if [[ "$1" == "up" ]]; then
|
||||
diffmonth=$(( $diffmonth - 1 ))
|
||||
else
|
||||
diffmonth=$(( $diffmonth + 1 ))
|
||||
fi
|
||||
eww update monthshift="$diffmonth" &
|
||||
|
||||
# Get dates
|
||||
dates=$(scripts/getfirstdayofmonth "$diffmonth")
|
||||
dateSplitted=( $dates )
|
||||
newTitle=$(date -d "${dateSplitted[3]}-${dateSplitted[2]}-${dateSplitted[1]}" "+%B %Y")
|
||||
|
||||
if [[ "$diffmonth" == "0" ]]; then
|
||||
dates=''
|
||||
fi
|
||||
eww update calendartitle="$newTitle" &
|
||||
eww update calendar="$(scripts/calendarlayout $dates)"
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
selected=$(eval $2 get selected)
|
||||
|
||||
|
||||
if [[ $selected == "_none" ]] || [[ $selected == "" ]]; then
|
||||
eval "$2 update selected=$1"
|
||||
selected=$(eval $2 get selected)
|
||||
else
|
||||
hyprctl dispatch movetoworkspacesilent $3,address:$selected
|
||||
|
||||
eval "$2 update selected=_none"
|
||||
selected=$(eval $2 get selected)
|
||||
fi
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
plugged=0
|
||||
|
||||
swaybg -i images/wallpaper/wallpaper-cultured &
|
||||
|
||||
while true; do
|
||||
STATE=$(cat /sys/class/power_supply/BATT/status)
|
||||
if [[ "$STATE" = "Charging" ]]; then
|
||||
if [ "$plugged" -eq "0" ]; then
|
||||
plugged=1
|
||||
notify-send 'Aghh~~~~'
|
||||
play scripts/supersecretsettings/culture.mp3
|
||||
fi
|
||||
else
|
||||
plugged=0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
cp ~/.config/hypr/hyprland.conf temporary_config.conf && cp temporary_config.conf ~/.config/hypr/hyprland.conf
|
||||
rm temporary_config.conf
|
||||
|
||||
pkill swaybg
|
||||
swaybg -i images/wallpaper/wallpaper-normal
|
||||
|
||||
kill $(pidof eww) && eww open bar && eww open bg-decor
|
||||
Executable
+85
@@ -0,0 +1,85 @@
|
||||
#include <array>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "nlohmann/json.hpp"
|
||||
using namespace std;
|
||||
using json = nlohmann::json;
|
||||
|
||||
int workspace_a, workspace_b;
|
||||
string clients;
|
||||
json clientjson;
|
||||
vector<string> windows_a, windows_b;
|
||||
bool output = false;
|
||||
|
||||
string exec(const char* cmd) {
|
||||
array<char, 128> buffer;
|
||||
string result;
|
||||
unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
|
||||
if (!pipe) {
|
||||
throw runtime_error("popen() failed!");
|
||||
}
|
||||
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
|
||||
result += buffer.data();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void tryAddApp(const json& client) {
|
||||
if (int(client["workspace"]["id"]) == workspace_a)
|
||||
windows_a.push_back(client["address"]);
|
||||
else if (int(client["workspace"]["id"]) == workspace_b)
|
||||
windows_b.push_back(client["address"]);
|
||||
}
|
||||
|
||||
void getApps() {
|
||||
// Get clients
|
||||
clients = exec("hyprctl clients -j | gojq -c -M");
|
||||
clientjson = json::parse(clients);
|
||||
|
||||
// Access the values
|
||||
for (json client : clientjson) {
|
||||
tryAddApp(client);
|
||||
}
|
||||
}
|
||||
|
||||
void swapWorkspaces() {
|
||||
for (string address : windows_a) {
|
||||
string cmd = "hyprctl dispatch movetoworkspacesilent " +
|
||||
to_string(workspace_b) + ",address:" + address;
|
||||
if (output) cout << cmd << '\n';
|
||||
exec(&cmd[0]);
|
||||
}
|
||||
for (string address : windows_b) {
|
||||
string cmd = "hyprctl dispatch movetoworkspacesilent " +
|
||||
to_string(workspace_a) + ",address:" + address;
|
||||
if (output) cout << cmd << '\n';
|
||||
exec(&cmd[0]);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
ios::sync_with_stdio(false);
|
||||
|
||||
if (argc < 3) {
|
||||
cout << "Usage: swapws [WORKSPACE_NUMBER_1] [WORKSPACE_NUMBER_2]"
|
||||
<< endl;
|
||||
return 0;
|
||||
}
|
||||
if (argc == 4 && string(argv[3]) == "--output") output = true;
|
||||
|
||||
workspace_a = stoi(string(argv[1]));
|
||||
workspace_b = stoi(string(argv[2]));
|
||||
if (workspace_a <= 0 || workspace_b <= 0 || workspace_a == workspace_b) {
|
||||
cout << "Nahhh that's stupid" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
getApps();
|
||||
swapWorkspaces();
|
||||
}
|
||||
Executable
+86
@@ -0,0 +1,86 @@
|
||||
#include <array>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "nlohmann/json.hpp"
|
||||
using namespace std;
|
||||
using json = nlohmann::json;
|
||||
|
||||
string clients, pinned;
|
||||
json clientjson, apps;
|
||||
vector<string> appnames;
|
||||
|
||||
string exec(const char* cmd) {
|
||||
array<char, 128> buffer;
|
||||
string result;
|
||||
unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
|
||||
if (!pipe) {
|
||||
throw runtime_error("popen() failed!");
|
||||
}
|
||||
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
|
||||
result += buffer.data();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void addApp(json& client) {
|
||||
if(string(client["class"]).size() == 0) return;
|
||||
|
||||
bool found = false;
|
||||
for (json& obj : apps) {
|
||||
auto it = obj.find("class");
|
||||
if (it != obj.end() && *it == client["class"]) {
|
||||
found = true;
|
||||
obj["count"] = int(obj["count"]) + 1;
|
||||
obj["address"].push_back(client["address"]);
|
||||
obj["workspace"].push_back(client["workspace"]["id"]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
json newApp =
|
||||
R"({"class": "", "count": 1, "workspace": [], "address": [], "icon": ""})"_json;
|
||||
newApp["class"] = client["class"];
|
||||
newApp["address"].push_back(client["address"]);
|
||||
newApp["workspace"].push_back(client["workspace"]["id"]);
|
||||
string filename = string("./scripts/cache/" + string(client["class"]));
|
||||
std::ifstream ifs(filename);
|
||||
std::string iconpath((std::istreambuf_iterator<char>(ifs)),
|
||||
(std::istreambuf_iterator<char>()));
|
||||
// cout << "PATH: " << filename << " | ICON PATH: " << iconpath << '\n';
|
||||
while (iconpath.size() > 0 && *iconpath.rbegin() == '\n') iconpath.pop_back(); // Remove '\n'
|
||||
newApp["icon"] = iconpath;
|
||||
|
||||
apps.push_back(newApp);
|
||||
}
|
||||
}
|
||||
|
||||
void getAppNameAndCount() {
|
||||
// Get clients
|
||||
clients = exec("hyprctl clients -j | gojq -c -M");
|
||||
pinned = exec("cat modules/taskbar.json | gojq -c -M");
|
||||
clientjson = json::parse(clients);
|
||||
apps = json::parse(pinned);
|
||||
|
||||
// Access the values
|
||||
for (json client : clientjson) {
|
||||
addApp(client);
|
||||
// cout << client << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
void getAppIcon() {}
|
||||
|
||||
int main() {
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
getAppNameAndCount();
|
||||
getAppIcon();
|
||||
cout << apps << '\n';
|
||||
}
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
scripts/taskbar
|
||||
|
||||
if [ "$1" == "--once" ]; then
|
||||
scripts/taskbar
|
||||
exit 0
|
||||
else
|
||||
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | rg --line-buffered "window>>" | while read -r line; do
|
||||
scripts/taskbar
|
||||
echo
|
||||
done
|
||||
fi
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
scripts/taskviewlayout
|
||||
|
||||
if [ "$1" == "--once" ]; then
|
||||
exit 0
|
||||
else
|
||||
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | rg --line-buffered "window>>" | while read -r line; do
|
||||
# This sleep is necessary
|
||||
# It prevents the script from being faster than hyprctl
|
||||
sleep 0.025
|
||||
scripts/taskviewlayout
|
||||
done
|
||||
fi
|
||||
Executable
+187
@@ -0,0 +1,187 @@
|
||||
#include <array> // This script tries to show windows of workspaces
|
||||
#include <cmath> // in a reasonable way in Task View
|
||||
#include <filesystem> //
|
||||
#include <fstream> // Goal: all windows on the same row have equal height
|
||||
#include <iostream> //
|
||||
#include <memory> //
|
||||
#include <regex> // binary search -> ok scale
|
||||
#include <stdexcept> // -> sort small-wide windows -> match pairs -> rows
|
||||
#include <string>
|
||||
|
||||
#include "nlohmann/json.hpp"
|
||||
|
||||
using namespace std;
|
||||
using json = nlohmann::json;
|
||||
|
||||
#define COLS 10
|
||||
#define RES_WIDTH 1920
|
||||
#define RES_HEIGHT 1080
|
||||
#define RESERVED_BOTTOM 250
|
||||
#define SPACING 30
|
||||
#define TITLEBAR_AND_BORDER_HEIGHT 51
|
||||
#define MIN_ROW_HEIGHT 186 // 100px (else scroll down)
|
||||
#define MAX_ROW_HEIGHT 300 // 100px (else scroll down)
|
||||
const json EMPTY_JSON = R"([])"_json;
|
||||
const string workspaceInitTemplate = "[]";
|
||||
|
||||
int numOfApps[COLS] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
string clients;
|
||||
json clientjson, workspaces;
|
||||
json workspacesArranged;
|
||||
|
||||
string exec(const char* cmd) {
|
||||
array<char, 128> buffer;
|
||||
string result;
|
||||
unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
|
||||
if (!pipe) {
|
||||
throw runtime_error("popen() failed!");
|
||||
}
|
||||
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
|
||||
result += buffer.data();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void initWorkspaces() {
|
||||
int i = 0;
|
||||
for (int j = 0; j < COLS; j++) {
|
||||
int workspaceNum = i * COLS + j + 1; // Note: Workspaces are 1-base
|
||||
string workspaceInitString =
|
||||
regex_replace(workspaceInitTemplate, regex("__WORKSPACE_ID"),
|
||||
to_string(workspaceNum));
|
||||
json thisWorkspaceInit = json::parse(workspaceInitString);
|
||||
workspaces.push_back(thisWorkspaceInit);
|
||||
}
|
||||
}
|
||||
|
||||
void addApp(json& client) {
|
||||
if(string(client["class"]).size() == 0) return;
|
||||
// Calculate position in overview tile
|
||||
int workspaceNum = int(client["workspace"]["id"]) - 1; // 1-base to 0-base
|
||||
if (workspaceNum < 0)
|
||||
return; // Skip scratchpads/specials, as they have negative ids
|
||||
int i = workspaceNum / COLS, j = workspaceNum % COLS;
|
||||
|
||||
// New JSON for app
|
||||
json newApp =
|
||||
R"({"class": "", "workspace": {"id": 8, "name": "8"}, "title": "", "at": [0, 0], "size": [0, 0], "address": [], "icon": ""})"_json;
|
||||
|
||||
// Add normal stuff
|
||||
newApp["class"] = client["class"];
|
||||
newApp["address"] = client["address"];
|
||||
newApp["workspace"] = client["workspace"];
|
||||
newApp["title"] = client["title"];
|
||||
newApp["size"] = client["size"];
|
||||
|
||||
// Icon path
|
||||
string filename = string("./scripts/cache/" + string(client["class"]));
|
||||
std::ifstream ifs(filename);
|
||||
std::string iconpath((std::istreambuf_iterator<char>(ifs)),
|
||||
(std::istreambuf_iterator<char>()));
|
||||
while (iconpath.size() > 0 && *iconpath.rbegin() == '\n')
|
||||
iconpath.pop_back(); // Remove '\n'
|
||||
newApp["icon"] = iconpath;
|
||||
|
||||
// Counting
|
||||
int size_x = int(newApp["size"][0]);
|
||||
int size_y = int(newApp["size"][1]);
|
||||
if (size_x <= size_y * 2) { // Normal
|
||||
newApp["countAs"] = 1; // count as 1 window
|
||||
} else { // Very wide
|
||||
newApp["countAs"] = 2; // count as 2 windows
|
||||
}
|
||||
numOfApps[int(newApp["workspace"]["id"]) - 1] += int(newApp["countAs"]);
|
||||
|
||||
// Push
|
||||
workspaces[j].push_back(newApp);
|
||||
}
|
||||
|
||||
void getApps() {
|
||||
// Get clients
|
||||
clients = exec("hyprctl clients -j | gojq -c -M");
|
||||
clientjson = json::parse(clients);
|
||||
|
||||
// Access the values
|
||||
for (json client : clientjson) {
|
||||
addApp(client);
|
||||
}
|
||||
}
|
||||
|
||||
void scaleWindows() {
|
||||
for (int i = 0; i < workspaces.size(); i++) {
|
||||
if (workspaces[i].size() == 0) {
|
||||
workspacesArranged.push_back(EMPTY_JSON);
|
||||
continue;
|
||||
}
|
||||
// Declare
|
||||
int numOfRows = numOfApps[i] > 3 ? int(ceil(sqrt(numOfApps[i]))) : 1;
|
||||
int winsPerRow = (numOfApps[i] + (numOfRows - 1)) / numOfRows; // ceil
|
||||
json thisWorkspace = EMPTY_JSON;
|
||||
for (int i = 0; i < numOfRows; i++) thisWorkspace.push_back(EMPTY_JSON);
|
||||
int rowHeight =
|
||||
min(max(MIN_ROW_HEIGHT,
|
||||
(RES_HEIGHT - RESERVED_BOTTOM - SPACING) / numOfRows -
|
||||
TITLEBAR_AND_BORDER_HEIGHT - SPACING),
|
||||
MAX_ROW_HEIGHT);
|
||||
int thisRowCnt = 0, rowsDone = 0;
|
||||
|
||||
// cout << "Workspace " << i + 1 << " | Rows: " << numOfRows
|
||||
// << " | Per row: " << winsPerRow << '\n';
|
||||
|
||||
// Scale
|
||||
for (json& window : workspaces[i]) {
|
||||
int cntAs = int(window["countAs"]);
|
||||
if (cntAs == 1) {
|
||||
window["size"][0] = int(window["size"][0]) /
|
||||
(float(window["size"][1]) / rowHeight);
|
||||
window["size"][1] = rowHeight;
|
||||
} else { // cntAs == 2
|
||||
window["size"][1] =
|
||||
int(float(window["size"][1]) /
|
||||
(float(window["size"][0]) / (rowHeight * 2)));
|
||||
window["size"][0] = rowHeight * 2;
|
||||
}
|
||||
|
||||
// int minWidth = string(window["title"]).size() * 9;
|
||||
// cout << "Window: " << string(window["title"])
|
||||
// << ", min width: " << minWidth << '\n';
|
||||
// if (window["size"][0] < minWidth) {
|
||||
// window["size"][1] = int(window["size"][1]) *
|
||||
// (float(minWidth) /
|
||||
// int(window["size"][0]));
|
||||
// window["size"][0] = minWidth;
|
||||
// }
|
||||
// cout << " --> " << window["size"][0] << "x" << window["size"][1]
|
||||
// << '\n';
|
||||
|
||||
thisWorkspace[rowsDone].push_back(window);
|
||||
thisRowCnt += int(window["countAs"]);
|
||||
if (thisRowCnt >= winsPerRow) {
|
||||
rowsDone++;
|
||||
thisRowCnt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
workspacesArranged.push_back(thisWorkspace);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
ios::sync_with_stdio(false);
|
||||
|
||||
// Get windows in workspaces, counting
|
||||
initWorkspaces();
|
||||
getApps();
|
||||
|
||||
// cout << ">>>>>>>> [DEBUG INGO START] >>>>>>>>" << '\n';
|
||||
// cout << workspaces << '\n';
|
||||
// cout << "<<<<<<<< [DEBUG INGO END] <<<<<<<<" << '\n' << '\n';
|
||||
|
||||
// cout << "# of apps: ";
|
||||
// for (int i = 0; i < COLS; i++) cout << numOfApps[i] << ' ';
|
||||
// cout << '\n';
|
||||
// Scaling, arranging
|
||||
scaleWindows();
|
||||
|
||||
cout << workspacesArranged << '\n';
|
||||
}
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/bash
|
||||
state=$(eww get winstart_allapps)
|
||||
|
||||
if [[ "$state" == "true" || "$1" == "--close" ]]; then
|
||||
eww update winstart_allapps=false
|
||||
else
|
||||
eww update winstart_allapps=true
|
||||
# This sleep is necessary for it to animate smoothly!
|
||||
sleep 0.2
|
||||
eww update allapps="$(eww get allapps_get)"
|
||||
fi
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/bash
|
||||
state=$(eww get rev_bottombar)
|
||||
|
||||
if [[ "$state" == "true" || "$1" == "--close" ]]; then
|
||||
eww update anim_open_bottombar=false
|
||||
eww update rev_bottombar=false
|
||||
# eww update force_sys_rev=false
|
||||
sleep 0.15
|
||||
eww close bottombar 2>/dev/null
|
||||
eww close bottombar-back 2>/dev/null
|
||||
eww update cavajson=''
|
||||
else
|
||||
eww update anim_open_bottombar=true
|
||||
eww open bottombar-back
|
||||
eww open bottombar
|
||||
eww update rev_bottombar=true
|
||||
# eww update force_sys_rev=true &
|
||||
fi
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/bash
|
||||
state=$(eww get rev_calendar)
|
||||
|
||||
if [[ "$state" == "true" || "$1" == "--close" ]]; then
|
||||
eww update anim_open_calendar=false
|
||||
eww update rev_calendar=false
|
||||
sleep 0.15
|
||||
eww close calendar 2>/dev/null
|
||||
else
|
||||
eww update anim_open_calendar=true
|
||||
eww open calendar
|
||||
eww update rev_calendar=true
|
||||
fi
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
state=$(hyprctl getoption decoration:rounding -j | gojq '.int')
|
||||
|
||||
if [[ "$state" != "0" || "$1" == "--enable" ]]; then
|
||||
eww update compact=true &
|
||||
hyprctl keyword decoration:rounding 0
|
||||
hyprctl keyword general:gaps_in 0
|
||||
hyprctl keyword general:gaps_out 0
|
||||
hyprctl keyword monitor eDP-1,addreserved,69,0,0,0
|
||||
if [[ "$2" == "--border" ]]; then
|
||||
hyprctl keyword general:border_size "$3"
|
||||
else
|
||||
hyprctl keyword general:border_size 1
|
||||
fi
|
||||
else
|
||||
eww update compact=false &
|
||||
hyprctl reload
|
||||
fi
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/bash
|
||||
cd ~/.config/eww || exit
|
||||
|
||||
reserves=$(hyprctl monitors -j | gojq -r -c '.[0]["reserved"]')
|
||||
if [[ "$1" == "--keypress" && "$reserves" == "[0,0,0,50]" ]]; then
|
||||
scripts/toggle-winactions.sh
|
||||
exit
|
||||
fi
|
||||
|
||||
state=$(eww get rev_dash)
|
||||
|
||||
if [[ "$state" == "true" || "$1" == "--close" ]]; then
|
||||
eww update anim_open_dash=false
|
||||
eww update rev_dash=false
|
||||
sleep 0.08
|
||||
eww close dashboard 2>/dev/null
|
||||
else
|
||||
scripts/toggle-overview.sh --close &
|
||||
scripts/toggle-osettings.sh --close &
|
||||
scripts/toggle-onotify.sh --close &
|
||||
eww update anim_open_dash=true
|
||||
eww open dashboard
|
||||
eww update rev_dash=true
|
||||
fi
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/bash
|
||||
cd ~/.config/eww || exit
|
||||
|
||||
reserves=$(hyprctl monitors -j | gojq -r -c '.[0]["reserved"]')
|
||||
if [[ "$1" == "--keypress" && "$reserves" == "[0,0,0,50]" ]]; then
|
||||
scripts/toggle-winactions.sh
|
||||
exit
|
||||
fi
|
||||
|
||||
state=$(eww get rev_dashfs)
|
||||
|
||||
if [[ "$state" == "true" || "$1" == "--close" ]]; then
|
||||
eww update anim_open_dashfs=false
|
||||
eww update rev_dashfs=false
|
||||
sleep 0.15
|
||||
eww close dashfs 2>/dev/null
|
||||
eww update cavajson=''
|
||||
else
|
||||
eww update anim_open_dashfs=true
|
||||
eww open dashfs
|
||||
eww update rev_dashfs=true
|
||||
fi
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/bash
|
||||
state=$(eww get music_open)
|
||||
|
||||
if [[ "$state" == "true" || "$1" == "--close" ]]; then
|
||||
eww update anim_open_music=false
|
||||
eww update music_open=false
|
||||
sleep 0.2
|
||||
eww close music 2>/dev/null
|
||||
eww update cavajson=''
|
||||
else
|
||||
eww update anim_open_music=true
|
||||
eww open music
|
||||
eww update music_open=true
|
||||
fi
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/bash
|
||||
currentshader=$(hyprctl getoption decoration:screen_shader -j | gojq -r '.str')
|
||||
|
||||
if [[ "$currentshader" != *"extradark.frag" ]]; then
|
||||
hyprctl keyword decoration:screen_shader '~/.config/hypr/shaders/extradark.frag'
|
||||
else
|
||||
hyprctl keyword decoration:screen_shader ''
|
||||
hyprctl reload
|
||||
fi
|
||||
|
||||
scripts/hyprsettings tickle
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/bash
|
||||
cd ~/.config/eww || exit
|
||||
|
||||
reserves=$(hyprctl monitors -j | gojq -r -c '.[0]["reserved"]')
|
||||
if [[ "$1" == "--keypress" && "$reserves" == "[0,0,0,50]" ]]; then
|
||||
scripts/toggle-winnotif.sh
|
||||
exit
|
||||
fi
|
||||
|
||||
state=$(eww get rev_ontf)
|
||||
|
||||
if [[ "$state" == "true" || "$1" == "--close" ]]; then
|
||||
eww update anim_open_ontf=false
|
||||
eww update rev_ontf=false
|
||||
# eww update force_sys_rev=false
|
||||
sleep 0.15
|
||||
eww close onotify 2>/dev/null
|
||||
else
|
||||
eww update anim_open_ontf=true
|
||||
eww open onotify
|
||||
eww update rev_ontf=true &
|
||||
# eww update force_sys_rev=true &
|
||||
fi
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/bash
|
||||
cd ~/.config/eww
|
||||
reserves=$(hyprctl monitors -j | gojq -r -c '.[0]["reserved"]')
|
||||
state=$(eww get osd_vol)
|
||||
|
||||
closewinvol() {
|
||||
eww update osd_vol=false
|
||||
sleep 0.2
|
||||
eww close winosd_vol 2>/dev/null
|
||||
}
|
||||
closewinosd() {
|
||||
eww update osd_bright=false
|
||||
sleep 0.2
|
||||
eww close winosd_bright 2>/dev/null
|
||||
}
|
||||
openwinosd() {
|
||||
if [ "$state" = "true" ]; then
|
||||
closewinvol
|
||||
fi
|
||||
eww open winosd_bright
|
||||
eww update osd_bright=true
|
||||
}
|
||||
closeosd() {
|
||||
eww update osd_bright=false
|
||||
sleep 0.2
|
||||
eww close osd 2>/dev/null
|
||||
}
|
||||
openosd() {
|
||||
eww open osd
|
||||
eww update osd_bright=true
|
||||
}
|
||||
|
||||
if [ "$reserves" = "[0,0,0,50]" ]; then # windoes mode active
|
||||
eww close osd 2>/dev/null &
|
||||
if [[ "$1" == "--open" ]]; then
|
||||
openwinosd
|
||||
else
|
||||
closewinosd
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
eww close winosd_vol 2>/dev/null &
|
||||
eww close winosd_bright 2>/dev/null &
|
||||
if [[ "$1" == "--open" ]]; then
|
||||
openosd
|
||||
elif [[ "$1" == "--close" ]]; then
|
||||
closeosd
|
||||
else
|
||||
closeosd
|
||||
fi
|
||||
Executable
+51
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/bash
|
||||
cd ~/.config/eww || exit
|
||||
reserves=$(hyprctl monitors -j | gojq -r -c '.[0]["reserved"]')
|
||||
state=$(eww get osd_bright)
|
||||
|
||||
closewinbright() {
|
||||
eww update osd_bright=false
|
||||
sleep 0.2
|
||||
eww close winosd_bright 2>/dev/null
|
||||
}
|
||||
closewinosd() {
|
||||
eww update osd_vol=false
|
||||
sleep 0.2
|
||||
eww close winosd_vol 2>/dev/null
|
||||
}
|
||||
openwinosd() {
|
||||
if [ "$state" = "true" ]; then
|
||||
closewinbright
|
||||
fi
|
||||
eww open winosd_vol
|
||||
eww update osd_vol=true
|
||||
}
|
||||
closeosd() {
|
||||
eww update osd_vol=false
|
||||
sleep 0.2
|
||||
eww close osd 2>/dev/null
|
||||
}
|
||||
openosd() {
|
||||
eww open osd
|
||||
eww update osd_vol=true
|
||||
}
|
||||
|
||||
if [ "$reserves" = "[0,0,0,50]" ]; then # windoes mode active
|
||||
eww close osd &
|
||||
if [[ "$1" == "--open" ]]; then
|
||||
openwinosd
|
||||
else
|
||||
closewinosd
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
eww close winosd_vol 2>/dev/null &
|
||||
eww close winosd_bright 2>/dev/null &
|
||||
if [[ "$1" == "--open" ]]; then
|
||||
openosd
|
||||
elif [[ "$1" == "--close" ]]; then
|
||||
closeosd
|
||||
else
|
||||
closeosd
|
||||
fi
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/bash
|
||||
cd ~/.config/eww || exit
|
||||
|
||||
reserves=$(hyprctl monitors -j | gojq -r -c '.[0]["reserved"]')
|
||||
if [[ "$1" == "--keypress" && "$reserves" == "[0,0,0,50]" ]]; then
|
||||
scripts/toggle-winnews.sh
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
state=$(eww get rev_ostg)
|
||||
|
||||
if [[ "$state" == "true" || "$1" == "--close" ]]; then
|
||||
eww update anim_open_ostg=false
|
||||
eww update rev_ostg=false
|
||||
sleep 0.15
|
||||
eww close osettings 2>/dev/null
|
||||
eww update oquery=''
|
||||
else # state = false
|
||||
eww update anim_open_ostg=true
|
||||
eww update oquery='' &
|
||||
eww open osettings
|
||||
eww update rev_ostg=true &
|
||||
fi
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/bash
|
||||
cd ~/.config/eww || exit
|
||||
mkdir -p ~/.config/eww/scripts/cache/
|
||||
|
||||
reserves=$(hyprctl monitors -j | gojq -r -c '.[0]["reserved"]')
|
||||
if [[ "$reserves" == "[0,0,0,50]" ]]; then
|
||||
if [[ "$1" == "--keypress" ]]; then
|
||||
scripts/toggle-winstart.sh
|
||||
exit
|
||||
elif [[ "$1" == "--overview" && "$reserves" == "[0,0,0,50]" ]]; then
|
||||
scripts/toggle-wintaskview.sh
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
|
||||
state=$(eww get open_overview)
|
||||
|
||||
if [[ "$state" == "true" || "$1" == "--close" ]]; then
|
||||
eww close overview 2>/dev/null &
|
||||
eww update overview_query='' &
|
||||
eww update open_overview=false &
|
||||
else
|
||||
scripts/allapps > scripts/cache/entries.txt &
|
||||
scripts/allappnames > scripts/cache/entrynames.txt &
|
||||
eww update overview_query='' &
|
||||
eww update overview_hover_name='{"class":"LMB: Focus | MMB: Close | RMB: Select/Move","title":"Activities Overview","workspace":{"id":5,"name":"5"},"icon": "/usr/share/icons/breeze-dark/actions/16/window.svg"}' &
|
||||
eww open overview
|
||||
eww update open_overview=true
|
||||
fi
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/bash
|
||||
state=$(eww get rev_supercontext)
|
||||
|
||||
if [[ "$state" == "true" || "$1" == "--close" ]]; then
|
||||
eww update anim_open_supercontext=false
|
||||
eww update rev_supercontext=false
|
||||
sleep 0.1
|
||||
eww close supercontext 2>/dev/null
|
||||
else
|
||||
eww update supercontext_pos_x="$(hyprctl cursorpos -j | gojq '.x')"
|
||||
eww update supercontext_pos_y="$(hyprctl cursorpos -j | gojq '.y')" &
|
||||
eww update anim_open_supercontext=true &
|
||||
eww open supercontext
|
||||
eww update rev_supercontext=true
|
||||
eww update ws_to_swap=0
|
||||
fi
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/bash
|
||||
state=$(eww get rev_themer)
|
||||
|
||||
if [[ "$state" == "true" || "$1" == "--close" ]]; then
|
||||
eww update anim_open_themer=false
|
||||
eww update rev_themer=false
|
||||
sleep 0.25
|
||||
eww close themer 2>/dev/null
|
||||
else
|
||||
eww update anim_open_themer=true
|
||||
eww open themer
|
||||
eww update rev_themer=true
|
||||
fi
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/bash
|
||||
state=$(eww get rev_winactions)
|
||||
|
||||
if [[ "$state" == "true" || "$1" == "--close" ]]; then
|
||||
if [[ "$2" == "settings" ]]; then
|
||||
gnome-control-center &
|
||||
fi
|
||||
if [[ "$2" == "power" ]]; then
|
||||
gnome-control-center power &
|
||||
fi
|
||||
eww update anim_open_winactions=false
|
||||
eww update rev_winactions=false
|
||||
sleep 0.1
|
||||
eww close winactions 2>/dev/null
|
||||
else
|
||||
eww update anim_open_winactions=true
|
||||
eww open winactions
|
||||
eww update rev_winactions=true
|
||||
fi
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/bash
|
||||
state=$(eww get rev_wingamebar)
|
||||
|
||||
if [[ "$state" == "true" || "$1" == "--close" ]]; then
|
||||
eww close wingamebar 2>/dev/null
|
||||
eww update anim_open_wingamebar=false
|
||||
eww update rev_wingamebar=false
|
||||
else
|
||||
eww update anim_open_wingamebar=true
|
||||
eww open wingamebar
|
||||
eww update rev_wingamebar=true
|
||||
fi
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/bash
|
||||
state=$(eww get rev_winlang)
|
||||
|
||||
if [[ "$state" == "true" || "$1" == "--close" ]]; then
|
||||
eww update anim_open_winlang=false
|
||||
eww update rev_winlang=false
|
||||
sleep 0.1
|
||||
eww close winlang 2>/dev/null
|
||||
else
|
||||
eww update anim_open_winlang=true
|
||||
eww open winlang
|
||||
eww update rev_winlang=true
|
||||
fi
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/bash
|
||||
reserves=$(hyprctl monitors -j | gojq -r -c '.[0]["reserved"]')
|
||||
|
||||
if [[ "$reserves" == "[0,61,0,0]" ]]; then
|
||||
eww close bottomline 2>/dev/null
|
||||
eww open winbar
|
||||
eww close bar 2>/dev/null
|
||||
hyprctl keyword monitor eDP-1,addreserved,0,50,0,0
|
||||
|
||||
hyprctl keyword decoration:rounding 8
|
||||
hyprctl keyword general:border_size 1
|
||||
hyprctl keyword decoration:drop_shadow true
|
||||
|
||||
hyprctl keyword general:col.active_border 'rgba(494949dd)'
|
||||
hyprctl keyword general:col.inactive_border 'rgba(494949aa)'
|
||||
else
|
||||
eww close winbar 2>/dev/null
|
||||
eww open bar
|
||||
eww open bottomline
|
||||
hyprctl keyword monitor eDP-1,addreserved,61,0,0,0
|
||||
|
||||
hyprctl reload
|
||||
fi
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/bash
|
||||
state=$(eww get rev_winnews)
|
||||
|
||||
if [[ "$state" == "true" || "$1" == "--close" ]]; then
|
||||
eww update anim_open_winnews=false
|
||||
eww update rev_winnews=false
|
||||
sleep 0.15
|
||||
eww close winnews 2>/dev/null
|
||||
eww update oquery=''
|
||||
else
|
||||
eww update anim_open_winnews=true
|
||||
eww update oquery='' &
|
||||
eww open winnews
|
||||
eww update rev_winnews=true
|
||||
fi
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/bash
|
||||
state=$(eww get rev_winnotif)
|
||||
|
||||
if [[ "$state" == "true" || "$1" == "--close" ]]; then
|
||||
eww update anim_open_winnotif=false
|
||||
eww update rev_winnotif=false
|
||||
sleep 0.2
|
||||
eww close winnotif 2>/dev/null
|
||||
else
|
||||
eww update anim_open_winnotif=true
|
||||
eww open winnotif
|
||||
eww update rev_winnotif=true
|
||||
fi
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/bash
|
||||
state=$(eww get rev_winpowermenu)
|
||||
|
||||
if [[ "$state" == "true" || "$1" == "--close" ]]; then
|
||||
eww update anim_open_winpowermenu=false
|
||||
eww update rev_winpowermenu=false
|
||||
eww update winsearch='' &
|
||||
sleep 0.15
|
||||
eww close winpowermenu 2>/dev/null
|
||||
else
|
||||
eww update anim_open_winpowermenu=true
|
||||
eww open winpowermenu
|
||||
eww update rev_winpowermenu=true
|
||||
fi
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/bash
|
||||
cd ~/.config/eww || exit
|
||||
state=$(eww get rev_winstart)
|
||||
|
||||
if [[ "$state" == "true" || "$1" == "--close" ]]; then
|
||||
scripts/toggle-winpowermenu.sh --close &
|
||||
eww update anim_open_winstart=false
|
||||
eww update rev_winstart=false
|
||||
sleep 0.1
|
||||
eww close winstart 2>/dev/null
|
||||
eww update winsearch=''
|
||||
eww update winsearch_prefix=''
|
||||
eww update winstart_allapps=false
|
||||
eww update allapps=''
|
||||
else
|
||||
scripts/allapps > scripts/cache/entries.txt &
|
||||
scripts/allappnames > scripts/cache/entrynames.txt &
|
||||
eww update anim_open_winstart=true
|
||||
eww open winstart
|
||||
eww update rev_winstart=true
|
||||
eww update allapps_get="$(scripts/allapps --mode 2)" &
|
||||
fi
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/bash
|
||||
cd ~/.config/eww || exit
|
||||
|
||||
state=$(eww get rev_wintaskview)
|
||||
|
||||
if [[ "$state" == "true" || "$1" == "--close" ]]; then
|
||||
eww update anim_open_wintaskview=false
|
||||
eww update rev_wintaskview=false
|
||||
sleep 0.1
|
||||
eww close wintaskview 2>/dev/null
|
||||
else
|
||||
eww update anim_open_wintaskview=true
|
||||
eww open wintaskview
|
||||
eww update rev_wintaskview=true
|
||||
fi
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
if [ "$1" == "light" ]; then
|
||||
echo -n '-l' > 'scripts/workdir/__mode_light_dark.txt'
|
||||
cp css/savedcolors/_iconcolor_default.txt css/_iconcolor_default.txt
|
||||
else
|
||||
echo -n '' > 'scripts/workdir/__mode_light_dark.txt'
|
||||
cp css/savedcolors/_iconcolor_default.txt css/_iconcolor_default.txt
|
||||
fi
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
if [[ "$(pidof waybar)" == "" ]]; then
|
||||
eww update tray_is_open=false
|
||||
else
|
||||
eww update tray_is_open=true
|
||||
fi
|
||||
Executable
+133
@@ -0,0 +1,133 @@
|
||||
#!/usr/bin/env bash
|
||||
cd ~/.config/eww
|
||||
|
||||
volicons=("" "" "")
|
||||
XDG_CACHE_HOME="$HOME/.cache"
|
||||
date="$XDG_CACHE_HOME/eww/osd_vol.date"
|
||||
lock=0
|
||||
|
||||
showhide() {
|
||||
# get dates
|
||||
rundate=$(cat "$date")
|
||||
currentdate=$(date +%s)
|
||||
|
||||
# handle showing
|
||||
if [ "$rundate" = "$currentdate" ] && [ "$lock" -eq 0 ]; then
|
||||
scripts/toggle-osd-vol.sh --open
|
||||
lock=1
|
||||
elif [ $((currentdate - rundate)) -ge 2 ] && [ "$lock" -eq 1 ]; then
|
||||
scripts/toggle-osd-vol.sh --close > /dev/null
|
||||
lock=0
|
||||
fi
|
||||
}
|
||||
|
||||
osd() {
|
||||
if [ ! -f "$date" ]; then
|
||||
mkdir -p "$XDG_CACHE_HOME/eww"
|
||||
fi
|
||||
date +%s > "$date"
|
||||
showhide
|
||||
}
|
||||
|
||||
osd_handler() {
|
||||
lock=0
|
||||
rundate=0
|
||||
if [ ! -f "$date" ]; then
|
||||
mkdir -p "$XDG_CACHE_HOME/eww"
|
||||
echo 0 > "$date"
|
||||
fi
|
||||
|
||||
while true; do
|
||||
showhide
|
||||
sleep 0.1
|
||||
done
|
||||
}
|
||||
|
||||
vol() {
|
||||
wpctl get-volume @DEFAULT_AUDIO_$1@ | awk '{print int($2*100)}'
|
||||
}
|
||||
ismuted() {
|
||||
wpctl get-volume @DEFAULT_AUDIO_"$1"@ | rg -i muted
|
||||
echo $?
|
||||
}
|
||||
setvol() {
|
||||
wpctl set-volume @DEFAULT_AUDIO_"$1"@ "$(awk -v n="$2" 'BEGIN{print (n / 100)}')"
|
||||
}
|
||||
setmute() {
|
||||
wpctl set-mute @DEFAULT_AUDIO_"$1"@ toggle
|
||||
}
|
||||
|
||||
if [ "$1" = "--once" ]; then
|
||||
lvl=$(awk -v n="$(vol "SINK")" 'BEGIN{print int(n/34)}')
|
||||
ismuted=$(ismuted "SINK")
|
||||
|
||||
if [ "$ismuted" = 1 ]; then
|
||||
icon="${volicons[$lvl]}"
|
||||
else
|
||||
icon=""
|
||||
fi
|
||||
audio=1
|
||||
if [ "$(wpctl status | grep 'MUTED')" == "" ]; then
|
||||
audio=1
|
||||
else
|
||||
audio=0
|
||||
fi
|
||||
|
||||
echo '{"icon":"'"$icon"'","audio":"'"$audio"'","percent":"'"$(vol "SINK")"'","microphone":"'"$(vol "SOURCE")"'"}'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "mute" ]; then
|
||||
if [ "$2" != "SOURCE" ] && [ "$2" != "SINK" ]; then
|
||||
echo "Can only mute SINK or SOURCE"; exit 1
|
||||
fi
|
||||
setmute "$2"
|
||||
elif [ "$1" = "setvol" ]; then
|
||||
if [ "$2" != "SOURCE" ] && [ "$2" != "SINK" ]; then
|
||||
echo "Can only set volume for SINK or SOURCE"; exit 1
|
||||
elif [ "$3" -lt 1 ] || [ "$3" -gt 100 ]; then
|
||||
echo "Volume must be between 1 and 100"; exit 1
|
||||
fi
|
||||
setvol "$2" "$3"
|
||||
elif [ "$1" = "osd" ]; then
|
||||
osd
|
||||
else
|
||||
# initial values
|
||||
lvl=$(awk -v n="$(vol "SINK")" 'BEGIN{print int(n/34)}')
|
||||
ismuted=$(ismuted "SINK")
|
||||
|
||||
if [ "$ismuted" = 1 ]; then
|
||||
icon="${volicons[$lvl]}"
|
||||
else
|
||||
icon=""
|
||||
fi
|
||||
audio=1
|
||||
if [ "$(wpctl status | grep 'MUTED')" == "" ]; then
|
||||
audio=1
|
||||
else
|
||||
audio=0
|
||||
fi
|
||||
|
||||
echo '{"icon":"'"$icon"'","audio":"'"$audio"'","percent":"'"$(vol "SINK")"'","microphone":"'"$(vol "SOURCE")"'"}'
|
||||
|
||||
osd_handler &
|
||||
# event loop
|
||||
pactl subscribe | rg --line-buffered "on sink" | while read -r _; do
|
||||
lvl=$(awk -v n="$(vol "SINK")" 'BEGIN{print int(n/34)}')
|
||||
ismuted=$(ismuted "SINK")
|
||||
|
||||
if [ "$ismuted" = 1 ]; then
|
||||
icon="${volicons[$lvl]}"
|
||||
else
|
||||
icon=""
|
||||
fi
|
||||
audio=1
|
||||
if [ "$(wpctl status | grep 'MUTED')" == "" ]; then
|
||||
audio=1
|
||||
else
|
||||
audio=0
|
||||
fi
|
||||
|
||||
echo '{"icon":"'"$icon"'","audio":"'"$audio"'","percent":"'"$(vol "SINK")"'","microphone":"'"$(vol "SOURCE")"'"}'
|
||||
done
|
||||
fi
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/python3
|
||||
# Import the requests module
|
||||
import requests
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Define the URL to send the GET request
|
||||
url = "https://api.waifu.pics/sfw/waifu"
|
||||
if len(sys.argv) > 1 and sys.argv[1] == '--segs':
|
||||
url = "https://api.waifu.pics/nsfw/"
|
||||
if len(sys.argv) > 2:
|
||||
url += sys.argv[2]
|
||||
else:
|
||||
url += "waifu"
|
||||
else:
|
||||
url = "https://api.waifu.pics/sfw/"
|
||||
if len(sys.argv) > 1:
|
||||
url += sys.argv[1]
|
||||
else:
|
||||
url += "waifu"
|
||||
|
||||
# Send the GET request and store the response object
|
||||
response = requests.get(url)
|
||||
|
||||
# Check if the request was successful
|
||||
if response.status_code == 200:
|
||||
# Print the received data as JSON
|
||||
results = response.json()
|
||||
link=results['url']
|
||||
os.system('wget -O "{0}" "{1}" -q –read-timeout=0.1'.format('eww_covers/waifu_tmp', link))
|
||||
os.system('mv ./eww_covers/waifu_tmp ./eww_covers/waifu')
|
||||
print('eww_covers/waifu')
|
||||
else:
|
||||
# Print an error message
|
||||
print("Something went wrong. Status code:", response.status_code)
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
geticonlist() {
|
||||
classes=$(hyprctl clients | grep -e 'class: ' | sed 's/class: Code/class: code/' | sed 's/\tclass: //')
|
||||
addresses=$(hyprctl clients | grep -e ' -> ')
|
||||
# echo "$classes"
|
||||
IFS=$'\n'
|
||||
classarr=($(echo "$classes"))
|
||||
|
||||
printf '['
|
||||
for i in "${!classarr[@]}"; do
|
||||
if [ $i -ne 0 ]; then
|
||||
printf ', '
|
||||
fi
|
||||
printf "$i"
|
||||
done
|
||||
echo ']'
|
||||
}
|
||||
|
||||
geticonlist
|
||||
|
||||
if [ "$1" == "--once" ]; then
|
||||
exit 0
|
||||
else
|
||||
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | rg --line-buffered "window>>" | while read -r line; do
|
||||
geticonlist
|
||||
done
|
||||
fi
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
multi
|
||||
Executable
+153
@@ -0,0 +1,153 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# define colors
|
||||
colors=("#FFFFFF" "#fab387" "#a6e3a1" "#89b4fa") # Active Workspaces
|
||||
dimmed=("rgba(174,172,182,0.7)" "#f9e2af" "#94e2d5" "#b4befe") # Inactive workspaces
|
||||
empty='rgba(146,145,145,0.5)' # Empty workspaces
|
||||
|
||||
# get initial focused workspace
|
||||
focusedws=$(hyprctl -j monitors | gojq -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
|
||||
|
||||
# set color for each workspace
|
||||
status() {
|
||||
if [ "${o[$1]}" -eq 1 ]; then
|
||||
mon=${monitormap[${workspaces[$1]}]}
|
||||
echo -n "${dimmed[$mon]}"
|
||||
else
|
||||
echo -n "$empty"
|
||||
fi
|
||||
}
|
||||
|
||||
status_activity() {
|
||||
if [ "${o[$1]}" -eq 1 ]; then
|
||||
mon=${monitormap[${workspaces[$1]}]}
|
||||
|
||||
if [ $focusedws -eq "$1" ]; then
|
||||
echo -n "active"
|
||||
else
|
||||
echo -n "inactive"
|
||||
fi
|
||||
else
|
||||
echo -n "empty"
|
||||
fi
|
||||
}
|
||||
|
||||
# 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 | gojq -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 | gojq -r '.[]|"\(.name) \(.id) "')
|
||||
}
|
||||
|
||||
# generate the json for eww
|
||||
generate() {
|
||||
echo -n '['
|
||||
|
||||
for i in {1..10}; do
|
||||
echo -n ''$([ $i -eq 1 ] || echo ,)'{"num":"'$i'","clr":"'$(status "$i")'"}'
|
||||
# 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 | gojq -r '.[]|"\(.id) \(.monitor)"')
|
||||
|
||||
# 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 | gojq -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 | gojq -r '.[]|"\(.id) \(.monitor)"')
|
||||
# check occupied workspaces
|
||||
for num in "${!workspaces[@]}"; do
|
||||
o[$num]=1
|
||||
done
|
||||
generate
|
||||
;;
|
||||
"monitor"*)
|
||||
monitor_event
|
||||
generate
|
||||
;;
|
||||
esac
|
||||
# echo $line
|
||||
# generate
|
||||
done
|
||||
|
||||
# main loop
|
||||
# socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | rg --line-buffered "workspace|mon(itor)?" | while read -r line; do
|
||||
# case ${line%>>*} in
|
||||
# "workspace")
|
||||
# focusedws=${line#*>>}
|
||||
# generate
|
||||
# ;;
|
||||
# "focusedmon")
|
||||
# focusedws=${line#*,}
|
||||
# generate
|
||||
# ;;
|
||||
# "createworkspace")
|
||||
# workspace_event "${line#*>>}" 1
|
||||
# focusedws=${line#*>>}
|
||||
# # generate
|
||||
# ;;
|
||||
# "destroyworkspace")
|
||||
# workspace_event "${line#*>>}" 0
|
||||
# generate
|
||||
# ;;
|
||||
# "monitor"*)
|
||||
# monitor_event
|
||||
# generate
|
||||
# ;;
|
||||
# esac
|
||||
# done
|
||||
Reference in New Issue
Block a user