From 88a4ce1e0553ee2fbe89dec272e96e55ede127d1 Mon Sep 17 00:00:00 2001 From: Yingjie Wang Date: Thu, 28 May 2026 01:31:30 -0400 Subject: [PATCH] init --- .luarc.json | 7 + hypridle.conf | 47 +++++++ hyprland.lua | 1 + hyprlock.conf | 95 ++++++++++++++ lua/conf/autostart.lua | 1 + lua/conf/colorscheme.lua | 37 ++++++ lua/conf/init.lua | 8 ++ lua/conf/monitor.lua | 9 ++ lua/lib/bind.lua | 41 ++++++ lua/lib/events.lua | 9 ++ lua/lib/globals.lua | 7 + lua/lib/settings.lua | 22 ++++ lua/lib/systemd.lua | 31 +++++ lua/lib/utils.lua | 134 ++++++++++++++++++++ lua/modules/init.lua | 61 +++++++++ lua/modules/swaync.lua | 36 ++++++ lua/modules/waybar.lua | 19 +++ lua/user/settings.lua | 6 + plugins/bundle.conf | 2 + plugins/hyprexpo.conf | 18 +++ plugins/hyprgrass.conf | 39 ++++++ scripts/active-monitor.py | 18 +++ scripts/battery_on_lock.sh | 27 ++++ scripts/cleanup.sh | 7 + scripts/diagnosis.sh | 52 ++++++++ scripts/disabledm.sh | 32 +++++ scripts/eww.sh | 11 ++ scripts/exit.sh | 3 + scripts/gamemode.sh | 24 ++++ scripts/gtk.sh | 35 +++++ scripts/hypridle.sh | 25 ++++ scripts/hyprshade.sh | 52 ++++++++ scripts/init-wallpaper-engine.sh | 26 ++++ scripts/keybindings.sh | 49 +++++++ scripts/loadconfig.sh | 2 + scripts/lock.sh | 3 + scripts/monitors.sh | 2 + scripts/power.sh | 42 ++++++ scripts/reboot.sh | 3 + scripts/restart-hypridle.sh | 5 + scripts/screenshot.sh | 45 +++++++ scripts/shutdown.sh | 3 + scripts/suspend.sh | 3 + scripts/toggle-animations.sh | 13 ++ scripts/toggleallfloat.sh | 11 ++ scripts/wallpaper-effects.sh | 12 ++ scripts/wallpaper.sh | 211 +++++++++++++++++++++++++++++++ scripts/xdg.sh | 27 ++++ systemd/swaync.service | 18 +++ 49 files changed, 1391 insertions(+) create mode 100644 .luarc.json create mode 100644 hypridle.conf create mode 100644 hyprland.lua create mode 100644 hyprlock.conf create mode 100644 lua/conf/autostart.lua create mode 100644 lua/conf/colorscheme.lua create mode 100644 lua/conf/init.lua create mode 100644 lua/conf/monitor.lua create mode 100644 lua/lib/bind.lua create mode 100644 lua/lib/events.lua create mode 100644 lua/lib/globals.lua create mode 100644 lua/lib/settings.lua create mode 100644 lua/lib/systemd.lua create mode 100644 lua/lib/utils.lua create mode 100644 lua/modules/init.lua create mode 100644 lua/modules/swaync.lua create mode 100644 lua/modules/waybar.lua create mode 100644 lua/user/settings.lua create mode 100644 plugins/bundle.conf create mode 100644 plugins/hyprexpo.conf create mode 100644 plugins/hyprgrass.conf create mode 100644 scripts/active-monitor.py create mode 100755 scripts/battery_on_lock.sh create mode 100755 scripts/cleanup.sh create mode 100755 scripts/diagnosis.sh create mode 100755 scripts/disabledm.sh create mode 100755 scripts/eww.sh create mode 100755 scripts/exit.sh create mode 100755 scripts/gamemode.sh create mode 100755 scripts/gtk.sh create mode 100755 scripts/hypridle.sh create mode 100755 scripts/hyprshade.sh create mode 100755 scripts/init-wallpaper-engine.sh create mode 100755 scripts/keybindings.sh create mode 100755 scripts/loadconfig.sh create mode 100755 scripts/lock.sh create mode 100755 scripts/monitors.sh create mode 100755 scripts/power.sh create mode 100755 scripts/reboot.sh create mode 100755 scripts/restart-hypridle.sh create mode 100755 scripts/screenshot.sh create mode 100755 scripts/shutdown.sh create mode 100755 scripts/suspend.sh create mode 100755 scripts/toggle-animations.sh create mode 100755 scripts/toggleallfloat.sh create mode 100755 scripts/wallpaper-effects.sh create mode 100755 scripts/wallpaper.sh create mode 100755 scripts/xdg.sh create mode 100644 systemd/swaync.service diff --git a/.luarc.json b/.luarc.json new file mode 100644 index 0000000..b4ecec0 --- /dev/null +++ b/.luarc.json @@ -0,0 +1,7 @@ +{ + "workspace": { + "library": [ + "/usr/share/hypr/stubs" + ] + } +} diff --git a/hypridle.conf b/hypridle.conf new file mode 100644 index 0000000..9c37adb --- /dev/null +++ b/hypridle.conf @@ -0,0 +1,47 @@ +# _ _ _ _ +# | |__ _ _ _ __ _ __(_) __| | | ___ +# | '_ \| | | | '_ \| '__| |/ _` | |/ _ \ +# | | | | |_| | |_) | | | | (_| | | __/ +# |_| |_|\__, | .__/|_| |_|\__,_|_|\___| +# |___/|_| +# +# Version 2.8.3 +# DO NOT REMOVE THE REPLACEMENT COMMENTS +# REQUIRED BY THE ML4W SETTINGS APP +# https://wiki.hyprland.org/Hypr-Ecosystem/hypridle/ + +general { + ignore_dbus_inhibit = false +} + +general { + lock_cmd = pidof hyprlock || hyprlock # avoid starting multiple hyprlock instances. + before_sleep_cmd = loginctl lock-session # lock before suspend. + after_sleep_cmd = hyprctl dispatch dpms on # to avoid having to press a key twice to turn on the display. +} + +# Screenlock +listener { + # HYPRLOCK TIMEOUT + timeout = 600 + # HYPRLOCK ONTIMEOUT + on-timeout = loginctl lock-session +} + +# dpms +listener { + # DPMS TIMEOUT + timeout = 660 + # DPMS ONTIMEOUT + on-timeout = hyprctl dispatch dpms off + # DPMS ONRESUME + on-resume = hyprctl dispatch dpms on +} + +# Suspend +listener { + # SUSPEND TIMEOUT + timeout = 1800 + #SUSPEND ONTIMEOUT + on-timeout = systemctl suspend +} diff --git a/hyprland.lua b/hyprland.lua new file mode 100644 index 0000000..c0fc990 --- /dev/null +++ b/hyprland.lua @@ -0,0 +1 @@ +require("lua.conf") diff --git a/hyprlock.conf b/hyprlock.conf new file mode 100644 index 0000000..230fa4b --- /dev/null +++ b/hyprlock.conf @@ -0,0 +1,95 @@ +# _ _ _ +# | |__ _ _ _ __ _ __| | ___ ___| | __ +# | '_ \| | | | '_ \| '__| |/ _ \ / __| |/ / +# | | | | |_| | |_) | | | | (_) | (__| < +# |_| |_|\__, | .__/|_| |_|\___/ \___|_|\_\ +# |___/|_| +# + +source = ~/dotfiles/theme/hyprland-color.conf +background { + monitor = + path = $HOME/.cache/used_wallpaper # only png supported for now + #color = rgba(0,0,0,0) + blur_passes = 3 + blur_size = 14 + noise = 0.1 +} + +input-field { + monitor = + size = 400, 70 + outline_thickness = 3 + dots_size = 0.33 # Scale of input-field height, 0.2 - 0.8 + dots_spacing = 0.4 # Scale of dots' absolute size, 0.0 - 1.0 + dots_center = true + dots_rounding = -1 # -1 default circle, -2 follow input-field rounding + outer_color = $blue + inner_color = $surface2 + font_color = $blue + fade_on_empty = true + fade_timeout = 1000 # Milliseconds before fade_on_empty is triggered. + placeholder_text = Input Password... # Text rendered in the input box when it's empty. + hide_input = false + rounding = -1 # -1 means complete rounding (circle/oval) + check_color = rgb(250, 179, 135) + fail_color = rgb(243, 139, 168) # if authentication failed, changes outer_color and fail message color + fail_text = $FAIL ($ATTEMPTS) # can be set to empty + invert_numlock = false # change color if numlock is off + swap_font_color = false # see below + position = 0, -20 + halign = center + valign = center +} + +label { + monitor = + text = cmd[update:1000] echo -e "$(~/dotfiles/hypr/scripts/battery_on_lock.sh)" + color = rgb(137, 180, 250) + font_size = 32 + font_family = Fira Code NF + halign = right + valign = bottom + position = -100, 10 +} + +label { + monitor = + text = cmd[update:1000] echo "$TIME" + color = rgba(205, 214, 244, 1.0) + font_size = 55 + font_family = Fira Semibold + position = -100, 50 + halign = right + valign = bottom + shadow_passes = 5 + shadow_size = 10 +} + +label { + monitor = + text = $USER + color = rgba(205, 214, 244, 1.0) + font_size = 32 + font_family = Fira Semibold + position = -100, 170 + halign = right + valign = bottom + shadow_passes = 5 + shadow_size = 10 +} + +image { + monitor = + path = $HOME/.cache/square_wallpaper.png + size = 300 # lesser side if not 1:1 ratio + rounding = -1 # negative values mean circle + border_size = 4 + border_color = rgb(137, 180, 250) + rotate = 0 # degrees, counter-clockwise + reload_time = -1 # seconds between reloading, 0 to reload with SIGUSR2 +# reload_cmd = # command to get new path. if empty, old path will be used. don't run "follow" commands like tail -F + position = 0, 250 + halign = center + valign = center +} diff --git a/lua/conf/autostart.lua b/lua/conf/autostart.lua new file mode 100644 index 0000000..5b9c9fe --- /dev/null +++ b/lua/conf/autostart.lua @@ -0,0 +1 @@ +local settings = require("lua.lib.settings") diff --git a/lua/conf/colorscheme.lua b/lua/conf/colorscheme.lua new file mode 100644 index 0000000..9e41126 --- /dev/null +++ b/lua/conf/colorscheme.lua @@ -0,0 +1,37 @@ +local settings = require("lua.lib.settings") +local colorscheme + +-- currently, only catppuccin is considerd +if settings["colorscheme"] == "catppuccin" or settings["colorscheme"] == "catppuccin-mocha" or true then + colorscheme.rosewater = "#f5e0dc" + colorscheme.flamingo = "#f2cdcd" + colorscheme.pink = "#f5c2e7" + colorscheme.mauve = "#cba6f7" + colorscheme.red = "#f38ba8" + colorscheme.maroon = "#eba0ac" + colorscheme.peach = "#fab387" + colorscheme.yellow = "#f9e2af" + colorscheme.green = "#a6e3a1" + colorscheme.teal = "#94e2d5" + colorscheme.sky = "#89dceb" + colorscheme.sapphire = "#74c7ec" + colorscheme.blue = "#89b4fa" + colorscheme.lavender = "#b4befe" + colorscheme.text = "#cdd6f4" + colorscheme.subtext1 = "#bac2de" + colorscheme.subtext0 = "#a6adc8" + colorscheme.overlay2 = "#9399b2" + colorscheme.overlay1 = "#7f849c" + colorscheme.overlay0 = "#6c7086" + colorscheme.surface2 = "#585b70" + colorscheme.surface1 = "#45475a" + colorscheme.surface0 = "#313244" + colorscheme.base = "#1e1e2e" + colorscheme.mantle = "#181825" + colorscheme.crust = "#11111b" + colorscheme.foreground = colorscheme.text + colorscheme.background = colorscheme.surface0 + colorscheme.accent = colorscheme.blue +end + +return colorscheme diff --git a/lua/conf/init.lua b/lua/conf/init.lua new file mode 100644 index 0000000..15d4ef0 --- /dev/null +++ b/lua/conf/init.lua @@ -0,0 +1,8 @@ +local settings = require("lua.lib.settings") +require("lua.lib.globals") + +require("lua.conf.monitor") + +require("lua.modules").load() + +hl.bind("SUPER + Return", hl.dsp.exec_cmd("kitty")) diff --git a/lua/conf/monitor.lua b/lua/conf/monitor.lua new file mode 100644 index 0000000..8b74d88 --- /dev/null +++ b/lua/conf/monitor.lua @@ -0,0 +1,9 @@ +local settings = require("lua.lib.settings") + +if settings["host"] == "laptop" then + hl.monitor({ + output = "eDP-1", + mode = "highres", + scale = "auto", + }) +end diff --git a/lua/lib/bind.lua b/lua/lib/bind.lua new file mode 100644 index 0000000..83a95fc --- /dev/null +++ b/lua/lib/bind.lua @@ -0,0 +1,41 @@ +local bind = {} + +bind.leader = "SUPER" + +local function merge(...) + local out = {} + + for _, t in ipairs({ ... }) do + if t ~= nil then + for k, v in pairs(t) do + out[k] = v + end + end + end + + return out +end + +local function with_leader(keys) + if keys == nil or keys == "" then + return bind.leader + end + + return bind.leader .. " + " .. keys +end + +function bind.key(keys, dispatcher, desc, opts) + local flags = merge(opts) + + if desc ~= nil then + flags.description = desc + end + + return hl.bind(keys, dispatcher, flags) +end + +function bind.leader_key(keys, dispatcher, desc, opts) + return bind.key(with_leader(keys), dispatcher, desc, opts) +end + +return bind diff --git a/lua/lib/events.lua b/lua/lib/events.lua new file mode 100644 index 0000000..f5e2abc --- /dev/null +++ b/lua/lib/events.lua @@ -0,0 +1,9 @@ +local M = {} + +function M.map(event, func_list) + for _, func in pairs(func_list) do + hl.on(event, func) + end +end + +return M diff --git a/lua/lib/globals.lua b/lua/lib/globals.lua new file mode 100644 index 0000000..73f1d14 --- /dev/null +++ b/lua/lib/globals.lua @@ -0,0 +1,7 @@ +HOME = os.getenv("HOME") +CONFIG_HOME = os.getenv("XDG_CONFIG_HOME") +if not CONFIG_HOME then + CONFIG_HOME = HOME .. "/.config" +end +HYPR = CONFIG_HOME .. "/hypr" +USER_CONFIG = HYPR .. "/lua/user" diff --git a/lua/lib/settings.lua b/lua/lib/settings.lua new file mode 100644 index 0000000..0b91586 --- /dev/null +++ b/lua/lib/settings.lua @@ -0,0 +1,22 @@ +local settings = {} + +---@type string +settings["hostname"] = "" + +---@type "desktop"|"laptop" +settings["profile"] = "desktop" + +---@type "catppuccin"|"catppuccin-mocha" +settings["colorscheme"] = "catppuccin" + +---@type boolean +settings["systemd"] = false + +---@type table +settings["modules"] = { + waybar = true, + swaync = true, + swayosd = true, +} + +return require("lua.lib.utils").extend_config(settings, "lua.user.settings") diff --git a/lua/lib/systemd.lua b/lua/lib/systemd.lua new file mode 100644 index 0000000..c9680b4 --- /dev/null +++ b/lua/lib/systemd.lua @@ -0,0 +1,31 @@ +local utils = require("lua.lib.utils") +local M = {} + +function M.is_user_unit_exists(unit) + return utils.command_success("systemctl --user cat " .. utils.shell_quote(unit) .. " >/dev/null 2>&1") +end + +M.user_unit_dir = CONFIG_HOME .. "/systemd/user" + +function M.ensure_user_unit(unit, source) + if M.is_user_unit_exists(unit) then + return true + end + + local target_dir = M.user_unit_dir + local target = target_dir .. "/" .. unit + + local cmd = table.concat({ + "mkdir -p " .. utils.shell_quote(target_dir), + "ln -s " .. utils.shell_quote(source) .. " " .. utils.shell_quote(target), + "systemctl --user daemon-reload", + }, " && ") + + return utils.command_success(cmd) +end + +function M.start_user_unit(unit) + return utils.command_success("systemctl --user start " .. utils.shell_quote(unit) .. " >/dev/null 2>&1") +end + +return M diff --git a/lua/lib/utils.lua b/lua/lib/utils.lua new file mode 100644 index 0000000..ff20856 --- /dev/null +++ b/lua/lib/utils.lua @@ -0,0 +1,134 @@ +-- lua/lib/utils.lua +require("lua.lib.globals") +local M = {} + +local function is_table(x) + return type(x) == "table" +end + +local function is_list(t) + if type(t) ~= "table" then + return false + end + + local n = 0 + + for k, _ in pairs(t) do + if type(k) ~= "number" then + return false + end + + if k > n then + n = k + end + end + + for i = 1, n do + if t[i] == nil then + return false + end + end + + return true +end + +function M.list_extend(dst, src) + for _, value in ipairs(src) do + table.insert(dst, value) + end + + return dst +end + +local function deepcopy(value, seen) + if type(value) ~= "table" then + return value + end + + seen = seen or {} + if seen[value] then + return seen[value] + end + + local result = {} + seen[value] = result + + for k, v in pairs(value) do + result[deepcopy(k, seen)] = deepcopy(v, seen) + end + + return result +end + +function M.tbl_recursive_merge(defaults, overrides) + local result = deepcopy(defaults) + + if not is_table(overrides) then + return result + end + + for key, value in pairs(overrides) do + if is_table(value) and is_table(result[key]) then + result[key] = M.tbl_recursive_merge(result[key], value) + else + result[key] = deepcopy(value) + end + end + + return result +end + +function M.extend_config(defaults, user_module) + if not M.is_file_exists(HYPR .. user_module) then + return deepcopy(defaults) + end + local ok, overrides = pcall(require, user_module) + + if not ok then + return deepcopy(defaults) + end + + if type(overrides) ~= "table" then + return deepcopy(defaults) + end + + return M.tbl_recursive_merge(defaults, overrides) +end + +function M.is_file_exists(name) + local f = io.open(name, "r") + if f ~= nil then + io.close(f) + return true + else + return false + end +end + +function M.exec_if_file_extes(file) + if M.is_file_exists(file) then + hl.exec_cmd(file) + else + hl.notification.create({ file .. " doesn't extist", 5000, 0 }) + end +end + +function M.create_if_not_exists(path) + if not M.is_file_exists(path) then + os.execute('mkdir -pv "$(dirname "' .. path .. '")"') + os.execute("touch " .. path) + return true + end + return false +end + +function M.shell_quote(s) + return "'" .. tostring(s):gsub("'", "'\\''") .. "'" +end + +function M.command_success(cmd) + local ok = os.execute(cmd) + return ok == true or ok == 0 +end + +return M diff --git a/lua/modules/init.lua b/lua/modules/init.lua new file mode 100644 index 0000000..c310548 --- /dev/null +++ b/lua/modules/init.lua @@ -0,0 +1,61 @@ +local settings = require("lua.lib.settings") +require("lua.lib.globals") +local utils = require("lua.lib.utils") +local events = require("lua.lib.events") + +local M = {} +local modules = {} + +local function is_module_exists(name) + return utils.is_file_exists(HYPR .. "/lua/modules/" .. name .. ".lua") +end + +local function load_module(name) + if not is_module_exists(name) then + return {} + end + local default_mod = require("lua.modules." .. name) + + local user_modname = "lua.user.modules." .. name + local mod = utils.extend_config(default_mod, user_modname) + + return mod +end + +for name, enabled in pairs(settings.modules) do + if enabled then + local mod = load_module(name) + table.insert(modules, { + name = name, + config = mod, + }) + end +end + +M.autostart = {} +M.autostop = {} +M.binds = {} + +local function collect_modules_prop(module, prop) + if module[prop] then + M[prop] = utils.list_extend(M[prop], module[prop]) + end +end + +for _, item in ipairs(modules) do + local module = item.config + collect_modules_prop(module, "autostart") + collect_modules_prop(module, "autostop") + collect_modules_prop(module, "binds") +end + +function M.load() + events.map("hyprland.start", M.autostart) + events.map("hyprland.shutdown", M.autostop) + + for _, bind in pairs(M.binds) do + bind() + end +end + +return M diff --git a/lua/modules/swaync.lua b/lua/modules/swaync.lua new file mode 100644 index 0000000..3b4ca2a --- /dev/null +++ b/lua/modules/swaync.lua @@ -0,0 +1,36 @@ +local settings = require("lua.lib.settings") +local systemd = require("lua.lib.systemd") +local utils = require("lua.lib.utils") +require("lua.lib.globals") +local M = {} + +local function start_swaync() + if settings["systemd"] then + local unit = "swaync.service" + local source = CONFIG_HOME .. "hypr/systemd/" .. unit + + if systemd.ensure_user_unit(unit, source) then + hl.exec_cmd("systemctl --user start swaync") + else + hl.exec_cmd("swaync") + end + else + hl.exec_cmd("swaync") + end +end + +local function stop_swaync() + if settings["systemd"] and utils.command_success("systemctl --user status swaync") then + hl.exec_cmd("systemctl --user stop swaync") + end +end + +M.autostart = { + start_swaync, +} + +M.autostop = { + stop_swaync, +} + +return M diff --git a/lua/modules/waybar.lua b/lua/modules/waybar.lua new file mode 100644 index 0000000..69b4f7e --- /dev/null +++ b/lua/modules/waybar.lua @@ -0,0 +1,19 @@ +local M = {} +local bind = require("lua.lib.bind") + +local function start_waybar() + hl.exec_cmd("~/dotfiles/waybar/launch.sh") +end + +M.autostart = { + start_waybar, +} + +M.binds = { + function() + bind.leader_key("SHIFT + B", hl.dsp.exec_cmd("~/dotfiles/waybar/launch.sh"), "(re)launch waybar", {}) + bind.leader_key("CTRL + B", hl.dsp.exec_cmd("~/dotfiles/waybar/toggle.sh"), "toggle waybar", {}) + end, +} + +return M diff --git a/lua/user/settings.lua b/lua/user/settings.lua new file mode 100644 index 0000000..6ae84e6 --- /dev/null +++ b/lua/user/settings.lua @@ -0,0 +1,6 @@ +local settings = {} + +settings["hostname"] = "arch-c940" +settings["profile"] = "laptop" + +return settings diff --git a/plugins/bundle.conf b/plugins/bundle.conf new file mode 100644 index 0000000..3fea5c8 --- /dev/null +++ b/plugins/bundle.conf @@ -0,0 +1,2 @@ +#source = hyprgrass.conf +#source = hyprexpo.conf diff --git a/plugins/hyprexpo.conf b/plugins/hyprexpo.conf new file mode 100644 index 0000000..d3a84fe --- /dev/null +++ b/plugins/hyprexpo.conf @@ -0,0 +1,18 @@ +plugin { + hyprexpo { + columns = 2 + gap_size = 5 + bg_col = rgb(1e1e2e) + workspace_method = center current # [center/first] [workspace] e.g. first 1 or center m+1 + + gesture_distance = 300 # how far is the "max" for the gesture + } +} + +hyprexpo-gesture = 3, vertical, expo + +#gesture = 3, up, dispatcher, hyprexpo:expo, on +#gesture = 3, down, dispatcher, hyprexpo:expo, off + +bind = $mainMod, F3, hyprexpo:expo, toggle +bind = $mainMod CTRL, RETURN, hyprexpo:expo, select diff --git a/plugins/hyprgrass.conf b/plugins/hyprgrass.conf new file mode 100644 index 0000000..9e5311f --- /dev/null +++ b/plugins/hyprgrass.conf @@ -0,0 +1,39 @@ +plugin { + touch_gestures { + # The default sensitivity is probably too low on tablet screens, + # I recommend turning it up to 4.0 + sensitivity = 4.0 + + # must be >= 3 + workspace_swipe_fingers = 3 + + # switching workspaces by swiping from an edge, this is separate from workspace_swipe_fingers + # and can be used at the same time + # possible values: l, r, u, or d + # to disable it set it to anything else + workspace_swipe_edge = x + + # in milliseconds + long_press_delay = 400 + + # resize windows by long-pressing on window borders and gaps. + # If general:resize_on_border is enabled, general:extend_border_grab_area is used for floating + # windows + resize_on_border_long_press = true + + # in pixels, the distance from the edge that is considered an edge + edge_margin = 40 + + # emulates touchpad swipes when swiping in a direction that does not trigger workspace swipe. + # ONLY triggers when finger count is equal to workspace_swipe_fingers + # + # might be removed in the future in favor of event hooks + emulate_touchpad_swipe = true + + experimental { + # send proper cancel events to windows instead of hacky touch_up events, + # NOT recommended as it crashed a few times, once it's stabilized I'll make it the default + send_cancel = 0 + } + } +} diff --git a/scripts/active-monitor.py b/scripts/active-monitor.py new file mode 100644 index 0000000..9aad2ae --- /dev/null +++ b/scripts/active-monitor.py @@ -0,0 +1,18 @@ +import sys +import subprocess +import os +import json +import pathlib +import shutil + +# Get script path +pathname = os.path.dirname(sys.argv[0]) +homeFolder = os.path.expanduser('~') # Path to home folder +dotfiles = homeFolder + "/dotfiles/" + +result = subprocess.run(["bash", dotfiles + "hypr/scripts/monitors.sh"], capture_output=True, text=True) +monitors_json = result.stdout.strip() +monitors_arr = json.loads(monitors_json) +for row in monitors_arr: + if row["focused"]: + print(row["id"]) diff --git a/scripts/battery_on_lock.sh b/scripts/battery_on_lock.sh new file mode 100755 index 0000000..907e0e1 --- /dev/null +++ b/scripts/battery_on_lock.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Get the current battery percentage +battery_percentage=$(cat /sys/class/power_supply/BAT1/capacity) + +# Get the battery status (Charging or Discharging) +battery_status=$(cat /sys/class/power_supply/BAT1/status) + +# Define the battery icons for each 10% segment +battery_icons=("󰂃" "󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰁹") + +# Define the charging icon +charging_icon="󰂄" + +# Calculate the index for the icon array +icon_index=$((battery_percentage / 10)) + +# Get the corresponding icon +battery_icon=${battery_icons[icon_index]} + +# Check if the battery is charging +if [ "$battery_status" = "Charging" ]; then + battery_icon="$charging_icon" +fi + +# Output the battery percentage and icon +echo "$battery_icon $battery_percentage%" diff --git a/scripts/cleanup.sh b/scripts/cleanup.sh new file mode 100755 index 0000000..51589da --- /dev/null +++ b/scripts/cleanup.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Remove gamemode flag +if [ -f ~/.cache/gamemode ] ;then + rm ~/.cache/gamemode + echo ":: ~/.cache/gamemode removed" +fi \ No newline at end of file diff --git a/scripts/diagnosis.sh b/scripts/diagnosis.sh new file mode 100755 index 0000000..a91a668 --- /dev/null +++ b/scripts/diagnosis.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# ____ _ _ +# | _ \(_) __ _ __ _ _ __ ___ ___(_)___ +# | | | | |/ _` |/ _` | '_ \ / _ \/ __| / __| +# | |_| | | (_| | (_| | | | | (_) \__ \ \__ \ +# |____/|_|\__,_|\__, |_| |_|\___/|___/_|___/ +# |___/ +# + +clear +sleep 0.5 +figlet "Diagnosis" +echo +echo "This script will check that essential packages and " +echo "execution commands are available on your system." +echo + +_commandExists() { + package="$1"; + if ! type $package > /dev/null 2>&1; then + echo ":: ERROR: $package doesn't exists. Please install it with yay -S $2" + else + echo ":: OK: $package found." + fi +} + +_folderExists() { + folder="$1"; + if [ ! -d $folder ]; then + echo ":: ERROR: $folder doesn't exists." + else + echo ":: OK: $folder found." + fi +} + +_commandExists "rofi" "rofi-wayland" +_commandExists "dunst" "dunst" +_commandExists "waybar" "waybar" +_commandExists "hyprpaper" "hyprpaper" +_commandExists "hyprlock" "hyprpaper" +_commandExists "hypridle" "hyprpaper" +_commandExists "wal" "python-pywal" +_commandExists "gum" "gum" +_commandExists "wlogout" "wlogout" +_commandExists "swww" "swww" +_commandExists "eww" "eww" +_commandExists "magick" "imagemagick" +_commandExists "figlet" "figlet" + +echo +echo "Press return to exit" +read \ No newline at end of file diff --git a/scripts/disabledm.sh b/scripts/disabledm.sh new file mode 100755 index 0000000..02b6718 --- /dev/null +++ b/scripts/disabledm.sh @@ -0,0 +1,32 @@ +#!/bin/bash +clear +cat <<"EOF" + ____ _ _ _ ____ __ __ +| _ \(_)___ __ _| |__ | | ___| _ \| \/ | +| | | | / __|/ _` | '_ \| |/ _ \ | | | |\/| | +| |_| | \__ \ (_| | |_) | | __/ |_| | | | | +|____/|_|___/\__,_|_.__/|_|\___|____/|_| |_| + +EOF + +echo "Hyprland recommends the start with the tty login." +echo "You can deactivate the current display manager (if exists)." +echo "" +echo "-> Do you really want to deactivate the display manager?" +while true; do + read -p "Do you want to enable the sddm display manager and setup theme? (Yy/Nn): " yn + case $yn in + [Yy]* ) + if [ -f /etc/systemd/system/display-manager.service ]; then + sudo rm /etc/systemd/system/display-manager.service + echo "Current display manager removed." + else + echo "No active display manager found." + fi + break;; + [Nn]* ) + exit + break;; + * ) echo "Please answer yes or no.";; + esac +done \ No newline at end of file diff --git a/scripts/eww.sh b/scripts/eww.sh new file mode 100755 index 0000000..7df4512 --- /dev/null +++ b/scripts/eww.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# _____ ____ __ +# / _ \ \ /\ / /\ \ /\ / / +# | __/\ V V / \ V V / +# \___| \_/\_/ \_/\_/ +# +EWW=`which eww` +if [[ ! `pidof eww` ]]; then + ${EWW} daemon + sleep 0.5 +fi diff --git a/scripts/exit.sh b/scripts/exit.sh new file mode 100755 index 0000000..c3e8a7a --- /dev/null +++ b/scripts/exit.sh @@ -0,0 +1,3 @@ +#!/bin/bash +sleep 0.5 +killall -9 Hyprland sleep 2 \ No newline at end of file diff --git a/scripts/gamemode.sh b/scripts/gamemode.sh new file mode 100755 index 0000000..815a780 --- /dev/null +++ b/scripts/gamemode.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# ____ _ +# / ___| __ _ _ __ ___ ___ _ __ ___ ___ __| | ___ +# | | _ / _` | '_ ` _ \ / _ \ '_ ` _ \ / _ \ / _` |/ _ \ +# | |_| | (_| | | | | | | __/ | | | | | (_) | (_| | __/ +# \____|\__,_|_| |_| |_|\___|_| |_| |_|\___/ \__,_|\___| +# + +if [ -f ~/.cache/gamemode ] ;then + hyprctl reload + rm ~/.cache/gamemode + notify-send "Gamemode deactivated" "Animations and blur enabled" +else + hyprctl --batch "\ + keyword animations:enabled 0;\ + keyword decoration:drop_shadow 0;\ + keyword decoration:blur:enabled 0;\ + keyword general:gaps_in 0;\ + keyword general:gaps_out 0;\ + keyword general:border_size 1;\ + keyword decoration:rounding 0" + touch ~/.cache/gamemode + notify-send "Gamemode activated" "Animations and blur disabled" +fi diff --git a/scripts/gtk.sh b/scripts/gtk.sh new file mode 100755 index 0000000..4e56ba7 --- /dev/null +++ b/scripts/gtk.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# ____ _____ _ __ +# / ___|_ _| |/ / +# | | _ | | | ' / +# | |_| | | | | . \ +# \____| |_| |_|\_\ +# +# Source: https://github.com/swaywm/sway/wiki/GTK-3-settings-on-Wayland + +config="$HOME/.config/gtk-3.0/settings.ini" +if [ ! -f "$config" ]; then exit 1; fi + +gnome_schema="org.gnome.desktop.interface" +gtk_theme="$(grep 'gtk-theme-name' "$config" | sed 's/.*\s*=\s*//')" +icon_theme="$(grep 'gtk-icon-theme-name' "$config" | sed 's/.*\s*=\s*//')" +cursor_theme="$(grep 'gtk-cursor-theme-name' "$config" | sed 's/.*\s*=\s*//')" +cursor_size="$(grep 'gtk-cursor-theme-size' "$config" | sed 's/.*\s*=\s*//')" +font_name="$(grep 'gtk-font-name' "$config" | sed 's/.*\s*=\s*//')" + +echo $gtk_theme +echo $icon_theme +echo $cursor_theme +echo $cursor_size +echo $font_name + +gsettings set "$gnome_schema" gtk-theme "$gtk_theme" +gsettings set "$gnome_schema" icon-theme "$icon_theme" +gsettings set "$gnome_schema" cursor-theme "$cursor_theme" +gsettings set "$gnome_schema" font-name "$font_name" +gsettings set "$gnome_schema" color-scheme "prefer-dark" + +# if [ -f ~/dotfiles/hypr/conf/cursor.conf ] ;then +# echo "exec-once = hyprctl setcursor $cursor_theme $cursor_size" > ~/dotfiles/hypr/conf/cursor.conf +# hyprctl setcursor $cursor_theme $cursor_size +# fi \ No newline at end of file diff --git a/scripts/hypridle.sh b/scripts/hypridle.sh new file mode 100755 index 0000000..e710b41 --- /dev/null +++ b/scripts/hypridle.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# _ _ _ _ _ +# | | | |_ _ _ __ _ __(_) __| | | ___ +# | |_| | | | | '_ \| '__| |/ _` | |/ _ \ +# | _ | |_| | |_) | | | | (_| | | __/ +# |_| |_|\__, | .__/|_| |_|\__,_|_|\___| +# |___/|_| +# + +SERVICE="hypridle" +if [[ "$1" == "status" ]]; then + sleep 1 + if pgrep -x "$SERVICE" >/dev/null ;then + echo '{"text": "RUNNING", "class": "active", "tooltip": "Screen locking active"}' + else + echo '{"text": "NOT RUNNING", "class": "notactive", "tooltip": "Screen locking deactivated"}' + fi +fi +if [[ "$1" == "toggle" ]]; then + if pgrep -x "$SERVICE" >/dev/null ;then + killall hypridle + else + hypridle + fi +fi diff --git a/scripts/hyprshade.sh b/scripts/hyprshade.sh new file mode 100755 index 0000000..ccb9b7f --- /dev/null +++ b/scripts/hyprshade.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# _ _ _ _ +# | | | |_ _ _ __ _ __ ___| |__ __ _ __| | ___ +# | |_| | | | | '_ \| '__/ __| '_ \ / _` |/ _` |/ _ \ +# | _ | |_| | |_) | | \__ \ | | | (_| | (_| | __/ +# |_| |_|\__, | .__/|_| |___/_| |_|\__,_|\__,_|\___| +# |___/|_| +# + +if [[ "$1" == "rofi" ]]; then + + # Open rofi to select the Hyprshade filter for toggle + options="$(hyprshade ls)\noff" + + # Open rofi + choice=$(echo -e "$options" | rofi -dmenu -replace -config ~/dotfiles/rofi/config-hyprshade.rasi -i -no-show-icons -l 4 -width 30 -p "Hyprshade") + if [ ! -z $choice ] ;then + echo "hyprshade_filter=\"$choice\"" > ~/dotfiles/.settings/hyprshade.sh + dunstify "Changing Hyprshade to $choice" "Toggle shader with SUPER+SHIFT+S" + fi + +else + + # Toggle Hyprshade based on the selected filter + hyprshade_filter="blue-light-filter" + + # Check if hyprshade.sh settings file exists and load + if [ -f ~/dotfiles/.settings/hyprshade.sh ] ;then + source ~/dotfiles/.settings/hyprshade.sh + fi + + # Toggle Hyprshade + if [ "$hyprshade_filter" != "off" ] ;then + if [ -z $(hyprshade current) ] ;then + echo ":: hyprshade is not running" + hyprshade on $hyprshade_filter + notify-send "Hyprshade activated" "with $(hyprshade current)" + echo ":: hyprshade started with $(hyprshade current)" + else + notify-send "Hyprshade deactivated" + echo ":: Current hyprshade $(hyprshade current)" + echo ":: Switching hyprshade off" + hyprshade off + fi + else + if [ -z $(hyprshade current) ] ;then + hyprshade off + fi + echo ":: hyprshade turned off" + fi + +fi diff --git a/scripts/init-wallpaper-engine.sh b/scripts/init-wallpaper-engine.sh new file mode 100755 index 0000000..1278ab7 --- /dev/null +++ b/scripts/init-wallpaper-engine.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# __ ______ _____ _ +# \ \ / / _ \ | ____|_ __ __ _(_)_ __ ___ +# \ \ /\ / /| |_) | | _| | '_ \ / _` | | '_ \ / _ \ +# \ V V / | __/ | |___| | | | (_| | | | | | __/ +# \_/\_/ |_| |_____|_| |_|\__, |_|_| |_|\___| +# |___/ +# + +wallpaper_engine=$(cat $HOME/dotfiles/.settings/wallpaper-engine.sh) +if [ "$wallpaper_engine" == "awww" ] ;then + # awww + echo ":: Using awww" + awww-daemon --format xrgb + sleep 0.5 + ~/dotfiles/hypr/scripts/wallpaper.sh init +elif [ "$wallpaper_engine" == "hyprpaper" ] ;then + # hyprpaper + echo ":: Using hyprpaper" + sleep 0.5 + ~/dotfiles/hypr/scripts/wallpaper.sh init +else + echo ":: Wallpaper Engine disabled" + ~/dotfiles/hypr/scripts/wallpaper.sh init +fi + diff --git a/scripts/keybindings.sh b/scripts/keybindings.sh new file mode 100755 index 0000000..d4edd07 --- /dev/null +++ b/scripts/keybindings.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# _ _ _ _ _ +# | | _____ _ _| |__ (_)_ __ __| (_)_ __ __ _ ___ +# | |/ / _ \ | | | '_ \| | '_ \ / _` | | '_ \ / _` / __| +# | < __/ |_| | |_) | | | | | (_| | | | | | (_| \__ \ +# |_|\_\___|\__, |_.__/|_|_| |_|\__,_|_|_| |_|\__, |___/ +# |___/ |___/ +# by Stephan Raabe (2023) +# ----------------------------------------------------- + +# ----------------------------------------------------- +# Get keybindings location based on variation +# ----------------------------------------------------- +config_file=$(cat ~/dotfiles/hypr/conf/keybinding.conf) +config_file=${config_file/source = ~/} +config_file=${config_file/source=~/} + +# ----------------------------------------------------- +# Path to keybindings config file +# ----------------------------------------------------- +config_file="/home/$USER$config_file" +echo "Reading from: $config_file" + +keybinds="" + +# Detect Start String +while read -r line +do + if [[ "$line" == "bind"* ]]; then + + line="$(echo "$line" | sed 's/$mainMod/SUPER/g')" + line="$(echo "$line" | sed 's/bind = //g')" + line="$(echo "$line" | sed 's/bindm = //g')" + + IFS='#' + read -a strarr <<<"$line" + kb_str=${strarr[0]} + cm_str=${strarr[1]} + + IFS=',' + read -a kbarr <<<"$kb_str" + + item="${kbarr[0]} + ${kbarr[1]}"$'\r'"${cm_str:1}" + keybinds=$keybinds$item$'\n' + fi +done < "$config_file" + +sleep 0.2 +rofi -dmenu -i -markup -eh 2 -replace -p "Keybinds" -config ~/dotfiles/rofi/config-compact.rasi <<< "$keybinds" \ No newline at end of file diff --git a/scripts/loadconfig.sh b/scripts/loadconfig.sh new file mode 100755 index 0000000..a51ce6d --- /dev/null +++ b/scripts/loadconfig.sh @@ -0,0 +1,2 @@ +#!/bin/bash +hyprctl reload \ No newline at end of file diff --git a/scripts/lock.sh b/scripts/lock.sh new file mode 100755 index 0000000..bc13b07 --- /dev/null +++ b/scripts/lock.sh @@ -0,0 +1,3 @@ +#!/bin/bash +sleep 0.5 +hyprlock \ No newline at end of file diff --git a/scripts/monitors.sh b/scripts/monitors.sh new file mode 100755 index 0000000..14ea2ea --- /dev/null +++ b/scripts/monitors.sh @@ -0,0 +1,2 @@ +#!/bin/bash +hyprctl -j monitors \ No newline at end of file diff --git a/scripts/power.sh b/scripts/power.sh new file mode 100755 index 0000000..3eb62fa --- /dev/null +++ b/scripts/power.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# ____ +# | _ \ _____ _____ _ __ +# | |_) / _ \ \ /\ / / _ \ '__| +# | __/ (_) \ V V / __/ | +# |_| \___/ \_/\_/ \___|_| +# + +if [[ "$1" == "exit" ]]; then + echo ":: Exit" + hyprctl dispatch exit +fi + +if [[ "$1" == "lock" ]]; then + echo ":: Lock" + sleep 0.5 + hyprlock +fi + +if [[ "$1" == "reboot" ]]; then + echo ":: Reboot" + sleep 0.5 + systemctl reboot +fi + +if [[ "$1" == "shutdown" ]]; then + echo ":: Shutdown" + sleep 0.5 + systemctl poweroff +fi + +if [[ "$1" == "suspend" ]]; then + echo ":: Suspend" + sleep 0.5 + systemctl suspend +fi + +if [[ "$1" == "hibernate" ]]; then + echo ":: Hibernate" + sleep 1; + systemctl hibernate +fi diff --git a/scripts/reboot.sh b/scripts/reboot.sh new file mode 100755 index 0000000..2ddff75 --- /dev/null +++ b/scripts/reboot.sh @@ -0,0 +1,3 @@ +#!/bin/bash +sleep 0.5 +systemctl reboot diff --git a/scripts/restart-hypridle.sh b/scripts/restart-hypridle.sh new file mode 100755 index 0000000..fe29461 --- /dev/null +++ b/scripts/restart-hypridle.sh @@ -0,0 +1,5 @@ +#!/bin/bash +killall hypridle +sleep 1 +hypridle & +notify-send "hypridle has been restarted." \ No newline at end of file diff --git a/scripts/screenshot.sh b/scripts/screenshot.sh new file mode 100755 index 0000000..8943e98 --- /dev/null +++ b/scripts/screenshot.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# ____ _ _ +# / ___| ___ _ __ ___ ___ _ __ ___| |__ ___ | |_ +# \___ \ / __| '__/ _ \/ _ \ '_ \/ __| '_ \ / _ \| __| +# ___) | (__| | | __/ __/ | | \__ \ | | | (_) | |_ +# |____/ \___|_| \___|\___|_| |_|___/_| |_|\___/ \__| +# +# +# by Stephan Raabe (2023) +# ----------------------------------------------------- + +DIR="$HOME/Pictures/screenshots/" +NAME="screenshot_$(date +%Y%m%d_%H%M%S).png" + +option2="Selected area" +option3="Fullscreen (delay 3 sec)" +option4="Current display (delay 3 sec)" + +options="$option2\n$option3\n$option4" + +choice=$(echo -e "$options" | rofi -dmenu -replace -config ~/dotfiles/rofi/config-screenshot.rasi -i -no-show-icons -l 3 -width 30 -p "Take Screenshot") + +case $choice in + $option2) + grim -g "$(slurp)" "$DIR$NAME" + xclip -selection clipboard -t image/png -i "$DIR$NAME" + notify-send "Screenshot created and copied to clipboard" "Mode: Selected area" + swappy -f "$DIR$NAME" + ;; + $option3) + sleep 3 + grim "$DIR$NAME" + xclip -selection clipboard -t image/png -i "$DIR$NAME" + notify-send "Screenshot created and copied to clipboard" "Mode: Fullscreen" + swappy -f "$DIR$NAME" + ;; + $option4) + sleep 3 + monitor="$(hyprctl monitors | awk '/Monitor/{monitor=$2} /focused: yes/{print monitor; exit}')" + grim -o "$monitor" "$DIR$NAME" + xclip -selection clipboard -t image/png -i "$DIR$NAME" + notify-send "Screenshot created and copied to clipboard" "Mode: Fullscreen" + swappy -f "$DIR$NAME" + ;; +esac diff --git a/scripts/shutdown.sh b/scripts/shutdown.sh new file mode 100755 index 0000000..48c8296 --- /dev/null +++ b/scripts/shutdown.sh @@ -0,0 +1,3 @@ +#!/bin/bash +sleep 0.5 +systemctl poweroff diff --git a/scripts/suspend.sh b/scripts/suspend.sh new file mode 100755 index 0000000..440d34b --- /dev/null +++ b/scripts/suspend.sh @@ -0,0 +1,3 @@ +#!/bin/bash +sleep 0.5 +systemctl suspend \ No newline at end of file diff --git a/scripts/toggle-animations.sh b/scripts/toggle-animations.sh new file mode 100755 index 0000000..867ecf4 --- /dev/null +++ b/scripts/toggle-animations.sh @@ -0,0 +1,13 @@ +#!/bin/bash +cache_file="$HOME/.cache/toggle_animation" +if [[ $(cat $HOME/dotfiles/hypr/conf/animation.conf) == *"disabled"* ]]; then + echo ":: Toggle blocked by disabled.conf variation." +else + if [ -f $cache_file ] ;then + hyprctl keyword animations:enabled true + rm $cache_file + else + hyprctl keyword animations:enabled false + touch $cache_file + fi +fi \ No newline at end of file diff --git a/scripts/toggleallfloat.sh b/scripts/toggleallfloat.sh new file mode 100755 index 0000000..fb6737c --- /dev/null +++ b/scripts/toggleallfloat.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# _ _ _ __ _ _ +# / \ | | |/ _| | ___ __ _| |_ +# / _ \ | | | |_| |/ _ \ / _` | __| +# / ___ \| | | _| | (_) | (_| | |_ +# /_/ \_\_|_|_| |_|\___/ \__,_|\__| +# +# by Stephan Raabe (2023) +# ----------------------------------------------------- + +hyprctl dispatch workspaceopt allfloat diff --git a/scripts/wallpaper-effects.sh b/scripts/wallpaper-effects.sh new file mode 100755 index 0000000..fb1d020 --- /dev/null +++ b/scripts/wallpaper-effects.sh @@ -0,0 +1,12 @@ + #!/bin/bash + + # Open rofi to select the Hyprshade filter for toggle + options="$(ls ~/dotfiles/hypr/effects/wallpaper/)\noff" + + # Open rofi + choice=$(echo -e "$options" | rofi -dmenu -replace -config ~/dotfiles/rofi/config-themes.rasi -i -no-show-icons -l 5 -width 30 -p "Hyprshade") + if [ ! -z $choice ] ;then + echo "$choice" > ~/dotfiles/.settings/wallpaper-effect.sh + dunstify "Changing Wallpaper Effect to " "$choice" + ~/dotfiles/hypr/scripts/wallpaper.sh init + fi \ No newline at end of file diff --git a/scripts/wallpaper.sh b/scripts/wallpaper.sh new file mode 100755 index 0000000..26ad12b --- /dev/null +++ b/scripts/wallpaper.sh @@ -0,0 +1,211 @@ +#!/bin/bash +# _ _ +# __ ____ _| | |_ __ __ _ _ __ ___ _ __ +# \ \ /\ / / _` | | | '_ \ / _` | '_ \ / _ \ '__| +# \ V V / (_| | | | |_) | (_| | |_) | __/ | +# \_/\_/ \__,_|_|_| .__/ \__,_| .__/ \___|_| +# |_| |_| +# +# by Stephan Raabe (2024) +# ----------------------------------------------------- + +# Cache file for holding the current wallpaper +wallpaper_folder="$HOME/wallpaper" +if [ -f ~/dotfiles/.settings/wallpaper-folder.sh ] ;then + source ~/dotfiles/.settings/wallpaper-folder.sh +fi +used_wallpaper="$HOME/.cache/used_wallpaper" +cache_file="$HOME/.cache/current_wallpaper" +square="$HOME/.cache/square_wallpaper.png" +rasi_file="$HOME/.cache/current_wallpaper.rasi" +blur_file="$HOME/dotfiles/.settings/blur.sh" + +square_dir="$HOME/.cache/square_wallpaper/" + +mkdir -pv "${square_dir}" + +blur="50x30" +blur=$(cat $blur_file) + +# Create cache file if not exists +#if [ ! -f $cache_file ] ;then +# touch $cache_file +# echo "$wallpaper_folder/default.jpg" > "$cache_file" +#fi + +## Create rasi file if not exists +#if [ ! -f $rasi_file ] ;then +# touch $rasi_file +# echo "* { current-image: url(\"$wallpaper_folder/default.jpg\", height); }" > "$rasi_file" +#fi + +#current_wallpaper=$(cat "$cache_file") + +case $1 in + + # Load wallpaper from .cache of last session + "init") + sleep 1 + if [ -f $cache_file ]; then + pass #wal -q -i $current_wallpaper + else + pass #wal -q -i $wallpaper_folder/ + fi + ;; + + # Select wallpaper with rofi + "select") + sleep 0.2 + entries="" + for wp in "${wallpaper_folder}"/*.{jpg,jpeg,png}; do + [[ -f "$wp" ]] || continue + name=$(basename "$wp") + #name="${name%.*}" + sq="${square_dir}/${name%.*}.png" + + if [[ ! -f "${sq}" ]]; then + magick "${wp}" -gravity Center -extent 512:512 "$sq" + fi + entries+="${name}\x00icon\x1f${sq}\n" + done + + selected=$( printf "$entries" | sort -R | rofi -dmenu -i -replace -config ~/dotfiles/rofi/config-wallpaper.rasi) + if [ ! "$selected" ]; then + echo "No wallpaper selected" + exit + fi + #wal -q -i $wallpaper_folder/$selected + export wallpaper=$wallpaper_folder/$selected + echo $wallpaper + ;; + + # Randomly select wallpaper + *) + pass + #wal -q -i $wallpaper_folder/ + ;; + +esac + +# ----------------------------------------------------- +# Load current pywal color scheme +# ----------------------------------------------------- +#source "$HOME/.cache/wal/colors.sh" + +# ----------------------------------------------------- +# get wallpaper image name +# ----------------------------------------------------- +newwall=$(echo $wallpaper | sed "s|$wallpaper_folder/||g") +echo $newwall + +# ----------------------------------------------------- +# Reload waybar with new colors +# ----------------------------------------------------- +~/dotfiles/waybar/launch.sh + +# ----------------------------------------------------- +# Set the new wallpaper +# ----------------------------------------------------- +transition_type="wipe" +# transition_type="outer" +# transition_type="random" + +ln -svfr $wallpaper $used_wallpaper + +# Load Wallpaper Effect +if [ -f $HOME/dotfiles/.settings/wallpaper-effect.sh ] ;then + effect=$(cat $HOME/dotfiles/.settings/wallpaper-effect.sh) + if [ ! "$effect" == "off" ] ;then + if [ "$1" == "init" ] ;then + echo ":: Init" + else + notify-send -e "Using wallpaper effect $effect..." "with image $newwall" -h int:value:10 -h string:x-dunst-stack-tag:wallpaper + fi + source $HOME/dotfiles/hypr/effects/wallpaper/$effect + fi +fi + +wallpaper_engine=$(cat $HOME/dotfiles/.settings/wallpaper-engine.sh) +if [ "$wallpaper_engine" == "awww" ] ;then + # awww + echo ":: Using awww" + awww img $used_wallpaper \ + --transition-bezier .43,1.19,1,.4 \ + --transition-fps=60 \ + --transition-type=$transition_type \ + --transition-duration=0.7 \ + --transition-pos "$( hyprctl cursorpos )" +elif [ "$wallpaper_engine" == "hyprpaper" ] ;then + # hyprpaper + echo ":: Using hyprpaper" + killall hyprpaper + wal_tpl=$(cat $HOME/dotfiles/.settings/hyprpaper.tpl) + output=${wal_tpl//WALLPAPER/$used_wallpaper} + echo "$output" > $HOME/dotfiles/hypr/hyprpaper.conf + hyprpaper & +else + echo ":: Wallpaper Engine disabled" +fi + +if [ "$1" == "init" ] ;then + echo ":: Init" +else + sleep 1 + notifyid=$(notify-send -e "Changing wallpaper ..." "with image $newwall" -h int:value:25 -p) +fi + +# ----------------------------------------------------- +# Created blurred wallpaper +# ----------------------------------------------------- +if [ "$1" == "init" ] ;then + echo ":: Init" +else + notify-send -e "Creating blurred version ..." "with image $newwall" -h int:value:50 -r $notifyid +fi + +#magick $used_wallpaper -resize 75% $blurred +#echo ":: Resized to 75%" +#if [ ! "$blur" == "0x0" ] ;then +# magick $blurred -blur $blur $blurred +# echo ":: Blurred" +#fi + +# ----------------------------------------------------- +# Created quare wallpaper +# ----------------------------------------------------- +if [ "$1" == "init" ] ;then + echo ":: Init" +else + notify-send -e "Creating square version ..." "with image $newwall" -h int:value:75 -r $notifyid +fi +#magick $wallpaper -gravity Center -extent 1:1 $square +name=$(basename "$wallpaper") +ln -svfr "${square_dir}/${name%.*}.png" "$square" +echo ":: Square version created" + +# ----------------------------------------------------- +# Write selected wallpaper into .cache files +# ----------------------------------------------------- +echo "$wallpaper" > "$cache_file" + +#read bw bh < <(identify -format "%w %h" "$blurred") +#rw=900 +#rh=522 +#if (( bw * rh >= rw * bh )); then +# scale=height +#else +# scale=width +#fi +#echo "* { current-image: url(\"$blurred\", $scale); }" > "$rasi_file" + +# ----------------------------------------------------- +# Send notification +# ----------------------------------------------------- + +if [ "$1" == "init" ] ;then + echo ":: Init" +else + notify-send -e "Wallpaper procedure complete!" "with image $newwall" -h int:value:100 -r $notifyid -t 1000 +fi + +echo "DONE!" diff --git a/scripts/xdg.sh b/scripts/xdg.sh new file mode 100755 index 0000000..cc8790e --- /dev/null +++ b/scripts/xdg.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# __ ______ ____ +# \ \/ / _ \ / ___| +# \ /| | | | | _ +# / \| |_| | |_| | +# /_/\_\____/ \____| +# +# ----------------------------------------------------- +sleep 1 + +# kill all possible running xdg-desktop-portals +killall -e xdg-desktop-portal-hyprland +killall -e xdg-desktop-portal-gnome +killall -e xdg-desktop-portal-kde +killall -e xdg-desktop-portal-lxqt +killall -e xdg-desktop-portal-wlr +killall -e xdg-desktop-portal-gtk +killall xdg-desktop-portal +sleep 1 + +# start xdg-desktop-portal-hyprland +/usr/lib/xdg-desktop-portal-hyprland & +sleep 2 + +# start xdg-desktop-portal +/usr/lib/xdg-desktop-portal & +sleep 1 diff --git a/systemd/swaync.service b/systemd/swaync.service new file mode 100644 index 0000000..6c28513 --- /dev/null +++ b/systemd/swaync.service @@ -0,0 +1,18 @@ +[Unit] +Description=Swaync notification daemon +Documentation=https://github.com/ErikReider/SwayNotificationCenter +PartOf=graphical-session.target +After=graphical-session.target +# ConditionEnvironment requires systemd v247 to work correctly +ConditionEnvironment=WAYLAND_DISPLAY + +[Service] +Type=dbus +BusName=org.freedesktop.Notifications +Environment=GTK_THEME=Adwaita:dark +ExecStart=/usr/bin/swaync +ExecReload=/usr/bin/swaync-client --reload-config ; /usr/bin/swaync-client --reload-css +Restart=on-failure + +[Install] +WantedBy=graphical-session.target