diff --git a/bin/install_the_dotfiles.sh b/.config/install_the_dotfiles.sh similarity index 77% rename from bin/install_the_dotfiles.sh rename to .config/install_the_dotfiles.sh index 00f1fec..2f85cf5 100644 --- a/bin/install_the_dotfiles.sh +++ b/.config/install_the_dotfiles.sh @@ -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 diff --git a/.config/sway/config b/.config/sway/config index d606f21..adb4d09 100644 --- a/.config/sway/config +++ b/.config/sway/config @@ -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 diff --git a/bin/command-list b/bin/command-list new file mode 100755 index 0000000..944640c --- /dev/null +++ b/bin/command-list @@ -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"]]) diff --git a/bin/files-list b/bin/files-list new file mode 100755 index 0000000..72be0d8 --- /dev/null +++ b/bin/files-list @@ -0,0 +1,3 @@ +#!/bin/bash +plocate "" | wmenu -l 20 -i | wl-copy + diff --git a/bin/hibernate b/bin/hibernate deleted file mode 100755 index 5cb45ca..0000000 --- a/bin/hibernate +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -sudo systemctl hibernate diff --git a/bin/reboot b/bin/reboot deleted file mode 100755 index b606780..0000000 --- a/bin/reboot +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -sudo systemctl reboot diff --git a/bin/search-apps b/bin/search-apps deleted file mode 100755 index af94b60..0000000 --- a/bin/search-apps +++ /dev/null @@ -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 diff --git a/bin/search-files b/bin/ufiles-list similarity index 98% rename from bin/search-files rename to bin/ufiles-list index e3dd4dc..24575b0 100755 --- a/bin/search-files +++ b/bin/ufiles-list @@ -1,4 +1,3 @@ #!/bin/bash sudo updatedb plocate "" | wmenu -l 20 -i | wl-copy -