search everything, move install script
This commit is contained in:
@@ -2,12 +2,15 @@
|
||||
# - [ ] Mount /krk-pc on startup
|
||||
# - [ ] Add server SSH keys and PC ssh keys
|
||||
# - [ ] Mount /proton on startup
|
||||
# - [x] Hibernate if not using PC for 10 minutes
|
||||
#
|
||||
# - [ ] everything relevant wmenu browser (programs and scripts without arguments, bookmarks, files)
|
||||
# - [ ] plocate + wmenu > xdg-open
|
||||
# - [ ] applications + bin folder
|
||||
# - [ ] Combine apps + bin + bookmarks
|
||||
# - [x] everything relevant wmenu browser (programs and scripts without arguments, bookmarks, files)
|
||||
# - [x] plocate + wmenu > xdg-open
|
||||
# - [x] applications + bin folder
|
||||
# - [x] bookmarks
|
||||
#
|
||||
# - [ ] fzf starship zoxide eza bat
|
||||
# - [x] fzf starship zoxide eza bat (only fzf seems descent)
|
||||
#
|
||||
# Solutions in search for problems:
|
||||
# - [ ] tmux automation
|
||||
@@ -16,21 +16,17 @@ set $right l
|
||||
# Your preferred terminal emulator
|
||||
set $term foot
|
||||
# Your preferred application launcher
|
||||
set $menu /home/kk/bin/search-apps -l 10 -i
|
||||
set $menu /home/kk/bin/command-list -l 20 -i
|
||||
set $fontsize 10
|
||||
|
||||
# UI font
|
||||
font pango:JetBrains Mono $fontsize
|
||||
|
||||
|
||||
|
||||
include /etc/sway/config-vars.d/*
|
||||
|
||||
default_border pixel 2
|
||||
default_floating_border pixel 1
|
||||
hide_edge_borders smart
|
||||
|
||||
|
||||
# default_border pixel 2
|
||||
# default_floating_border pixel 1
|
||||
# hide_edge_borders smart
|
||||
|
||||
### Output configuration
|
||||
#
|
||||
@@ -51,8 +47,8 @@ hide_edge_borders smart
|
||||
# Example configuration:
|
||||
#
|
||||
exec swayidle -w \
|
||||
timeout 300 'swaylock -f -c 000000' \
|
||||
timeout 600 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \
|
||||
timeout 300 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \
|
||||
timeout 600 'systemctl hibernate' \
|
||||
before-sleep 'swaylock -f -c 000000'
|
||||
#
|
||||
# This will lock your screen after 300 seconds of inactivity, then turn off
|
||||
|
||||
103
bin/command-list
Executable file
103
bin/command-list
Executable file
@@ -0,0 +1,103 @@
|
||||
#!/usr/bin/python3
|
||||
import os, subprocess, json
|
||||
|
||||
|
||||
def readfile(path):
|
||||
fd = open(path, "r")
|
||||
result = fd.read()
|
||||
fd.close()
|
||||
return result
|
||||
|
||||
vals = {}
|
||||
home = os.environ["HOME"]
|
||||
appsdir=["/usr/share/applications", f"{home}/.local/share/applications"]
|
||||
for appdir in appsdir:
|
||||
if not os.path.isdir(appdir):
|
||||
continue
|
||||
|
||||
for appfile in os.listdir(appdir):
|
||||
if not appfile.endswith(".desktop"):
|
||||
continue
|
||||
|
||||
path = appdir + "/" + appfile
|
||||
content = readfile(path)
|
||||
|
||||
_name = None
|
||||
_exec = None
|
||||
_type = None
|
||||
_nodisplay = ""
|
||||
_hidden = ""
|
||||
for line in content.splitlines(content):
|
||||
line = line.strip()
|
||||
|
||||
if line.startswith("Exec="):
|
||||
_exec = line[5:]
|
||||
elif line.startswith("Type="):
|
||||
_type = line[5:]
|
||||
elif line.startswith("Name="):
|
||||
_name = line[5:]
|
||||
elif line.startswith("NoDisplay="):
|
||||
_nodisplay = line[10:]
|
||||
elif line.startswith("Hidden="):
|
||||
_hidden = line[7:]
|
||||
|
||||
|
||||
if _name is None or _exec is None:
|
||||
continue
|
||||
if _type is None or _type != "Application":
|
||||
continue
|
||||
if _nodisplay == "true" or _hidden == "true":
|
||||
continue
|
||||
|
||||
vals[_name] = {"kind": "app", "exec": _exec, "path": path}
|
||||
|
||||
|
||||
bindir = f"{home}/bin"
|
||||
for file in os.listdir(bindir):
|
||||
path = f"{bindir}/{file}"
|
||||
if os.path.isdir(path):
|
||||
continue
|
||||
if file.startswith("."):
|
||||
continue
|
||||
vals[file] = {"kind": "bin", "path": path}
|
||||
|
||||
def walk_bookmarks(node, folder=""):
|
||||
if isinstance(node, dict):
|
||||
if node.get("type") == "url" and node.get("url"):
|
||||
name = node.get("name") or node["url"]
|
||||
label = f"{folder}/{name}" if folder else name
|
||||
vals[label] = {"kind": "url", "url": node["url"]}
|
||||
elif "children" in node:
|
||||
name = node.get("name", "")
|
||||
next_folder = f"{folder}/{name}" if folder and name else name or folder
|
||||
for child in node.get("children", []):
|
||||
walk_bookmarks(child, next_folder)
|
||||
|
||||
bookmarkfile = f"{home}/.config/chromium/Default/Bookmarks"
|
||||
if os.path.isfile(bookmarkfile):
|
||||
content = readfile(bookmarkfile)
|
||||
data = json.loads(content)
|
||||
|
||||
roots = data.get("roots", {})
|
||||
for root in roots.values():
|
||||
walk_bookmarks(root)
|
||||
|
||||
entries = []
|
||||
for it in vals.items():
|
||||
entries.append(it[0])
|
||||
entries_string = "\n".join(entries)
|
||||
result = subprocess.run(["wmenu", "-l", "20", "-i"], input=entries_string, text=True, stdout=subprocess.PIPE)
|
||||
|
||||
if result.returncode != 0:
|
||||
exit(result.returncode)
|
||||
|
||||
choice = result.stdout.strip()
|
||||
val = vals[choice]
|
||||
|
||||
|
||||
if val["kind"] == "bin":
|
||||
subprocess.run([val["path"]])
|
||||
elif val["kind"] == "app":
|
||||
subprocess.run(["gtk-launch", choice])
|
||||
elif val["kind"] == "url":
|
||||
subprocess.run(["xdg-open", val["url"]])
|
||||
3
bin/files-list
Executable file
3
bin/files-list
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
plocate "" | wmenu -l 20 -i | wl-copy
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/bash
|
||||
sudo systemctl hibernate
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/bash
|
||||
sudo systemctl reboot
|
||||
@@ -1,51 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Show regular .desktop applications plus executable files in ~/bin.
|
||||
# .desktop entries are launched with gtk-launch.
|
||||
# ~/bin entries are executed directly, so their shebang is respected.
|
||||
|
||||
APP_DIRS="/usr/share/applications $HOME/.local/share/applications"
|
||||
BIN_DIR="$HOME/bin"
|
||||
|
||||
entries=$(
|
||||
for dir in $APP_DIRS; do
|
||||
[ -d "$dir" ] || continue
|
||||
|
||||
find "$dir" -type f -name '*.desktop' 2>/dev/null | while IFS= read -r file; do
|
||||
name=$(awk -F= '/^Name=/ { print $2; exit }' "$file")
|
||||
type=$(awk -F= '/^Type=/ { print $2; exit }' "$file")
|
||||
nodisplay=$(awk -F= '/^NoDisplay=/ { print $2; exit }' "$file")
|
||||
hidden=$(awk -F= '/^Hidden=/ { print $2; exit }' "$file")
|
||||
|
||||
[ -n "$name" ] || continue
|
||||
[ -z "$type" ] || [ "$type" = "Application" ] || continue
|
||||
[ "$nodisplay" = "true" ] && continue
|
||||
[ "$hidden" = "true" ] && continue
|
||||
|
||||
id=$(basename "$file" .desktop)
|
||||
printf '%s [desktop]\tdesktop\t%s\n' "$name" "$id"
|
||||
done
|
||||
done
|
||||
|
||||
if [ -d "$BIN_DIR" ]; then
|
||||
find "$BIN_DIR" -maxdepth 1 -type f -perm /111 2>/dev/null | while IFS= read -r file; do
|
||||
name=$(basename "$file")
|
||||
printf '%s [bin]\tbin\t%s\n' "$name" "$file"
|
||||
done
|
||||
fi
|
||||
)
|
||||
|
||||
choice=$(printf '%s\n' "$entries" | sort -f | wmenu -l 20)
|
||||
[ -n "$choice" ] || exit 0
|
||||
|
||||
kind=$(printf '%s' "$choice" | cut -f2)
|
||||
target=$(printf '%s' "$choice" | cut -f3-)
|
||||
|
||||
case "$kind" in
|
||||
desktop)
|
||||
gtk-launch "$target" >/dev/null 2>&1 &
|
||||
;;
|
||||
bin)
|
||||
"$target" >/dev/null 2>&1 &
|
||||
;;
|
||||
esac
|
||||
@@ -1,4 +1,3 @@
|
||||
#!/bin/bash
|
||||
sudo updatedb
|
||||
plocate "" | wmenu -l 20 -i | wl-copy
|
||||
|
||||
Reference in New Issue
Block a user