Skip to content

Instantly share code, notes, and snippets.

@haryp2309
Last active June 4, 2024 19:32
Show Gist options
  • Save haryp2309/cc7232cc23e6fe44d0654a8a074ef7fe to your computer and use it in GitHub Desktop.
Save haryp2309/cc7232cc23e6fe44d0654a8a074ef7fe to your computer and use it in GitHub Desktop.
Fedora Silverblue Setup

Fedora Silverblue Setup

Systemd Services

  • Auto Update Dev Container (custom scripts, see below)
  • Logitech Service (logiops)
  • Auto Clean Downloads

Logitech MX Master 2S Setup

/etc/logid.cfg:

devices: ({
    name: "Wireless Mouse MX Master 2S";

    // A lower threshold number makes the wheel switch to free-spin mode
    // quicker when scrolling fast.
    smartshift: { on: true; threshold: 20; };

    hiresscroll: {
        hires: true;
        invert: false;
        target: true;
        up: {
              mode: "Axis";
              axis: "REL_WHEEL_HI_RES";
              axis_multiplier: 2;
          },
          down: {
              mode: "Axis";
              axis: "REL_WHEEL_HI_RES";
              axis_multiplier: -2;
          },
      };


    // Higher numbers make the mouse more sensitive (cursor moves faster),
    // 4000 max for MX Master 3.
    dpi: 1500;

    buttons: (

      // Make thumb button 10.
      { cid: 0x53; action = { type: "Keypress"; keys: ["KEY_BACK"]; }; },

      // Make top button 11.
      { cid: 0x56; action = { type: "Keypress"; keys: ["KEY_FORWARD"];    }; },
      
      // Gesture Button to CTRL
      { cid: 0xc3; action = { type: "Keypress"; keys: ["KEY_LEFTCTRL"];    }; },
      
      {
        cid: 0xc4;
        action =
              {
                  type: "Gestures";
                  gestures: (
                      {
                          direction: "Left";
                          mode: "OnThreshold";
                          action =
                          {
                              type: "Keypress";
                              keys: ["KEY_LEFTMETA", "KEY_PAGEDOWN"];
                          };
                      },
                      {
                          direction: "Right";
                          mode: "OnThreshold";
                          action =
                          {
                              type: "Keypress";
                              keys: ["KEY_LEFTMETA", "KEY_PAGEUP"];
                          }
                      },

                      {
                          direction: "None"
                          mode: "OnRelease";
                          action =
                          {
                              type: "Keypress";
                              keys: ["KEY_LEFTMETA"];
                          }
                      }
                  );
              };
      },

    );
  });

Custom Scripts

Auto Update Dev Container (systemd service)

  1. Install dnf-automatic on the container
  2. Enable apply_updates in sudoedit /etc/dnf/automatic.conf
  3. Export dnf-automatic.timer and dnf-automatic.service from distrobox.
    • distrobox-export --service dnf-automatic.timer
    • distrobox-export --service dnf-automatic.service
  4. Enable dnf-automatic.timer in host: systemctl enable --now development-dnf-automatic.timer
  5. Update ~/.config/systemd/user/development-dnf-automatic.timerto update at wanted time of day.

Auto Clean Downloads

import os
import time
from pathlib import Path
from subprocess import run

MAX_DAYS = 3

current_time = time.time()
dir_path = Path.home() / "Downloads"
for f in os.listdir(dir_path):
    f_full_path = dir_path / f
    creation_time = os.path.getctime(f_full_path)
    if (current_time - creation_time) // (24 * 60 * 60) >= MAX_DAYS:
        # try:
        #     os.remove(f_full_path)
        # except IsADirectoryError:
        #     shutil.rmtree(f_full_path)
        run(["gio", "trash", f_full_path])
        print(f"{f} removed")

Development Container Setup

Symlinks

Documents and Downloads folder is symlinked with host

VS Code

Installed through dnf directly into the container. Exported through distrobox as both bin and app to the host

Host integration aliases

~/.profile:

# Host Aliases
for COMMAND in "gnome-text-editor"
alias dh="distrobox-host-exec"
do
    alias $COMMAND="distrobox-host-exec $COMMAND"
done
...

~/.config/fish/config.fish:

alias dh="distrobox-host-exec"
for COMMAND in "gnome-text-editor"
    alias $COMMAND="distrobox-host-exec $COMMAND"
end

Access host podman from container

~/.local/bin/podman:

#! /bin/sh

exec distrobox-host-exec podman $@

Moreadwaita Icon Pack

Update script

#! /bin/python3

from pathlib import Path
from subprocess import run, check_output

git_project_path = (Path(__file__).parent / "MoreWaita").absolute()


def log(*args):
    print("[UPDATE_SCRIPT]:", *args)


def get_git_hash():
    hash = (
        check_output(["git", "rev-parse", "HEAD"], cwd=git_project_path)
        .decode()
        .strip()
    )
    log("Found hash:", hash)
    return hash


def get_updates():
    pre_hash = get_git_hash()
    log("Doing git pull")
    run(["git", "pull"], cwd=git_project_path)
    post_hash = get_git_hash()
    return pre_hash != post_hash


is_update_available = get_updates()

if is_update_available:
    log("Changes detected. Updating theme...")
    run("./install.sh", cwd=git_project_path)
    log("Notifying desktop")
    run(
        [
            "notify-send",
            "MoreWaita was updated",
            "MoreWaita IconPack was updated using your own script!",
        ]
    )
    log("DONE!")
else:
    log("No updates detected")

Wayland Fixes

Chromium Based Browsers

  • Add --enable-features=UseOzonePlatform,TouchpadOverscrollHistoryNavigation --ozone-platform=wayland as arguments when executing binary on .desktop files.
  • Enable Ozone in chrome flags.

Spotify (Flatpak)

Switch execution property to be:

/usr/bin/flatpak run \
	--socket=wayland \
	--branch=stable \
	--arch=x86_64 \
	--command=/app/extra/bin/spotify \
	--file-forwarding com.spotify.Client \
	--ozone-platform=wayland \
	'--enable-features=WaylandWindowDecorations' \
	@@u %U @@

VS Code

Switch execution property to be:

/usr/bin/distrobox-enter  -n dev -- env ELECTRON_TRASH=trash-cli GTK_USE_PORTAL=1 /usr/share/code/code --enable-features=WaylandWindowDecorations --enable-features=UseOzonePlatform --ozone-platform=wayland --unity-launch  %F
@orcbolg3612
Copy link

📦[keyhost505@fedora ~]$ distrobox-export --service dnf-automatic.timer
ERROR: Invalid flag '--service'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment