目录
Please enable Javascript to view the contents

Ubuntu: 个性化配置及保存路径

 ·  ☕ 4 分钟

    重要

    记录Ubuntu工作机中,一些自定义系统配置所在目录。方便备份和恢复开发环境。

    • install Ubuntu-22.04
    • 登录选择 ubuntu xorg
    • apt update
    • apt upgrade
    • dpkg -i # 运行APPImage的依赖sudo dpkg -i $HOME/apps/packages/libfuse2_2.9.9-5ubuntu3_amd64.deb
    • bash get-docker.sh
    • install sougou
    • install chrome; restart computer
    • 拷贝个人配置cp -r -p <硬盘/home/hex/> /home/hex/
    • 重启检查

    1.简介

    1.1 文件夹书签(Nautilus Add Bookmarks)

    配置文件所在目录 cat /home/hex/.config/gtk-3.0/bookmarks,内容如下:

    1
    2
    3
    4
    
    file:///home/hex/WeChatFiles/hexiang3941/FileStorage/File
    file:///home/hex/Desktop/github
    file:///home/hex/workspace
    file:///home/hex/Documents/%E5%B7%A5%E4%BD%9C%E6%96%87%E4%BB%B6/%E5%85%AC%E5%8F%B8-4-%E8%BD%A6%E7%99%BE%E6%96%87%E6%A1%A3

    注意:

    • 需要填绝对路径
    • 先后顺序为目录显示顺序
    • 文件保存退出,配置即生效

    1.2 用户目录(xdg-user-dirs)

    详细信息,请参考man xdg-user-dirs-update

    配置文件所在目录$HOME/.config/user-dirs.dirs,内容如下:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    
    # This file is written by xdg-user-dirs-update
    # If you want to change or add directories, just edit the line you're
    # interested in. All local changes will be retained on the next run.
    # Format is XDG_xxx_DIR="$HOME/yyy", where yyy is a shell-escaped
    # homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an
    # absolute path. No other format is supported.
    # 
    XDG_DESKTOP_DIR="$HOME/Desktop"
    XDG_DOWNLOAD_DIR="$HOME/Downloads"
    XDG_TEMPLATES_DIR="$HOME/Templates"
    XDG_PUBLICSHARE_DIR="$HOME/Public"
    XDG_DOCUMENTS_DIR="$HOME/Documents"
    XDG_PICTURES_DIR="$HOME/Pictures"
    XDG_Apps_DIR="$HOME/apps"
    XDG_WORKSPACE_DIR="$HOME/workspace"
    XDG_MUSIC_DIR="$HOME/Music"
    XDG_VIDEOS_DIR="$HOME/Videos"

    以上内容,为命令xdg-user-dirs-update生成。通常在用户会话开始时自动执行,来根据语言环境更新用户dirs。此逻辑由下面配置文件/etc/xdg/user-dirs.conf控制

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    
    # This controls the behaviour of xdg-user-dirs-update which is run on user login
    # You can also have per-user config in ~/.config/user-dirs.conf, or specify
    # the XDG_CONFIG_HOME and/or XDG_CONFIG_DIRS to override this
    #
    
    enabled=True
    
    # This sets the filename encoding to use. You can specify an explicit
    # encoding, or "locale" which means the encoding of the users locale
    # will be used
    filename_encoding=UTF-8

    有些目录像Music\Vedio不会经常使用,不想让系统自动创建,可以讲上面配置文件设置为enabled=False。但这样会导致部分问题

    比如Nautilus文件工具通过$HOME/Template目录中文件,显示新建文件时的选项。删除此目录会导致鼠标右键无新建文件选项。

    (但其他文件管理系统Thunar[xfce默认]Nemo[cinnamon默认]没有这个问题)

    隐藏不需要目录方法:

    • 一种:删除目录,并执行命令xdg-user-dirs-update
    • 另一种:改变位置
    • 最后一种:手动修改文件,并讲设置为false,禁止自动更新

    简单操作举例:

    1
    2
    3
    4
    5
    6
    
    # 1. 创建默认目录
    xdg-user-dirs-update
    # 2. 创建自定义目录
    xdg-user-dirs-update --set DOWNLOAD ~/Internet
    # 3. 查询
    xdg-user-dir TEMPLATES

    1.3 本地Desktop存储目录

    配置文件目录$HOME/.local/share/applications/, 配置文件jetbrains-goland.desktop示例如下:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    
    [Desktop Entry]
    Version=1.0
    Type=Application
    Name=GoLand
    Icon=/home/hex/apps/GoLand-2021.1.3/bin/goland.svg
    Exec="/home/hex/apps/GoLand-2021.1.3/bin/goland.sh" %f
    Comment=Cross-platform IDE built specially for Go developers
    Categories=Development;IDE;
    Terminal=false
    StartupWMClass=jetbrains-goland

    1.4 快捷键存储目录(keyboard)

    1.5 运行appImage失败

    原因:Ubuntu 22.04 不再默认安装 libfuse2,导致运行appImage时报错如下

    1
    2
    3
    4
    5
    
    AppImages require FUSE to run.
    You might still be able to extract the contents of this AppImage
    if you run it with the --appimage-extract option.
    See https://github.com/AppImage/AppImageKit/wiki/FUSE
    for more information

    需要安装libfuse2

    1.5 截图工具flameshot无法使用(Gnome4.1+)

    在登录时,选择ubuntu xorg则解决问题

    1
    
    sudo apt install libfuse2 

    或者离线安装

    1
    
    sudo dpkg -i $HOME/apps/packages/libfuse2_2.9.9-5ubuntu3_amd64.deb

    1.6 压缩包安装Typora

    1. 解压安装包

      1
      2
      3
      
      mkdir /tmp/typora
      tar -zxvf /home/hex/apps/packages/办公软件/Typora-linux-x64.tar.gz -C /tmp/typora
      mv /tmp/typora/bin/Typora-linux-x64 $HOME/apps/Typora
    2. 创建软连接

      是为了在命令行执行 typora </md/file/path>, 打开命令行工具

      1
      
      ln -s /home/hex/apps/Typora/Typora /usr/local/bin/typora
    3. 创建Desktop

      将以下内容拷贝至文件/home/hex/.local/share/applications/self-typora.desktop

      1
      2
      3
      4
      5
      6
      
      [Desktop Entry]
      Name=typora
      Exec=/home/hex/apps/Typora/Typora
      Icon=/home/hex/apps/Typora/resources/app/asserts/icon/icon_512x512.png
      Type=Application
      StartupNotify=true

      文件保存即生效

    1.7 卸载软件

    1
    2
    3
    
    sudo apt-get remove --purge libreoffice*
    sudo apt clean
    sudo apt-get autoremove

    1.8 个性化设置

    • 点击最小化

      1
      
      gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'minimize'

      执行后即时生效

    • 显示电池电量百分比

      Settings - Power - Show Battery Percentage 点击开启

    • 改变图标大小

      • Settings - Appearance - Dock Icon size 设置值 48
      • Settings - Appearance - Dock Icon size 设置值 48
    • 显示设置

      • Ubuntu一般会自动识别HI-DPI屏幕并适当扩展。如果没有,需要手动进行调整。

        Settings -> Displays -> enable Fractional scaling -> 选择合适地比例

      • docker-run 地微信显示出现问题,调整DPI环境变量。此值计算方式为分别率/英寸,例如200

    • 安装字体、编解码器

      微软字体、主流媒体格式

      1
      
      sudo apt install ubuntu-restricted-extras

    1.9 声音

    • 检查pulseaudio状态

      1
      
      pulseaudio --check

      它通常不打印输出,只需退出代码即可。0表示运行。

    • 停止

      1
      2
      3
      
      pulseaudio -k
      # or
      killall pulseaudio
    • 后台期待

      1
      
      pulseaudio -D

    Reference

    分享

    Hex
    作者
    Hex
    CloudNative Developer