give ubuntu mac keystrokes

Add this to your .bashrc at least for one login, especially as root so it installs the packages


# install dependencies
sudo apt-get install -y dbus-x11 // required for below
sudo apt install gnome-sushi // file preview with spacebar
# disable capslock and insert
setxkbmap -option caps:none // I hate capslock
xmodmap -e "keycode 118 = NoSymbol"   # Insert key (usually keycode 118) disabled

# enable command q, command h, command m and command-tab
gsettings set org.gnome.desktop.wm.keybindings close "['<Control>q', '<Super>q']"
gsettings set org.gnome.desktop.wm.keybindings minimize "['<Control>h', '<Super>h']"
gsettings set org.gnome.desktop.wm.keybindings minimize "['<Control>h', '<Super>h', '<Control>m', '<Super>m']"
gsettings set org.gnome.desktop.wm.keybindings switch-applications "['<Super>Tab', '<Control>Tab']"

# turn the windows key into a control key so that windows c, v, x, z behaves like mac command cxvz
cat > ~/.Xmodmap <<'EOF'
keycode 133 = Control_L
keycode 134 = Control_R
EOF
echo "xmodmap ~/.Xmodmap" >> ~/.xprofile
chmod +x ~/.xprofile
xmodmap ~/.Xmodmap

# screenshots on control/win shift 3 and 4
sudo apt install xbindkeys xdotool gnome-screenshot

# Create ~/.xbindkeysrc with correct mapping
cat > ~/.xbindkeysrc <<EOF
"gnome-screenshot -a -c"
  control+shift + mod2 + Release + Mod2 + c:12
"gnome-screenshot -c"
  control+shift + mod2 + Release + Mod2 + c:13
EOF

# Make autostart folder if needed
mkdir -p ~/.config/autostart

# Create xbindkeys autostart .desktop file
cat > ~/.config/autostart/xbindkeys.desktop <<EOF
[Desktop Entry]
Type=Application
Exec=xbindkeys
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=XBindKeys
EOF

# Start xbindkeys now
killall xbindkeys 2>/dev/null
xbindkeys

# set control period to be cancel instead of control C

#!/bin/bash

# Ensure dependencies are present
sudo apt install -y xbindkeys xdotool gnome-screenshot

# Make script folder if it doesn't exist
mkdir -p ~/scripts

# Create the SIGINT script
cat > ~/scripts/send-sigint.sh <<'EOF'
#!/bin/bash
# Send SIGINT to foreground process of focused terminal window

winpid=$(xdotool getwindowpid "$(xdotool getactivewindow)")
target_pid=$(pgrep -P "$winpid" | head -n1)

if [[ -z "$target_pid" ]]; then
  target_pid="$winpid"
fi

kill -INT "$target_pid"
EOF

chmod +x ~/scripts/send-sigint.sh

# Write .xbindkeysrc with snipping and interrupt keys
cat > ~/.xbindkeysrc <<EOF
"gnome-screenshot -a -c"
  control+shift + mod2 + Release + Mod2 + c:12

"gnome-screenshot -c"
  control+shift + mod2 + Release + Mod2 + c:13

"~/scripts/send-sigint.sh"
  control + c:60
EOF

# Add autostart entry
mkdir -p ~/.config/autostart
cat > ~/.config/autostart/xbindkeys.desktop <<EOF
[Desktop Entry]
Type=Application
Name=XBindKeys
Exec=xbindkeys
Hidden=false
X-GNOME-Autostart-enabled=true
NoDisplay=false
EOF

# Restart xbindkeys
killall xbindkeys 2>/dev/null
xbindkeys

echo "✅ Setup complete. Win+Period now sends SIGINT to foreground process."


Popular posts from this blog

Automatically Fix Song Metadata and Filenames on Linux with Beets

throttle traffic on apache

script to show all files with disk usage sizes