Compare commits

...

2 Commits

Author SHA1 Message Date
711a3da32d update change-wallpaper script 2025-07-25 21:10:38 -07:00
e101b81abd update hyprland and add rmpc config 2025-07-25 20:42:28 -07:00
4 changed files with 304 additions and 15 deletions

View File

@@ -223,7 +223,7 @@ device {
}
render {
explicit_sync = true
# explicit_sync = true
}
misc {
@@ -256,7 +256,9 @@ misc {
# windowrulev2 = float, class:com.mitchellh.ghostty
windowrule = float, class:discord
windowrule = float, class:mpv
windowrule = float, class:steam
windowrule = workspace 10 silent, class:discord
windowrule = workspace 9 silent, class:steam
# windowruv2 = opacity 0.88, class:.* fullscreen:0
windowrule = opacity 0.88, class:.* fullscreen:0
# windowruv2 = opacity 1, class:.* fullscreen:0

View File

@@ -106,9 +106,9 @@ bind = SUPER, m, exec, ~/.local/bin/mpv-add.sh
bind = SUPER SHIFT, s, exec, slurp | grim -g - - | wl-copy
bind = ,code:107, exec, ~/.local/bin/screenshot
bind = SUPER,code:107, exec, flameshot screen
bind = SUPER SHIFT, o, exec, ~/.local/bin/ocr.sh
bind = $mainMod, o, exec, ~/.local/bin/ocr.sh
bind = $mainMod SHIFT, o, exec, ~/.local/bin/rofi-open tab
bind = SUPER, o, exec, ~/.local/bin/ocr.sh
bind = $mainMod, o, exec, ~/.local/bin/rofi-open tab
bind = $mainMod SHIFT, o, exec, ~/.local/bin/rofi-open window
# change wallpaper
bind = $mainMod CTRL, n, exec, ~/.local/bin/change-wallpaper

235
.config/rmpc/config.ron Normal file
View File

@@ -0,0 +1,235 @@
#![enable(implicit_some)]
#![enable(unwrap_newtypes)]
#![enable(unwrap_variant_newtypes)]
(
address: "127.0.0.1:6600",
password: None,
theme: None,
cache_dir: "/tmp/rmpc",
on_song_change: ["songinfo"],
volume_step: 5,
max_fps: 144,
scrolloff: 0,
wrap_navigation: false,
enable_mouse: true,
enable_config_hot_reload: true,
status_update_interval_ms: 1000,
rewind_to_start_sec: None,
reflect_changes_to_playlist: false,
select_current_song_on_change: false,
browser_song_sort: [Disc, Track, Artist, Title],
directories_sort: SortFormat(group_by_type: true, reverse: false),
keybinds: (
global: {
":": CommandMode,
",": VolumeDown,
"s": Stop,
".": VolumeUp,
"<Tab>": NextTab,
"<S-Tab>": PreviousTab,
"1": SwitchToTab("Queue"),
"2": SwitchToTab("Directories"),
"3": SwitchToTab("Artists"),
"4": SwitchToTab("Album Artists"),
"5": SwitchToTab("Albums"),
"6": SwitchToTab("Playlists"),
"7": SwitchToTab("Search"),
"q": Quit,
">": NextTrack,
"p": TogglePause,
"<": PreviousTrack,
"f": SeekForward,
"z": ToggleRepeat,
"x": ToggleRandom,
"c": ToggleConsume,
"v": ToggleSingle,
"b": SeekBack,
"?": ShowHelp,
"u": Update,
"U": Rescan,
"I": ShowCurrentSongInfo,
"O": ShowOutputs,
"P": ShowDecoders,
"R": AddRandom,
},
navigation: {
"k": Up,
"j": Down,
"h": Left,
"l": Right,
"<Up>": Up,
"<Down>": Down,
"<Left>": Left,
"<Right>": Right,
"<C-k>": PaneUp,
"<C-j>": PaneDown,
"<C-h>": PaneLeft,
"<C-l>": PaneRight,
"<C-u>": UpHalf,
"N": PreviousResult,
"a": Add,
"A": AddAll,
"r": Rename,
"n": NextResult,
"g": Top,
"<Space>": Select,
"<C-Space>": InvertSelection,
"G": Bottom,
"<CR>": Confirm,
"i": FocusInput,
"J": MoveDown,
"<C-d>": DownHalf,
"/": EnterSearch,
"<C-c>": Close,
"<Esc>": Close,
"K": MoveUp,
"D": Delete,
"B": ShowInfo,
},
queue: {
"D": DeleteAll,
"<CR>": Play,
"<C-s>": Save,
"a": AddToPlaylist,
"d": Delete,
"C": JumpToCurrent,
"X": Shuffle,
},
),
search: (
case_sensitive: false,
mode: Contains,
tags: [
(value: "any", label: "Any Tag"),
(value: "artist", label: "Artist"),
(value: "album", label: "Album"),
(value: "albumartist", label: "Album Artist"),
(value: "title", label: "Title"),
(value: "filename", label: "Filename"),
(value: "genre", label: "Genre"),
],
),
artists: (
album_display_mode: SplitByDate,
album_sort_by: Date,
),
default_album_art_path: None,
draw_borders: false,
show_song_table_header: false,
symbols: (song: "🎵", dir: "📁", playlist: "🎼", marker: "\u{e0b0}"),
layout: Split(
direction: Vertical,
panes: [
(
pane: Pane(Header),
size: "1",
),
(
pane: Pane(TabContent),
size: "100%",
),
(
pane: Pane(ProgressBar),
size: "1",
),
],
),
progress_bar: (
symbols: ["", "", "⭘", " ", " "],
track_style: (bg: "#1e2030"),
elapsed_style: (fg: "#c6a0f6", bg: "#1e2030"),
thumb_style: (fg: "#c6a0f6", bg: "#1e2030"),
),
scrollbar: (
symbols: ["│", "█", "▲", "▼"],
track_style: (),
ends_style: (),
thumb_style: (fg: "#b7bdf8"),
),
browser_column_widths: [20, 38, 42],
text_color: "#cad3f5",
background_color: "#24273a",
header_background_color: "#1e2030",
modal_background_color: None,
modal_backdrop: false,
tab_bar: (active_style: (fg: "black", bg: "#c6a0f6", modifiers: "Bold"), inactive_style: ()),
borders_style: (fg: "#6e738d"),
highlighted_item_style: (fg: "#c6a0f6", modifiers: "Bold"),
current_item_style: (fg: "black", bg: "#b7bdf8", modifiers: "Bold"),
highlight_border_style: (fg: "#b7bdf8"),
song_table_format: [
(
prop: (kind: Property(Artist), style: (fg: "#b7bdf8"), default: (kind: Text("Unknown"))),
width: "50%",
alignment: Right,
),
(
prop: (kind: Text("-"), style: (fg: "#b7bdf8"), default: (kind: Text("Unknown"))),
width: "1",
alignment: Center,
),
(
prop: (kind: Property(Title), style: (fg: "#7dc4e4"), default: (kind: Text("Unknown"))),
width: "50%",
),
],
header: (
rows: [
(
left: [
(kind: Text("["), style: (fg: "#b7bdf8", modifiers: "Bold")),
(kind: Property(Status(State)), style: (fg: "#b7bdf8", modifiers: "Bold")),
(kind: Text("]"), style: (fg: "#b7bdf8", modifiers: "Bold"))
],
center: [
(kind: Property(Song(Artist)), style: (fg: "#eed49f", modifiers: "Bold"),
default: (kind: Text("Unknown"), style: (fg: "#eed49f", modifiers: "Bold"))
),
(kind: Text(" - ")),
(kind: Property(Song(Title)), style: (fg: "#7dc4e4", modifiers: "Bold"),
default: (kind: Text("No Song"), style: (fg: "#7dc4e4", modifiers: "Bold"))
)
],
right: [
(kind: Text("Vol: "), style: (fg: "#b7bdf8", modifiers: "Bold")),
(kind: Property(Status(Volume)), style: (fg: "#b7bdf8", modifiers: "Bold")),
(kind: Text("% "), style: (fg: "#b7bdf8", modifiers: "Bold"))
]
)
],
),
tabs: [
(
name: "Queue",
pane: Split(
direction: Horizontal,
panes: [(size: "60%", pane: Pane(Queue)), (size: "40%", pane: Pane(AlbumArt))],
),
),
(
name: "Directories",
pane: Pane(Directories),
),
(
name: "Artists",
pane: Pane(Artists),
),
(
name: "Album Artists",
pane: Pane(AlbumArtists),
),
(
name: "Albums",
pane: Pane(Albums),
),
(
name: "Playlists",
pane: Pane(Playlists),
),
(
name: "Search",
pane: Pane(Search),
),
],
)

View File

@@ -11,6 +11,7 @@ import (
"os/exec"
"path/filepath"
"regexp"
"sort"
"strings"
"time"
)
@@ -21,29 +22,42 @@ const (
)
type Config struct {
Topics []string `json:"topics"`
Topics []string `json:"topics"`
Keep int `json:"keep"` // Number of wallpapers to keep (0 = never delete)
WallpaperDir string `json:"wallpaperDir"` // Directory to store wallpapers
}
var defaultTopics = []string{
"lofi",
}
func loadConfig() []string {
const defaultKeep = 10
func loadConfig() (topics []string, keep int, wallpaperDir string) {
homeDir, err := os.UserHomeDir()
if err != nil {
return defaultTopics
return defaultTopics, defaultKeep, wallpaperDir
}
configPath := filepath.Join(homeDir, ".config", "change-wallpaper", "config.json")
file, err := os.Open(configPath)
if err != nil {
return defaultTopics
return defaultTopics, defaultKeep, wallpaperDir
}
defer file.Close()
var cfg Config
if err := json.NewDecoder(file).Decode(&cfg); err != nil || len(cfg.Topics) == 0 {
return defaultTopics
if err := json.NewDecoder(file).Decode(&cfg); err != nil {
return defaultTopics, defaultKeep, wallpaperDir
}
return cfg.Topics
if len(cfg.Topics) == 0 {
cfg.Topics = defaultTopics
}
if cfg.Keep < 0 {
cfg.Keep = defaultKeep
}
if cfg.WallpaperDir == "" {
cfg.WallpaperDir = wallpaperDir
}
return cfg.Topics, cfg.Keep, cfg.WallpaperDir
}
type WallhavenResponse struct {
@@ -57,7 +71,7 @@ func main() {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
// Load topics from config or use defaults
topics := loadConfig()
topics, keep, configWallpaperDir := loadConfig()
// Check if a file path was provided as argument
if len(os.Args) > 1 {
@@ -75,14 +89,26 @@ func main() {
os.Exit(1)
}
wallpaperPath := filepath.Join(homeDir, wallpaperDir)
// Use config wallpaper directory if set, otherwise use default
var wallpaperPath string
if configWallpaperDir != "" {
if strings.HasPrefix(configWallpaperDir, "~/") {
wallpaperPath = filepath.Join(homeDir, configWallpaperDir[2:])
} else if configWallpaperDir == "~" {
wallpaperPath = homeDir
} else {
wallpaperPath = configWallpaperDir
}
} else {
wallpaperPath = filepath.Join(homeDir, wallpaperDir)
}
if err := os.MkdirAll(wallpaperPath, 0755); err != nil {
fmt.Fprintf(os.Stderr, "Error creating wallpaper directory: %v\n", err)
os.Exit(1)
}
// Download and set new wallpaper
newWallpaper, topic := downloadRandomWallpaper(wallpaperPath, r, topics)
newWallpaper, topic := downloadRandomWallpaper(wallpaperPath, r, topics, keep)
if newWallpaper != "" {
changeWallpaper(newWallpaper, topic)
} else {
@@ -91,7 +117,33 @@ func main() {
}
}
func downloadRandomWallpaper(wallpaperPath string, r *rand.Rand, topics []string) (string, string) {
func downloadRandomWallpaper(wallpaperPath string, r *rand.Rand, topics []string, keep int) (string, string) {
// Clean up old wallpapers before downloading a new one, if keep > 0
if keep > 0 {
files, err := os.ReadDir(wallpaperPath)
if err == nil && len(files) > keep {
type fileInfo struct {
name string
mod int64
}
var fileInfos []fileInfo
for _, f := range files {
if !f.IsDir() {
info, err := f.Info()
if err == nil {
fileInfos = append(fileInfos, fileInfo{f.Name(), info.ModTime().Unix()})
}
}
}
// Sort by mod time, newest first
sort.Slice(fileInfos, func(i, j int) bool { return fileInfos[i].mod > fileInfos[j].mod })
for _, f := range fileInfos[keep:] {
os.Remove(filepath.Join(wallpaperPath, f.name))
}
}
}
// If keep == 0, never delete
// Select random topic
topic := topics[r.Intn(len(topics))]
var query string