From c2299c21d146a89cc18849c44066116fdf7c5ef9 Mon Sep 17 00:00:00 2001 From: bh Date: Sat, 7 Mar 2026 20:25:03 +0800 Subject: Added hypr and quickshell --- hypr/.config/hypr/.hyprland.conf.bak | 223 ++++++++++++++++ hypr/.config/hypr/hyprland.conf | 282 ++++++++++++++++++++ hypr/.config/hypr/hyprpaper.conf | 14 + hypr/.config/hypr/scripts/mute | 14 + hypr/.config/hypr/scripts/screenshot | 15 ++ quickshell/.config/quickshell/shell.qml | 448 ++++++++++++++++++++++++++++++++ 6 files changed, 996 insertions(+) create mode 100644 hypr/.config/hypr/.hyprland.conf.bak create mode 100644 hypr/.config/hypr/hyprland.conf create mode 100644 hypr/.config/hypr/hyprpaper.conf create mode 100755 hypr/.config/hypr/scripts/mute create mode 100755 hypr/.config/hypr/scripts/screenshot create mode 100644 quickshell/.config/quickshell/shell.qml diff --git a/hypr/.config/hypr/.hyprland.conf.bak b/hypr/.config/hypr/.hyprland.conf.bak new file mode 100644 index 0000000..4fcf08a --- /dev/null +++ b/hypr/.config/hypr/.hyprland.conf.bak @@ -0,0 +1,223 @@ +############################################ +# Keybindings +############################################ + +input { + kb_layout = us + kb_variant = dvps + kb_options = caps:backspace +} + + +############################################ +# Colours +############################################ + +$darkcyan = rgb(007575) +$lightcyan = rgb(1ebaba) +$lightercyan = rgb(19e0e0) +$red = rgb(e55235) + + +############################################ +# Workspaces (Hyprland calls them "desktops") +############################################ + +# Names: 一 二 三 四 五 六 七 八 九 十 󱉼 +# You don’t assign them globally; you move to them or bind to them. + +# Example binds (uncomment if you want): +# bind = SUPER, 1, workspace, name:一 +# bind = SUPER, 2, workspace, name:二 +# … +# bind = SUPER, 0, workspace, name:󱉼 + + +############################################ +# Window Appearance +############################################ + +general { + border_size = 1 + gaps_in = 6 + gaps_out = 6 +} + +decoration { + rounding = 0 + + active_border_color = $lightercyan + inactive_border_color = $darkcyan + urgent_border_color = $red + + # No split ratio or monocle mode — Hyprland tiling is automatic. +} + + +############################################ +# Startup Applications +############################################ + +exec-once = kitty +exec-once = kitty + +exec-once = polybar + +exec-once = feh --bg-fill /home/bh/Pictures/Wallpapers/TealNebula.jpg + +exec-once = dunst + + + +############################################ +# Floating Rules +############################################ + +windowrulev2 = float, class:^(floating)$ + + +############################################ +# MOVE FOCUS (bspc node -f X) +############################################ + +bind = SUPER, h, movefocus, l +bind = SUPER, j, movefocus, d +bind = SUPER, k, movefocus, u +bind = SUPER, l, movefocus, r + + +############################################ +# MOVE WINDOW (bspc node -s X) +############################################ + +bind = SUPER SHIFT, h, movewindow, l +bind = SUPER SHIFT, j, movewindow, d +bind = SUPER SHIFT, k, movewindow, u +bind = SUPER SHIFT, l, movewindow, r + + +############################################ +# PRESEL (Hyprland does not have preselection) +# → closest equivalent is splitratio and togglesplit +############################################ + +# directional preselect +bind = SUPER CTRL, h, splitratio, -0.1 +bind = SUPER CTRL, j, splitratio, +0.1 +bind = SUPER CTRL, k, splitratio, -0.1 +bind = SUPER CTRL, l, splitratio, +0.1 + +# ratio presets +bind = SUPER CTRL, n, splitratio, 0.75 +bind = SUPER CTRL, t, splitratio, 0.25 + + +############################################ +# SWITCH WORKSPACES +############################################ + +bind = SUPER, ampersand, workspace, name:一 +bind = SUPER, bracketleft, workspace, name:二 +bind = SUPER, braceleft, workspace, name:三 +bind = SUPER, braceright, workspace, name:四 +bind = SUPER, parenleft, workspace, name:五 +bind = SUPER, equal, workspace, name:六 +bind = SUPER, asterisk, workspace, name:七 +bind = SUPER, parenright, workspace, name:八 +bind = SUPER, plus, workspace, name:九 +bind = SUPER, bracketright, workspace, name:十 +bind = SUPER, exclam, workspace, name:󱉼 + + +############################################ +# MOVE WINDOW TO WORKSPACE +############################################ + +bind = SUPER SHIFT, ampersand, movetoworkspace, name:一 +bind = SUPER SHIFT, bracketleft, movetoworkspace, name:二 +bind = SUPER SHIFT, braceleft, movetoworkspace, name:三 +bind = SUPER SHIFT, braceright, movetoworkspace, name:四 +bind = SUPER SHIFT, parenleft, movetoworkspace, name:五 +bind = SUPER SHIFT, equal, movetoworkspace, name:六 +bind = SUPER SHIFT, asterisk, movetoworkspace, name:七 +bind = SUPER SHIFT, parenright, movetoworkspace, name:八 +bind = SUPER SHIFT, plus, movetoworkspace, name:九 +bind = SUPER SHIFT, bracketright, movetoworkspace, name:十 +bind = SUPER SHIFT, exclam, movetoworkspace, name:󱉼 + + +############################################ +# BSPWM FUNCTIONS → HYPRLAND EQUIVALENTS +############################################ + +# Toggle Monocle +bind = SUPER, m, togglefloating + +# Fullscreen (your custom script) +bind = SUPER, f, exec, ~/Scripts/fullscreen + +# Close window +bind = SUPER, c, killactive + +# Restart WM (Hyprland version) +bind = SUPER SHIFT, c, exec, hyprctl reload + +# Swap with last window +bind = SUPER CTRL, m, movetolast + + +############################################ +# OTHER FUNCTIONS +############################################ + +# Screen locker +bind = SUPER, slash, exec, ~/Scripts/blur-lock + + +############################################ +# APPLICATIONS +############################################ + +bind = SUPER, Return, exec, kitty +bind = SUPER ALT, Return, exec, kitty --class floating + +bind = SUPER, w, exec, zen-browser +bind = SUPER, d, exec, rofi -modi drun -show drun -config ~/.config/rofi/rofidmenu.rasi +bind = SUPER, v, exec, bash ~/Scripts/clipboard +bind = SUPER, e, exec, emacs +bind = SUPER, s, exec, ~/Scripts/screenshot +bind = SUPER SHIFT, s, exec, ~/Scripts/snip + + +############################################ +# AUDIO KEYS +############################################ + +# Volume up +bind = , XF86AudioRaiseVolume, exec, \ + pactl set-sink-volume @DEFAULT_SINK@ +5% && VOLUME=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -Po '\\d+%' | head -1) && dunstify " Volume: $VOLUME" -h int:value:"${VOLUME%\%}" -r 2593 -t 1000 + +# Volume down +bind = , XF86AudioLowerVolume, exec, \ + pactl set-sink-volume @DEFAULT_SINK@ -5% && VOLUME=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -Po '\\d+%' | head -1) && dunstify " Volume: $VOLUME" -h int:value:"${VOLUME%\%}" -r 2593 -t 1000 + +# Mute +bind = , XF86AudioMute, exec, ~/Scripts/mute + +############################################ +# Application Rules +############################################ + +# Window rules equivalent of bspc rule + +# kitty → workspace 一 +windowrulev2 = workspace name:一, class:^(kitty)$ + +# firefox → workspace 二 +windowrulev2 = workspace name:二, class:^(firefox)$ + +# zen → workspace 二 +windowrulev2 = workspace name:二, class:^(zen|zen-browser)$ + +# Emacs → workspace 三 +windowrulev2 = workspace name:三, class:^(Emacs)$ diff --git a/hypr/.config/hypr/hyprland.conf b/hypr/.config/hypr/hyprland.conf new file mode 100644 index 0000000..c03748b --- /dev/null +++ b/hypr/.config/hypr/hyprland.conf @@ -0,0 +1,282 @@ +# ██╗░░██╗██╗░░░██╗██████╗░██████╗░██╗░░░░░░█████╗░███╗░░██╗██████╗░ +# ██║░░██║╚██╗░██╔╝██╔══██╗██╔══██╗██║░░░░░██╔══██╗████╗░██║██╔══██╗ +# ███████║░╚████╔╝░██████╔╝██████╔╝██║░░░░░███████║██╔██╗██║██║░░██║ +# ██╔══██║░░╚██╔╝░░██╔═══╝░██╔══██╗██║░░░░░██╔══██║██║╚████║██║░░██║ +# ██║░░██║░░░██║░░░██║░░░░░██║░░██║███████╗██║░░██║██║░╚███║██████╔╝ +# ╚═╝░░╚═╝░░░╚═╝░░░╚═╝░░░░░╚═╝░░╚═╝╚══════╝╚═╝░░╚═╝╚═╝░░╚══╝╚═════╝░ +# +# █▄▄ █░█ ▀ █▀ █▀▀ █▀█ █▄░█ █▀▀ █ █▀▀ █▀▀ █▀█ █▀█ █░█ █▄█ █▀█ █▀█ █░░ ▄▀█ █▄░█ █▀▄ +# █▄█ █▀█ ░ ▄█ █▄▄ █▄█ █░▀█ █▀░ █ █▄█ █▀░ █▄█ █▀▄ █▀█ ░█░ █▀▀ █▀▄ █▄▄ █▀█ █░▀█ █▄▀ +# +# Translated from bspwm + sxhkd configuration + + +################# +### MONITORS ### +################# + +monitor=,preferred,auto,auto + + +################### +### MY PROGRAMS ### +################### + +$terminal = kitty +$fileManager = dolphin +$menu = rofi -modi drun -show drun -config ~/.config/rofi/rofidmenu.rasi +$browser = firefox + + +################# +### AUTOSTART ### +################# + +exec-once = kitty +exec-once = kitty +# exec-once = waybar +exec-once = hyprpaper +exec-once = dunst +exec-once = wl-paste --watch cliphist store + + +############################# +### ENVIRONMENT VARIABLES ### +############################# + +env = XCURSOR_SIZE,24 +env = HYPRCURSOR_SIZE,24 + + +##################### +### LOOK AND FEEL ### +##################### + +# Colors (from bspwm config) +$darkcyan = rgb(007575) +$lightcyan = rgb(1ebaba) +$lightercyan = rgb(19e0e0) +$red = rgb(e55235) + +general { + gaps_in = 3 + gaps_out = 3 + + border_size = 1 + + col.active_border = $lightercyan + col.inactive_border = $darkcyan + + resize_on_border = false + allow_tearing = false + layout = dwindle +} + +dwindle { + preserve_split = true + force_split = 2 + pseudotile = true + preserve_split = true +} + +decoration { + rounding = 0 + + active_opacity = 1.0 + inactive_opacity = 1.0 + + shadow { + enabled = true + range = 4 + render_power = 3 + color = rgba(1a1a1aee) + } + + blur { + enabled = true + size = 0 + passes = 5 + + ignore_opacity = false + new_optimizations = true + xray = false + vibrancy = 0.1696 + } +} + +animations { + enabled = true + + bezier = myBezier, 0.05, 0.9, 0.1, 1.05 + + animation = windows, 1, 7, myBezier + animation = windowsOut, 1, 7, default, popin 80% + animation = border, 1, 10, default + animation = borderangle, 1, 8, default + animation = fade, 1, 7, default + animation = workspaces, 1, 6, default +} + +master { + new_status = master +} + +misc { + force_default_wallpaper = 0 + disable_hyprland_logo = true +} + + +############# +### INPUT ### +############# + +input { + # kb_layout = us,us,cn,jp,ru + # kb_variant = dvorak,,wubi,,, + # kb_model = + # kb_options = grp:ctrl_shift_toggle + # kb_rules = + kb_layout = us + kb_variant = dvps + kb_options = caps:backspace + + follow_mouse = 0 + + sensitivity = 0 + + touchpad { + natural_scroll = false + } +} + +gestures { + # workspace_swipe option does not exist in current Hyprland +} + +device { + name = epic-mouse-v1 + sensitivity = -0.5 +} + + +#################### +### KEYBINDINGSS ### +#################### + +$mainMod = SUPER + +# Applications +bind = $mainMod, Return, exec, $terminal +bind = $mainMod ALT, Return, exec, kitty --class floating +bind = $mainMod, W, exec, $browser +bind = $mainMod, D, exec, $menu +bind = $mainMod, E, exec, emacs + +# Scripts +bind = $mainMod, V, exec, ~/.config/rofi/scripts/clipboard-wayland.sh +bind = $mainMod, S, exec, ~/.config/hypr/scripts/screenshot +bind = $mainMod SHIFT, S, exec, ~/.config/hypr/screenshot snip +bind = $mainMod, slash, exec, ~/Scripts/blur-lock + +# Window Management +bind = $mainMod SHIFT, C, killactive, +bind = $mainMod SHIFT, R, exec, hyprctl reload +bind = $mainMod, F, fullscreen, 0 +bind = $mainMod, M, fullscreen, 1 + +# Move Focus (Vim-style) +bind = $mainMod, H, movefocus, l +bind = $mainMod, L, movefocus, r +bind = $mainMod, K, movefocus, u +bind = $mainMod, J, movefocus, d + +# Move Window (Vim-style) +bind = $mainMod SHIFT, H, movewindow, l +bind = $mainMod SHIFT, L, movewindow, r +bind = $mainMod SHIFT, K, movewindow, u +bind = $mainMod SHIFT, J, movewindow, d + +# Preselection / Split Direction (Ctrl+Super+hjkl) +bind = $mainMod CTRL, H, layoutmsg, preselect l +bind = $mainMod CTRL, L, layoutmsg, preselect r +bind = $mainMod CTRL, K, layoutmsg, preselect u +bind = $mainMod CTRL, J, layoutmsg, preselect d + +# Swap with last window +bind = $mainMod CTRL, M, swapnext, prev + +# Switch Workspaces (Dvorak layout keys) +# Note: These keybinds match Dvorak layout from sxhkd config +bind = $mainMod, ampersand, workspace, 1 # 一 +bind = $mainMod, bracketleft, workspace, 2 # 二 +bind = $mainMod, braceleft, workspace, 3 # 三 +bind = $mainMod, braceright, workspace, 4 # 四 +bind = $mainMod, parenleft, workspace, 5 # 五 +bind = $mainMod, equal, workspace, 6 # 六 +bind = $mainMod, asterisk, workspace, 7 # 七 +bind = $mainMod, parenright, workspace, 8 # 八 +bind = $mainMod, plus, workspace, 9 # 九 +bind = $mainMod, bracketright, workspace, 10 # 十 +bind = $mainMod, exclam, workspace, 11 # 󱉼 + +# Move to Different Workspaces (Dvorak layout keys) +bind = $mainMod SHIFT, ampersand, movetoworkspace, 1 +bind = $mainMod SHIFT, bracketleft, movetoworkspace, 2 +bind = $mainMod SHIFT, braceleft, movetoworkspace, 3 +bind = $mainMod SHIFT, braceright, movetoworkspace, 4 +bind = $mainMod SHIFT, parenleft, movetoworkspace, 5 +bind = $mainMod SHIFT, equal, movetoworkspace, 6 +bind = $mainMod SHIFT, asterisk, movetoworkspace, 7 +bind = $mainMod SHIFT, parenright, movetoworkspace, 8 +bind = $mainMod SHIFT, plus, movetoworkspace, 9 +bind = $mainMod SHIFT, bracketright, movetoworkspace, 10 +bind = $mainMod SHIFT, exclam, movetoworkspace, 11 + +# Scroll through existing workspaces with mainMod + scroll +bind = $mainMod, mouse_down, workspace, e+1 +bind = $mainMod, mouse_up, workspace, e-1 + +# Move/resize windows with mainMod + LMB/RMB and dragging +bindm = $mainMod, mouse:272, movewindow +bindm = $mainMod, mouse:273, resizewindow + +# Media Keys +bindel = , XF86AudioRaiseVolume, exec, pactl set-sink-volume @DEFAULT_SINK@ +5% && VOLUME=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -Po '\d+%' | head -1) && dunstify " Volume: $VOLUME" -h int:value:"${VOLUME%\%}" -r 2593 -t 1000 +bindel = , XF86AudioLowerVolume, exec, pactl set-sink-volume @DEFAULT_SINK@ -5% && VOLUME=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -Po '\d+%' | head -1) && dunstify " Volume: $VOLUME" -h int:value:"${VOLUME%\%}" -r 2593 -t 1000 +bindl = , XF86AudioMute, exec, ~/.config/hypr/scripts/mute + + +################## +### LAYER RULES ### +################## + +layerrule = blur on, match:namespace rofi +layerrule = ignore_alpha 0.5, match:namespace rofi + + +############################## +### WINDOWS AND WORKSPACES ### +############################## + +# Send Firefox to workspace 2 +windowrule = match:class ^(firefox)$, workspace 2 + +# Send Emacs to workspace 3 +windowrule = match:class ^(Emacs)$, workspace 3 + +# Float windows with class "floating" +windowrule = match:class ^(floating)$, float on + +# Workspace Names (Chinese characters from bspwm) +exec-once = hyprctl dispatch renameworkspace "1 一" +exec-once = hyprctl dispatch renameworkspace "2 二" +exec-once = hyprctl dispatch renameworkspace "3 三" +exec-once = hyprctl dispatch renameworkspace "4 四" +exec-once = hyprctl dispatch renameworkspace "5 五" +exec-once = hyprctl dispatch renameworkspace "6 六" +exec-once = hyprctl dispatch renameworkspace "7 七" +exec-once = hyprctl dispatch renameworkspace "8 八" +exec-once = hyprctl dispatch renameworkspace "9 九" +exec-once = hyprctl dispatch renameworkspace "10 十" +exec-once = hyprctl dispatch renameworkspace "11 󱉼" diff --git a/hypr/.config/hypr/hyprpaper.conf b/hypr/.config/hypr/hyprpaper.conf new file mode 100644 index 0000000..f4bff53 --- /dev/null +++ b/hypr/.config/hypr/hyprpaper.conf @@ -0,0 +1,14 @@ +wallpaper { + monitor = eDP-1 + path = /home/bh/Pictures/Wallpapers/TealNebula.jpg + fit_mode = cover +} + +# optional fallback for any monitor without a specific target +wallpaper { + monitor = + path = /home/bh/Pictures/Wallpapers/TealNebula.jpg + fit_mode = cover +} + +splash = false diff --git a/hypr/.config/hypr/scripts/mute b/hypr/.config/hypr/scripts/mute new file mode 100755 index 0000000..7d17b92 --- /dev/null +++ b/hypr/.config/hypr/scripts/mute @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# Toggle mute +pactl set-sink-mute @DEFAULT_SINK@ toggle + +# Get mute status +MUTE=$(pactl get-sink-mute @DEFAULT_SINK@ | awk '{print $2}') + +if [ "$MUTE" = "yes" ]; then + dunstify " Volume: Muted" -r 2593 -t 1000 +else + VOLUME=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -Po "\d+%" | head -1) + dunstify " Volume: $VOLUME" -h int:value:${VOLUME%\%} -r 2593 -t 1000 +fi diff --git a/hypr/.config/hypr/scripts/screenshot b/hypr/.config/hypr/scripts/screenshot new file mode 100755 index 0000000..5ed5b7d --- /dev/null +++ b/hypr/.config/hypr/scripts/screenshot @@ -0,0 +1,15 @@ +#!/bin/bash + +mkdir -p ~/Pictures/Screenshots + +FILE=~/Pictures/Screenshots/$(date '+%Y-%m-%d_%H-%M-%S').png + +if [[ "$1" == "snip" ]]; then + grim -g "$(slurp)" "$FILE" || exit 1 +else + grim "$FILE" || exit 1 +fi + +wl-copy --type image/png < "$FILE" + +notify-send "Screenshot Taken" "Saved to $FILE" -i "$FILE" diff --git a/quickshell/.config/quickshell/shell.qml b/quickshell/.config/quickshell/shell.qml new file mode 100644 index 0000000..854af9e --- /dev/null +++ b/quickshell/.config/quickshell/shell.qml @@ -0,0 +1,448 @@ +import Quickshell +import Quickshell.Hyprland +import Quickshell.Io +import QtQuick +import QtQuick.Layouts + +PanelWindow { + id: root + anchors.top: true + anchors.left: true + anchors.right: true + implicitHeight: 25 + color: "transparent" + + property color bg1: "#003636" + property color bg2: "#004344" + property color fg: "#6ae8eb" + + // Re-evaluate when workspace list or focus changes + property var wsValues: Hyprland.workspaces.values + property int focusedId: Hyprland.focusedWorkspace?.id ?? -1 + + function wsState(id) { + if (focusedId === id) return "focused" + for (var i = 0; i < wsValues.length; i++) { + if (wsValues[i].id === id) return "occupied" + } + return "empty" + } + + // Workspaces - absolutely centered + RowLayout { + anchors.centerIn: parent + spacing: 12 + + Repeater { + model: ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "󱉼"] + + Text { + required property int index + required property string modelData + property int wsId: index + 1 + property string state: wsState(wsId) + + text: modelData + color: state === "focused" ? "#FFC500" : state === "occupied" ? "#8affff" : "#4d7f7f" + font.family: "Noto Sans CJK SC" + font.pixelSize: 13 + font.bold: state === "focused" + + MouseArea { + anchors.fill: parent + onClicked: Hyprland.dispatch("workspace " + wsId) + } + } + } + } + + // Left modules + RowLayout { + anchors.left: parent.left + anchors.top: parent.top + anchors.bottom: parent.bottom + spacing: -1 + + // Wlan module + Rectangle { + color: root.bg1 + Layout.fillHeight: true + implicitWidth: wlanRow.implicitWidth + 16 + + RowLayout { + id: wlanRow + anchors.centerIn: parent + spacing: 4 + + Text { + text: "" + id: wlanIcon + color: root.fg + font.family: "Symbols Nerd Font" + font.pixelSize: 12 + } + + Text { + text: "wlo1" + color: "#FFC500" + font.family: "Source Code Pro" + font.pixelSize: 14 + } + + Text { + id: wlanSsid + color: root.fg + font.family: "Source Code Pro" + font.pixelSize: 14 + font.bold: true + text: "..." + } + + Text { + id: wlanIp + color: root.fg + font.family: "Source Code Pro" + font.pixelSize: 14 + } + } + + Timer { + interval: 5000 + running: true + repeat: true + triggeredOnStart: true + onTriggered: wlanProc.running = true + } + + Process { + id: wlanProc + command: ["sh", "-c", "iwgetid -r 2>/dev/null; ip -4 -o addr show wlo1 2>/dev/null | cut -d' ' -f7 | cut -d/ -f1"] + stdout: StdioCollector { + onStreamFinished: { + var lines = this.text.trim().split("\n") + var ssid = lines[0] || "" + var ip = lines[1] || "" + if (ssid && ip) { + wlanIcon.text = "" + wlanSsid.text = ssid + wlanSsid.color = root.fg + wlanSsid.font.bold = true + wlanIp.text = ip + } else { + wlanIcon.text = "󱚼" + wlanSsid.text = "DISCONNECTED" + wlanSsid.color = "#707880" + wlanSsid.font.bold = false + wlanIp.text = "" + } + } + } + } + } + + // Powerline separator: bg1 -> transparent + Text { + text: "" + color: root.bg1 + font.family: "Inconsolata for Powerline" + font.pixelSize: 25 + Layout.fillHeight: true + verticalAlignment: Text.AlignVCenter + } + } + + // Right modules + RowLayout { + anchors.right: parent.right + anchors.top: parent.top + anchors.bottom: parent.bottom + spacing: -1 + + // Powerline separator: transparent -> bg1 + Text { + text: "" + color: root.bg1 + font.family: "Inconsolata for Powerline" + font.pixelSize: 25 + Layout.fillHeight: true + verticalAlignment: Text.AlignVCenter + } + + + // Volume module + Rectangle { + color: root.bg1 + Layout.fillHeight: true + implicitWidth: volRow.implicitWidth + 16 + + RowLayout { + id: volRow + anchors.centerIn: parent + spacing: 4 + + Text { + id: volIcon + text: "" + color: root.fg + font.family: "Symbols Nerd Font" + font.pixelSize: 12 + } + + Text { + id: volText + color: root.fg + font.family: "Source Code Pro" + font.pixelSize: 14 + } + } + + Timer { + interval: 1000 + running: true + repeat: true + triggeredOnStart: true + onTriggered: volProc.running = true + } + + Process { + id: volProc + command: ["sh", "-c", "wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{if (/MUTED/) print \"MUTED\"; else printf \"%.0f%%\", $2*100}'"] + stdout: StdioCollector { + onStreamFinished: { var out = this.text.trim(); var muted = (out === "MUTED"); volText.text = out; volIcon.text = muted ? "" : "" } + } + } + } + + // Powerline separator: bg1 -> bg2 + Text { + text: "" + color: root.bg2 + font.family: "Inconsolata for Powerline" + font.pixelSize: 25 + Layout.fillHeight: true + verticalAlignment: Text.AlignVCenter + + Rectangle { + anchors.fill: parent + color: root.bg1 + z: -1 + } + } + // RAM module + Rectangle { + color: root.bg2 + Layout.fillHeight: true + implicitWidth: ramRow.implicitWidth + 16 + + property string ramOutput: "" + + RowLayout { + id: ramRow + anchors.centerIn: parent + spacing: 4 + + Text { + text: "" + color: root.fg + font.family: "Symbols Nerd Font" + font.pixelSize: 12 + } + + Text { + id: ramText + color: root.fg + font.family: "Source Code Pro" + font.pixelSize: 14 + } + } + + Timer { + interval: 2000 + running: true + repeat: true + triggeredOnStart: true + onTriggered: ramProc.running = true + } + + Process { + id: ramProc + command: ["sh", "-c", "free -b | awk '/^Mem:/ {printf \"%.1f/%.1fGB\", $3/1073741824, $2/1073741824}'"] + stdout: StdioCollector { + onStreamFinished: ramText.text = this.text.trim() + } + } + } + + // Powerline separator: bg2 -> bg1 + Text { + text: "" + color: root.bg1 + font.family: "Inconsolata for Powerline" + font.pixelSize: 25 + Layout.fillHeight: true + verticalAlignment: Text.AlignVCenter + + Rectangle { + anchors.fill: parent + color: root.bg2 + z: -1 + } + } + + // CPU module + Rectangle { + color: root.bg1 + Layout.fillHeight: true + implicitWidth: cpuRow.implicitWidth + 16 + + RowLayout { + id: cpuRow + anchors.centerIn: parent + spacing: 4 + + Text { + text: "" + color: root.fg + font.family: "Symbols Nerd Font" + font.pixelSize: 12 + } + + Text { + id: cpuText + color: root.fg + font.family: "Source Code Pro" + font.pixelSize: 14 + } + } + + Timer { + interval: 2000 + running: true + repeat: true + triggeredOnStart: true + onTriggered: cpuProc.running = true + } + + Process { + id: cpuProc + command: ["sh", "-c", "awk '/^cpu / {u=$2+$4; t=$2+$3+$4+$5+$6+$7+$8; printf \"%.0f%%\", u*100/t}' /proc/stat"] + stdout: StdioCollector { + onStreamFinished: cpuText.text = this.text.trim() + } + } + } + + // Powerline separator: bg1 -> bg2 + Text { + text: "" + color: root.bg2 + font.family: "Inconsolata for Powerline" + font.pixelSize: 25 + Layout.fillHeight: true + verticalAlignment: Text.AlignVCenter + + Rectangle { + anchors.fill: parent + color: root.bg1 + z: -1 + } + } + + // Date module + Rectangle { + color: root.bg2 + Layout.fillHeight: true + implicitWidth: dateRow.implicitWidth + 16 + + RowLayout { + id: dateRow + anchors.centerIn: parent + spacing: 4 + + Text { + text: "" + color: root.fg + font.family: "Symbols Nerd Font" + font.pixelSize: 12 + } + + Text { + id: dateText + color: root.fg + font.family: "Source Code Pro" + font.pixelSize: 14 + + property var dayKanji: ["日", "月", "火", "水", "木", "金", "土"] + + Timer { + interval: 1000 + running: true + repeat: true + triggeredOnStart: true + onTriggered: { + var now = new Date() + var y = now.getFullYear() + var m = String(now.getMonth() + 1).padStart(2, '0') + var d = String(now.getDate()).padStart(2, '0') + dateText.text = y + "年" + m + "月" + d + "日 (" + dateText.dayKanji[now.getDay()] + ")" + } + } + } + } + } + + // Powerline separator: bg2 -> bg1 + Text { + text: "" + color: root.bg1 + font.family: "Inconsolata for Powerline" + font.pixelSize: 25 + Layout.fillHeight: true + verticalAlignment: Text.AlignVCenter + + Rectangle { + anchors.fill: parent + color: root.bg2 + z: -1 + } + } + + // Time module + Rectangle { + color: root.bg1 + Layout.fillHeight: true + implicitWidth: timeRow.implicitWidth + 16 + + RowLayout { + id: timeRow + anchors.centerIn: parent + spacing: 4 + + Text { + text: "󰥔" + color: root.fg + font.family: "Symbols Nerd Font" + font.pixelSize: 12 + } + + Text { + id: timeText + color: root.fg + font.family: "Source Code Pro" + font.pixelSize: 14 + + Timer { + interval: 100 + running: true + repeat: true + triggeredOnStart: true + onTriggered: { + var now = new Date() + timeText.text = now.toLocaleTimeString(Qt.locale(), "HH:mm:ss") + } + } + } + } + } + } +} -- cgit v1.2.3